Script Won't Start The Way I Want To {SOLVED}

Discuss how to use the Ren'Py engine to create visual novels and story-based games. New releases are announced in this section.
Forum rules
This is the right place for Ren'Py help. Please ask one question per thread, use a descriptive subject like 'NotFound error in option.rpy' , and include all the relevant information - especially any relevant code and traceback messages. Use the code tag to format scripts.
Post Reply
Message
Author
ArizaLuca
Veteran
Posts: 241
Joined: Tue Feb 20, 2018 12:59 pm
Completed: Through the Screen, Riddle Me This, Trust Fall, Phobias, Another Adventure
Projects: The Souls in the Seams, Fata Morgana, Minecraft: Story Mode - Behind the Scenes
Organization: Astral Autumn Games
Tumblr: astralautumngames
Deviantart: ArizaLuca
itch: astralautumngames
Contact:

Script Won't Start The Way I Want To {SOLVED}

#1 Post by ArizaLuca »

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?
Last edited by ArizaLuca on Sun Sep 23, 2018 8:31 am, edited 1 time in total.

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Script Won't Start The Way I Want To

#2 Post by Kia »

once the first condition is true the rest of conditions are not checked, you can flip your variables and check from the least likely to change to the most likely

ArizaLuca
Veteran
Posts: 241
Joined: Tue Feb 20, 2018 12:59 pm
Completed: Through the Screen, Riddle Me This, Trust Fall, Phobias, Another Adventure
Projects: The Souls in the Seams, Fata Morgana, Minecraft: Story Mode - Behind the Scenes
Organization: Astral Autumn Games
Tumblr: astralautumngames
Deviantart: ArizaLuca
itch: astralautumngames
Contact:

Re: Script Won't Start The Way I Want To

#3 Post by ArizaLuca »

This results in the same thing; I have also marked the persistent as true once it hits that route.

User avatar
Kia
Eileen-Class Veteran
Posts: 1040
Joined: Fri Aug 01, 2014 7:49 am
Deviantart: KiaAzad
Discord: Kia#6810
Contact:

Re: Script Won't Start The Way I Want To

#4 Post by Kia »

you need to map out your conditions. when you have two conditions you have four possibility:

Code: Select all

a=False b=False
a=True b=False
a=False b=True
a=True b=True
with a simple if like:

Code: Select all

if a:
    jump a
elif b:
    jump b
you're going to get different result with each condition

Code: Select all

a=False b=False = jump nothing
a=True b=False = jump a
a=False b=True = jump b
a=True b=True = jump a
as you can see once a is true b won't be checked anymore, you need to plan for that and check conditions according to the possibilities.

Code: Select all

if a and not b:
    jump a
elif a and b:
    jump b

User avatar
xavimat
Eileen-Class Veteran
Posts: 1461
Joined: Sat Feb 25, 2012 8:45 pm
Completed: Yeshua, Jesus Life, Cops&Robbers
Projects: Fear&Love
Organization: Pilgrim Creations
Github: xavi-mat
itch: pilgrimcreations
Location: Spain
Discord: xavimat
Contact:

Re: Script Won't Start The Way I Want To

#5 Post by xavimat »

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:

Code: Select all

$ persistent.myvar = 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.
Comunidad Ren'Py en español: ¡Únete a nuestro Discord!
Rhaier Kingdom A Ren'Py Multiplayer Adventure Visual Novel.
Cops&Robbers A two-player experiment | Fear&Love Why can't we say I love you?
Honest Critique (Avatar made with Chibi Maker by ~gen8)

ArizaLuca
Veteran
Posts: 241
Joined: Tue Feb 20, 2018 12:59 pm
Completed: Through the Screen, Riddle Me This, Trust Fall, Phobias, Another Adventure
Projects: The Souls in the Seams, Fata Morgana, Minecraft: Story Mode - Behind the Scenes
Organization: Astral Autumn Games
Tumblr: astralautumngames
Deviantart: ArizaLuca
itch: astralautumngames
Contact:

Re: Script Won't Start The Way I Want To

#6 Post by ArizaLuca »

The order I'm trying to go in is "Social anxiety, self esteem, stress, what are you doing here, and normal".

ArizaLuca
Veteran
Posts: 241
Joined: Tue Feb 20, 2018 12:59 pm
Completed: Through the Screen, Riddle Me This, Trust Fall, Phobias, Another Adventure
Projects: The Souls in the Seams, Fata Morgana, Minecraft: Story Mode - Behind the Scenes
Organization: Astral Autumn Games
Tumblr: astralautumngames
Deviantart: ArizaLuca
itch: astralautumngames
Contact:

Re: Script Won't Start The Way I Want To

#7 Post by ArizaLuca »

Code: Select all

label start:
    
    if persistent.sa:
        jump socialanxiety
    if persistent.se:
        jump selfesteem
    if persistent.s:
        jump stress
    if persistent.whatareyoudoinghere:
        jump whatareyoudoinghere
    if persistent.normal:
        jump normal
