ArizaLuca wrote: ↑Fri Sep 21, 2018 9:05 pm
So my game works in that once you've finished one 'version' of the script, it jumps to another version. However, when I try to do it, it continually starts from the same script.
Code: Select all
label start:
if persistent.sa == False:
jump socialanxiety
elif persistent.se == False:
jump selfesteem
elif persistent.s == False:
jump stress
elif persistent.whatareyoudoinghere == False:
jump whatareyoudoinghere
elif persistent.normal == False:
jump normal
That's the code I'm using at the moment. Every time I try to do the endings below the 'social anxiety' one, it won't move. What is the issue?
From your post I can't see the obvious order. Can you please describe it? What is your desired order? How are you expecting the program to behave? Is "jump normal" the first gameplay you desire?
On the other hand, it's not a good idea to check for False using "if variable == False". In fact, persistent variables, when not defined, have the default value of None, not False.
There are different ways of using persistent variables:
When using persistent variables as simply boolean flags, the easiest way is:
1-Don't define the variables from the beginning.
2-Check if the variable is True only with the variable:
Code: Select all
if persistent.myvar:
do something
else: # <-- optionally
do other things
If you need to check if the variable is not True, use the simplest way:
Code: Select all
if not persistent.myvar:
do something
Do not use "if persistent.myvar == False" or "if persistent.myvar == None". You could use "if persistent.myvar is None", but why use that? Use the simplest.
3-At the end of the gameplay, change the variable to True:
You need a different variable for every flag you need to be persistent.
BUT you can use persistent variables in more complex ways.
1.For example, define a persistent list:
Code: Select all
define persistent.endings = [] ## Remeber, 0 spaces of indentation here. This will be run at init phase.
2.You can check if an ending has been read:
Code: Select all
if "ending1" in persistent.endings:
do something
Or check if it has not been read:
Code: Select all
if "ending2" not in persistent.endings:
3.At the end of the ending, add the "endingX" to the list:
Code: Select all
label ending1:
if "ending1" not in persistent.endings:
$ persistent.endings.append("ending1")
At last, note that "persistent" variables are intended to be somewhat "outside" the game narrative (to unlock bonus, for example), but it is not a good idea to use them for the narrative itself, specially if you want to check them at the beginning of the game. You'd need to provide a way to reset the persistent variables if you do that.
I mean: Let's say a game starts in a normal way, when the normal ending is reached, it changes the persistent variable so the game will start in a secondary way. So, from that moment, no one can play again the normal way in that computer if you don't change again the persistent variable to the initial value.