# Question on permenant variables

**URL:** <https://forum.choiceofgames.com/t/question-on-permenant-variables/1671>\
**Category:** ChoiceScript Help\
**Created:** [September 9, 2013, 10:04pm UTC](https://forum.choiceofgames.com/t/question-on-permenant-variables/1671 "2013-09-09T22:04:18Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![isisius](https://avatars.discourse-cdn.com/v4/letter/i/df705f/32.png) [@isisius](https://forum.choiceofgames.com/u/isisius)\
**Post date:** [September 9, 2013, 10:04pm UTC](https://forum.choiceofgames.com/t/question-on-permenant-variables/1671/1 "2013-09-09T22:04:18Z")

</div>

I have tried and couldnt actually find any information on this, so apologies if ive just missed a thread explaining this.  
Is it possible to create a variable that exists outside the game. So by that i mean, if i want users to bea ble to unlock things after multiple playthroughs?  
I did notice a thread earlier talk about just sending that user back to the start instead of making an ending after the game, but i wanted to do it in a way where if a user has dont something, it is unlocked for the next game.  
An example, if a user has played through and discovered magic, in their next game they can choose that their father was a magician, and as such it will effect the gameplay on any future playthroughs.  
However if they decide they want to start the game again (hit restart halfway through that second play-through), they are still able to select the option to have their father have been a magician.

Does my question make sense? If not i can clarify further.

---

<div class="post-metadata">

**Author:** ![Celtic\_Rune](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/celtic_rune/32/48141_2.png) [@Celtic\_Rune](https://forum.choiceofgames.com/u/Celtic_Rune)\
**Post date:** [September 10, 2013, 1:21am UTC](https://forum.choiceofgames.com/t/question-on-permenant-variables/1671/2 "2013-09-10T01:21:10Z")

</div>

You could try working with a password? Like, if they discover one of those permanent variables, give them a password, and if they enter that password at the beginning of the next game, the permanent variables will spring into action? Something like that?

I’m sure there is a more immersive way in which this can be done, but for that you’d have to wait until one of the more experienced coders on the forum picks up on this thread (which I’m sure they will)

---

<div class="post-metadata">

**Author:** ![isisius](https://avatars.discourse-cdn.com/v4/letter/i/df705f/32.png) [@isisius](https://forum.choiceofgames.com/u/isisius)\
**Post date:** [September 10, 2013, 2:09am UTC](https://forum.choiceofgames.com/t/question-on-permenant-variables/1671/3 "2013-09-10T02:09:34Z")

</div>

Thanks man, i did think about the password but it just seems a little fiddly in that they need to keep the password saved somewhere when they want to enter it, and then people can just get the password easily off websites.  
I like the idea of earning variables by exploring the game, which can unlock further story or bonuses. Feels like it adds a little bit to the replayability if done well.

---

<div class="post-metadata">

**Author:** ![FairyGodfeather](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/fairygodfeather/32/16709_2.png) [@FairyGodfeather](https://forum.choiceofgames.com/u/FairyGodfeather)\
**Post date:** [September 10, 2013, 3:30am UTC](https://forum.choiceofgames.com/t/question-on-permenant-variables/1671/4 "2013-09-10T03:30:53Z")

</div>

You could make the password something easy to remember, of course that doesn’t stop the problem of people cheating but if they want to cheat then they want to cheat. I think that’s the easiest way, to have an input password and then abracadabra as the password or something.

You can also send the player back to the start at the end instead of restarting. That causes issues though, it means they can’t just restart the game from the second playthrough. I think the password system is easier.

---

<div class="post-metadata">

**Author:** ![CJW](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/cjw/32/111787_2.png) [@CJW](https://forum.choiceofgames.com/u/CJW)\
**Post date:** [September 10, 2013, 3:51am UTC](https://forum.choiceofgames.com/t/question-on-permenant-variables/1671/5 "2013-09-10T03:51:01Z")

</div>

You could probably make some sort of REALLY simple hashing or obfuscating algorithm for the password.

You’d then want to include the player’s character’s name in the password generation, so that the password itself will only work if the player chooses that same name a second time round. It’s not foolproof of course, any code you write to hash a password can simply be reverse engineered to unhash it, but it’ll take some small effort, so hopefully it’ll go \*some\* way towards putting people off cheating.

But I still think the easiest way to do this would be to utilize a save system, either CoG’s \*show\_password, my framework or your own solution.

Though you’d need to be clever about tweaking it to start from the beginning again - it’s still the easiest and most robust method I can think of.

---

<div class="post-metadata">

**Author:** ![isisius](https://avatars.discourse-cdn.com/v4/letter/i/df705f/32.png) [@isisius](https://forum.choiceofgames.com/u/isisius)\
**Post date:** [September 10, 2013, 8:12am UTC](https://forum.choiceofgames.com/t/question-on-permenant-variables/1671/6 "2013-09-10T08:12:07Z")

</div>

Alright, well its something that ill have a think about then.  
It was just something i was thinking about in passing, im kinda just playing with it at the moment, but i might try this discussion again if i get more serious about wanting something like this.  
Thanks guys 🙂

---

<div class="post-metadata">

**Author:** ![DaveDPF](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/davedpf/32/992_2.png) [@DaveDPF](https://forum.choiceofgames.com/u/DaveDPF)\
**Post date:** [September 10, 2013, 10:19am UTC](https://forum.choiceofgames.com/t/question-on-permenant-variables/1671/7 "2013-09-10T10:19:11Z")

</div>

Very informative thread, thank you all.

---

<div class="post-metadata">

**Author:** ![FairyGodfeather](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/fairygodfeather/32/16709_2.png) [@FairyGodfeather](https://forum.choiceofgames.com/u/FairyGodfeather)\
**Post date:** [September 10, 2013, 12:44pm UTC](https://forum.choiceofgames.com/t/question-on-permenant-variables/1671/8 "2013-09-10T12:44:47Z")

</div>

You could always just trust the player. Ask them if they’ve finished the game before and then have a few questions before the game starts to see what they can unlock. If they choose to cheat then so be it. They’ll lose out on the experience that you had planned, but that’s their decision.

You could also include things that only happen in the first playthrough. Let the player know that by choosing newgame+ they’re going to miss out on some things even if they unlock others. That might dissuade people from cheating on their first go.

---

<div class="post-metadata">

**Author:** ![Lucid](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/lucid/32/39775_2.png) [@Lucid](https://forum.choiceofgames.com/u/Lucid)\
**Post date:** [September 10, 2013, 8:50pm UTC](https://forum.choiceofgames.com/t/question-on-permenant-variables/1671/9 "2013-09-10T20:50:14Z")

</div>

I think that the best way is still to just to loop back to the beginning of the game. You end up with a nice Legacy game without any of the unnecessary passwords and extra problems. 🙂

---

<div class="post-metadata">

**Author:** ![isisius](https://avatars.discourse-cdn.com/v4/letter/i/df705f/32.png) [@isisius](https://forum.choiceofgames.com/u/isisius)\
**Post date:** [September 11, 2013, 8:48pm UTC](https://forum.choiceofgames.com/t/question-on-permenant-variables/1671/10 "2013-09-11T20:48:19Z")

</div>

See I like the idea of the Legacy game, its exactly what i was aiming for the only issue i have is that i want people to be able to go back to the start of that game without losing the stuff from the game before.  
The vision i was having was that when someone starts a new game they are able to choose what their father was if they have unlocked it.

So if they have discovered magic, they can choose that he was a mage, or if they managed to get knighted in a game, he was a nobleman. Doing this would unlock more possibilities in the next playthrough.

So i’d like the player to be able to restart the game mid game if they have accidentally made a choice they didn’t want to, but not lose the things they may have unlocked.  
Further more i would like them to be able to always play with a mage ancestor if they have unlocked it once.

Maybe i could add a “restart” button to the stats screen which restarts it in the way i want to (i.e loop back to the start)  
From what i understand i could just have boolean variables that change from false to true if they unlock them during the game, and as long as they don’t actually restart the game.  
The only problem then is making sure the user sees that as the way to restart the game, and not have them click the restart button on the opening screen.

I have a vague recollection of the Choice of Romance games having options you can unlock by purchasing them. Something to do with being able to start as a life mage.  
That must mean that there is the possibility of having variables that are permanently set outside of the game, i guess it just depends on whether we can use them or not.

---

<div class="post-metadata">

**Author:** ![FairyGodfeather](https://sea3.discourse-cdn.com/choiceofgames/user_avatar/forum.choiceofgames.com/fairygodfeather/32/16709_2.png) [@FairyGodfeather](https://forum.choiceofgames.com/u/FairyGodfeather)\
**Post date:** [September 11, 2013, 9:01pm UTC](https://forum.choiceofgames.com/t/question-on-permenant-variables/1671/11 "2013-09-11T21:01:27Z")

</div>

The games with unlockable variables do it with a \*set paidcontent true and then an \*if paidcontent I think. (Although not those exact commands.)

You could mail @dfabulich and ask him if what you want to do can be done.

---

<div class="post-metadata">

**Author:** ![isisius](https://avatars.discourse-cdn.com/v4/letter/i/df705f/32.png) [@isisius](https://forum.choiceofgames.com/u/isisius)\
**Post date:** [September 11, 2013, 9:18pm UTC](https://forum.choiceofgames.com/t/question-on-permenant-variables/1671/12 "2013-09-11T21:18:53Z")

</div>

Ahhh that makes sense, so in essence there do exist variables of some sort at the “menu” level, but whether they are customizable or not is another thing.  
Thanks, i might just send him a message regarding this, just so i know if its possible or not 🙂