The code now looks like this; it STILL will not jump to the new point in the script. Every time it starts it is at the socialanxiety tag.

User avatar
Scribbles
Miko-Class Veteran
Posts: 636
Joined: Wed Sep 21, 2016 4:15 pm
Completed: Pinewood Island, As We Know It
Projects: In Blood
Organization: Jaime Scribbles Games
Deviantart: breakfastdoodles
itch: scribbles
Location: Ohio
Contact:

Re: Script Won't Start The Way I Want To

#8 Post by Scribbles »

I'm not an expert by any means, but think of it like the code goes line by line and executes. So in the above example while persistent.sa is true it will ALWAYS jump socialanxiety and continue to skip all of the other if statements. You might need to find another way to configure that code all together.

Code: Select all

 $ persistent.route == "socialanxiety"

label start:
    if persistent.route == "socialanxiety":
        jump socialanxiety
        ## Then change the persistent variable to the next route that you want within the socialanxiety lable
    if persistent.route == "selfesteem":
        jump selfesteem
    ## an so on

label socialanxiety:
    "STUFF GOES HERE"
    $ persistent.route == "selfesteem"
    return

maybe try something like that? It does mean that the persistent.route variable will always be changing, so I'm not sure how effective it would be but it couldn't hurt to give it a go
Image - Image -Image

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Script Won't Start The Way I Want To

#9 Post by Imperf3kt »

ArizaLuca wrote: Sat Sep 22, 2018 8:02 pm

Code: Select all

label start:
    
    if persistent.sa:
        jump socialanxiety
    if persistent.se:
        jump selfesteem
    if persistent.s:
        jump stress
    if persistent.whatareyoudoinghere:
        jump whatareyoudoinghere
    if persistent.normal:
        jump normal
The code now looks like this; it STILL will not jump to the new point in the script. Every time it starts it is at the socialanxiety tag.
I believe kia gave you a very good suggestion, but you don't appear to have used it.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

ArizaLuca
Veteran
Posts: 241
Joined: Tue Feb 20, 2018 12:59 pm
Completed: Through the Screen, Riddle Me This, Trust Fall, Phobias, Another Adventure
Projects: The Souls in the Seams, Fata Morgana, Minecraft: Story Mode - Behind the Scenes
Organization: Astral Autumn Games
Tumblr: astralautumngames
Deviantart: ArizaLuca
itch: astralautumngames
Contact:

Re: Script Won't Start The Way I Want To

#10 Post by ArizaLuca »

Imperf3kt wrote: Sun Sep 23, 2018 5:16 am
ArizaLuca wrote: Sat Sep 22, 2018 8:02 pm

Code: Select all

label start:
    
    if persistent.sa:
        jump socialanxiety
    if persistent.se:
        jump selfesteem
    if persistent.s:
        jump stress
    if persistent.whatareyoudoinghere:
        jump whatareyoudoinghere
    if persistent.normal:
        jump normal
The code now looks like this; it STILL will not jump to the new point in the script. Every time it starts it is at the socialanxiety tag.
I believe kia gave you a very good suggestion, but you don't appear to have used it.
I did change it so that it was flipped, but this was after receiving a different suggestion.

ArizaLuca
Veteran
Posts: 241
Joined: Tue Feb 20, 2018 12:59 pm
Completed: Through the Screen, Riddle Me This, Trust Fall, Phobias, Another Adventure
Projects: The Souls in the Seams, Fata Morgana, Minecraft: Story Mode - Behind the Scenes
Organization: Astral Autumn Games
Tumblr: astralautumngames
Deviantart: ArizaLuca
itch: astralautumngames
Contact:

Re: Script Won't Start The Way I Want To

#11 Post by ArizaLuca »

Scribbles wrote: Sat Sep 22, 2018 8:48 pm I'm not an expert by any means, but think of it like the code goes line by line and executes. So in the above example while persistent.sa is true it will ALWAYS jump socialanxiety and continue to skip all of the other if statements. You might need to find another way to configure that code all together.

Code: Select all

 $ persistent.route == "socialanxiety"

label start:
    if persistent.route == "socialanxiety":
        jump socialanxiety
        ## Then change the persistent variable to the next route that you want within the socialanxiety lable
    if persistent.route == "selfesteem":
        jump selfesteem
    ## an so on

label socialanxiety:
    "STUFF GOES HERE"
    $ persistent.route == "selfesteem"
    return

maybe try something like that? It does mean that the persistent.route variable will always be changing, so I'm not sure how effective it would be but it couldn't hurt to give it a go
Thank you so much, it finally worked!

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3791
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Script Won't Start The Way I Want To {SOLVED}

#12 Post by Imperf3kt »

I meant the if a not b thing.

The suggestion you're using now works fine until you try to load an old save file
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]