[Solved] Flagged choices/variables not working as intended/properly

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
User avatar
SpicyMayo1429
Regular
Posts: 36
Joined: Tue Mar 20, 2018 11:23 am
Contact:

[Solved] Flagged choices/variables not working as intended/properly

#1 Post by SpicyMayo1429 » Thu May 09, 2019 12:15 am

I've been at it for hours trying to figure out what had to be fixed but I feel like I'm not getting anywhere... So in my game, there is a recurring menu that happens where you pick between three choices (check the news, check a computer, or continue along). Two of the three choices will have a notification pop-up (as you will have unlocked a definition in a page similar to a tips page.) What I'm trying to do is have it so if you have selected a choice and received that specific notification before you won't see it again.

Here's code for the first menu thus far (as each one is similar but different and leads to different events), eventually they'll be changed to image maps (extra notation is in the ####):

Code: Select all

 ## This is the first threewaychoice we come across.
    ## In here you'll have the option of checking the 'infoboard', 'terminal', or just continuing along with the story.
    ## It will be represented with an imagemap.
    
    menu:
        "Check Infoboard":		#### You will check the news.
            $ News_Junky += 1		#### This basically counts how many time you will have selected this choice.
            $ ThreeWayChoice += 1	#### This counts overall how many of the 3 way choices we come across.
            jump TWC_info_1
        "Continue along":		#### You will continue with the story.
            $ ThreeWayChoice += 1	#### This counts overall how many of the 3 way choices we come across.
            jump TWC_stay_1
        "Check a terminal":		#### You will check a computer
            $ Terminal_Check += 1	#### This basically counts how many time you will have selected this choice.
            $ ThreeWayChoice += 1	#### This counts overall how many of the 3 way choices we come across.
            jump TWC_term_1


label TWC_info_1:
    
    $ renpy.notify('{color=#ff0000}Keypoint unlocked{/color}: Infoboard')		#### This is the notification that appears on screen.
    ## Unlock Keypoint 3: Infoboard
    $ persistent.unlock_tip_3 = True							#### This is what will unlock the tip.
    $ Keypoint3_unlock = "yes"								#### This is the flag that should remember we saw the notification.
    
    "Along his way home, Scott saw one of the bigger {color=#ff0000}Infoboards{/color}."
    
    #$ renpy.notify('{color=#ff0000}Keypoint unlocked{/color}: Chem Children')	#### As soon as I figure out where in the tips list this'll be placed, it'll be unhashed.
    ## Unlock Keypoint 25: Chem Children
    #$ persistent.unlock_tip_25 = True						#### As soon as I figure out where in the tips list this'll be placed, it'll be unhashed.
    #$ Keypoint25_unlock = "yes"						#### As soon as I figure out where in the tips list this'll be placed, it'll be unhashed.
    
    "It flashed to an advertisement for \'{color=#ff0000}Chem Children{/color}\'"
    
    ## An image showing the Infoboard will show here.
    ## A caption might follow it.
    
    jump section1_cont
    
label TWC_term_1:
    
    $ renpy.notify('{color=#ff0000}Keypoint unlocked{/color}: Terminals')		#### This is the notification that appears on screen.
    ## Unlock Keypoint 6: Terminal
    $ persistent.unlock_tip_6 = True							#### This is what will unlock the tip.
    $ Keypoint6_unlock = "yes"								#### This is the flag that should remember we saw the notification.
    
    "Along his way home, Scott stopped to check a nearby {color=#ff0000}terminal{/color}."
    "He pulled out a card from his wallet and scanned it."
    "He inputted any necessary credentials it asked for."
    
    sc "Okay... Let's see here..."
    
    "He pressed a few things on the screen to see how much money was sitting in his account."
    
    sc "I've gotten paid recently..."
    
    ## An image showing the terminal will show here
    ## It will go through Scott signing in and seeing his paycheck.
    
    jump section1_cont
    
label TWC_stay_1:
    
    "Scott decided it was best for him to go home, so that's where he went."
Now my issue is that when coming across the second 3 way choice, it'll either show the incorrect notification, incorrect choice dialogue, or both depending on what you picked prior to.

If you check the infobard first:
  • Infoboard 2nd time will be correct and follow through correctly.
  • Continuing along will follow correctly.
  • Checking the terminal will show the notification but will go through with the "continue along" choice.
If you check the terminal first:
  • Choosing the infoboard will show the right notification but will go through with the "check terminal" choice.
  • Continuing along will follow through properly.
  • Checking the terminal a second time will be correct and follow through also.
If you continued along without checking anything first:
  • Choosing the infoboard next will show the notification for terminals and go through with the "continue along" choice.
  • Continuing without checking anything again will be fine.
  • Choosing terminal will show the proper notification but will also go through with the continue along choice.
...

Here's the code for the second time we run across the choices (again, extra notation is in the ####):

Code: Select all

## Here is the second threewaychoice.
    ## Again, represented with an imagemap.
    
    menu:
        "Check Infoboard":		#### You will check the news.	
            $ News_Junky += 1		#### This basically counts how many time you will have selected this choice.
            $ ThreeWayChoice += 1	#### This counts overall how many of the 3 way choices we come across.
            jump TWC_info_2
        "Continue along":		#### You will continue with the story.
            $ ThreeWayChoice += 1	#### This counts overall how many of the 3 way choices we come across.
            jump TWC_stay_2
        "Check a terminal":		#### You will check a computer.
            $ Terminal_Check += 1	#### This basically counts how many time you will have selected this choice.
            $ ThreeWayChoice += 1	#### This counts overall how many of the 3 way choices we come across.
            jump TWC_term_2
    
    
label TWC_info_2:
    
if Keypoint3_unlock == "no":								#### If we didn't choose this option before  this should play out so that we will see the notification.
    $ renpy.notify('{color=#ff0000}Keypoint unlocked{/color}: Infoboard')		#### This is the notification that appears on screen.
    ## Unlock Keypoint 3: Infoboard
    $ persistent.unlock_tip_3 = True							#### This is what will unlock the tip.
    $ Keypoint3_unlock = "yes"								#### This is the flag that should remember we saw the notification.
    
else:											#### If we did choose this option before, it should skip showing the notification and continue with the choice made.
        
    "Scott found a nearby {color=#ff0000}Infobaord{/color} to brief the news."
    "It stated that a few terminals well be closed for maintenance."
        
    ## An image showing the Infoboard will show here.
    ## A caption might follow it.
        
    jump section2_cont
    
label TWC_term_2:
    
if Keypoint6_unlock == "no":								#### If we didn't choose this option before  this should play out so that we will see the notification.
    $ renpy.notify('{color=#ff0000}Keypoint unlocked{/color}: Terminals')		#### This is the notification that appears on screen.
    ## Unlock Keypoint 6: Terminal
    $ persistent.unlock_tip_6 = True							#### This is what will unlock the tip.
    $ Keypoint6_unlock = "yes"								#### This is the flag that should remember we saw the notification.
    
else:											#### If we did choose this option before, it should skip showing the notification and continue with the choice made.
        
    "Scott found a {color=#ff0000}terminal{/color} so he could check his account."
    "He pulled out a card from his wallet and scanned it."
    "He inputted any necessary credentials it asked for."

    sc "Okay... Let's see here..."
    
    "He pressed a few things on the screen and transferred some of his money into another one of his accounts."
        
    jump section2_cont
    
label TWC_stay_2:
    
    "Scott contemplated on the idea of going to Erotica."
I've defined the the flags/variables prior to my script like so:

Code: Select all

## Defaulted In Game Variables ##
default Scott_Moral_Negative = 0
default ThreeWayChoice = 0
default News_Junky = 0
default Terminal_Check = 0

## Defined Variables ##

define Keypoint3_unlock = "no"
define Keypoint6_unlock = "no"
define Scott_responce_1 = "calm"


###########################
## The game starts here. ##
###########################
label start:
Such a long post, apologies. Any pointers are appreciated. If you have any other questions or need more info, feel free to ask.
Last edited by SpicyMayo1429 on Thu May 09, 2019 8:52 am, edited 1 time in total.

User avatar
Saa
Regular
Posts: 32
Joined: Tue Aug 20, 2013 7:11 pm
Tumblr: nipahgirl
Contact:

Re: flagged choices/variables not working as intended/properly

#2 Post by Saa » Thu May 09, 2019 7:51 am

Two things:

1 - you forgot the indentation on the ifs and elses of TWC_term_2 and TWC_info_2

2 - you forgot to jump to section2_cont at the end of your if blocks.

So it should be like:

Code: Select all

## Here is the second threewaychoice.
    ## Again, represented with an imagemap.
    
    menu:
        "Check Infoboard":        #### You will check the news.    
            $ News_Junky += 1        #### This basically counts how many time you will have selected this choice.
            $ ThreeWayChoice += 1    #### This counts overall how many of the 3 way choices we come across.
            jump TWC_info_2
        "Continue along":        #### You will continue with the story.
            $ ThreeWayChoice += 1    #### This counts overall how many of the 3 way choices we come across.
            jump TWC_stay_2
        "Check a terminal":        #### You will check a computer.
            $ Terminal_Check += 1    #### This basically counts how many time you will have selected this choice.
            $ ThreeWayChoice += 1    #### This counts overall how many of the 3 way choices we come across.
            jump TWC_term_2
    
    
label TWC_info_2:
    
    if Keypoint3_unlock == "no":                                #### If we didn't choose this option before  this should play out so that we will see the notification.
        $ renpy.notify('{color=#ff0000}Keypoint unlocked{/color}: Infoboard')        #### This is the notification that appears on screen.
        ## Unlock Keypoint 3: Infoboard
        $ persistent.unlock_tip_3 = True                            #### This is what will unlock the tip.
        $ Keypoint3_unlock = "yes"                                #### This is the flag that should remember we saw the notification.
        jump section2_cont
        
    else:                                            #### If we did choose this option before, it should skip showing the notification and continue with the choice made.
            
        "Scott found a nearby {color=#ff0000}Infobaord{/color} to brief the news."
        "It stated that a few terminals well be closed for maintenance."
            
        ## An image showing the Infoboard will show here.
        ## A caption might follow it.
            
        jump section2_cont
    
label TWC_term_2:
    
    if Keypoint6_unlock == "no":                                #### If we didn't choose this option before  this should play out so that we will see the notification.
        $ renpy.notify('{color=#ff0000}Keypoint unlocked{/color}: Terminals')        #### This is the notification that appears on screen.
        ## Unlock Keypoint 6: Terminal
        $ persistent.unlock_tip_6 = True                            #### This is what will unlock the tip.
        $ Keypoint6_unlock = "yes"                                #### This is the flag that should remember we saw the notification.
        jump section2_cont
        
    else:                                            #### If we did choose this option before, it should skip showing the notification and continue with the choice made.
            
        "Scott found a {color=#ff0000}terminal{/color} so he could check his account."
        "He pulled out a card from his wallet and scanned it."
        "He inputted any necessary credentials it asked for."

        sc "Okay... Let's see here..."
        
        "He pressed a few things on the screen and transferred some of his money into another one of his accounts."
            
        jump section2_cont
    
label TWC_stay_2:
    
    "Scott contemplated on the idea of going to Erotica."

User avatar
SpicyMayo1429
Regular
Posts: 36
Joined: Tue Mar 20, 2018 11:23 am
Contact:

Re: flagged choices/variables not working as intended/properly

#3 Post by SpicyMayo1429 » Thu May 09, 2019 8:37 am

Saa wrote:
Thu May 09, 2019 7:51 am


2 - you forgot to jump to section2_cont at the end of your if blocks.
The thing with the jumping at the end of the blocks is that I still need it to go though with the rest of the choice and not just jumping and skipping the rest after seeing the notification:

Code: Select all

    menu:
        "Check Infoboard":        ## You will check the news.    
            $ News_Junky += 1        ## This basically counts how many time you will have selected this choice.
            $ ThreeWayChoice += 1    ## This counts overall how many of the 3 way choices we come across.
            jump TWC_info_2
        "Continue along":        ## You will continue with the story.
            $ ThreeWayChoice += 1    ## This counts overall how many of the 3 way choices we come across.
            jump TWC_stay_2
        "Check a terminal":        ## You will check a computer.
            $ Terminal_Check += 1    ## This basically counts how many time you will have selected this choice.
            $ ThreeWayChoice += 1    ## This counts overall how many of the 3 way choices we come across.
            jump TWC_term_2
    
    
label TWC_info_2:
    
    if Keypoint3_unlock == "no":                                ## If we didn't choose this option before  this should play out so that we will see the notification.
        $ renpy.notify('{color=#ff0000}Keypoint unlocked{/color}: Infoboard')        ## This is the notification that appears on screen.
        ## Unlock Keypoint 3: Infoboard
        $ persistent.unlock_tip_3 = True                            ## This is what will unlock the tip.
        $ Keypoint3_unlock = "yes"                                ## This is the flag that should remember we saw the notification.
        jump section2_cont
        
    else:       #### If we did choose this option before, it should skip showing the notification and continue with the choice made. 
    		#### However if we haven't picked this choice it still has to carry through with the rest within the else.
            
        "Scott found a nearby {color=#ff0000}Infobaord{/color} to brief the news."
        "It stated that a few terminals well be closed for maintenance."
            
        ## An image showing the Infoboard will show here.
        ## A caption might follow it.
            
        jump section2_cont
    
label TWC_term_2:
    
    if Keypoint6_unlock == "no":                                ## If we didn't choose this option before  this should play out so that we will see the notification.
        $ renpy.notify('{color=#ff0000}Keypoint unlocked{/color}: Terminals')        ## This is the notification that appears on screen.
        ## Unlock Keypoint 6: Terminal
        $ persistent.unlock_tip_6 = True                            ## This is what will unlock the tip.
        $ Keypoint6_unlock = "yes"                                ## This is the flag that should remember we saw the notification.
        jump section2_cont
        
    else:       #### If we did choose this option before, it should skip showing the notification and continue with the choice made. 
    		#### However if we haven't picked this choice it still has to carry through with the rest within the else.
            
        "Scott found a {color=#ff0000}terminal{/color} so he could check his account."
        "He pulled out a card from his wallet and scanned it."
        "He inputted any necessary credentials it asked for."

        sc "Okay... Let's see here..."
        
        "He pressed a few things on the screen and transferred some of his money into another one of his accounts."
            
        jump section2_cont
    
label TWC_stay_2:
    
    "Scott contemplated on the idea of going to Erotica."
also is it important that my if else and elif statement are indented? I wouldn't have thought it was a significant deal because there where time where I've had them work perfectly without them being indented...

User avatar
Saa
Regular
Posts: 32
Joined: Tue Aug 20, 2013 7:11 pm
Tumblr: nipahgirl
Contact:

Re: flagged choices/variables not working as intended/properly

#4 Post by Saa » Thu May 09, 2019 8:42 am

If you need it to go to the "Scott found a (...)" text, don't use the "else", because the game only does what's in the "else" if it didn't meet the conditions for the "if". Instead, just don't have an "else" at all:

Code: Select all

If you need it to go to the "Scott found a (...)" text, don't use the "else", because the game only does what's in the "else" if it didn't meet the conditions for the "if". Instead, just don't have an "else" at all:
[code]    menu:
        "Check Infoboard":        ## You will check the news.    
            $ News_Junky += 1        ## This basically counts how many time you will have selected this choice.
            $ ThreeWayChoice += 1    ## This counts overall how many of the 3 way choices we come across.
            jump TWC_info_2
        "Continue along":        ## You will continue with the story.
            $ ThreeWayChoice += 1    ## This counts overall how many of the 3 way choices we come across.
            jump TWC_stay_2
        "Check a terminal":        ## You will check a computer.
            $ Terminal_Check += 1    ## This basically counts how many time you will have selected this choice.
            $ ThreeWayChoice += 1    ## This counts overall how many of the 3 way choices we come across.
            jump TWC_term_2
    
    
label TWC_info_2:
    
    if Keypoint3_unlock == "no":                                ## If we didn't choose this option before  this should play out so that we will see the notification.
        $ renpy.notify('{color=#ff0000}Keypoint unlocked{/color}: Infoboard')        ## This is the notification that appears on screen.
        ## Unlock Keypoint 3: Infoboard
        $ persistent.unlock_tip_3 = True                            ## This is what will unlock the tip.
        $ Keypoint3_unlock = "yes"                                ## This is the flag that should remember we saw the notification.
        jump section2_cont
        
           #### If we did choose this option before, it should skip showing the notification and continue with the choice made. 
    		#### However if we haven't picked this choice it still has to carry through with the rest within the else.
            
    "Scott found a nearby {color=#ff0000}Infobaord{/color} to brief the news."
    "It stated that a few terminals well be closed for maintenance."
        
    ## An image showing the Infoboard will show here.
    ## A caption might follow it.
        
    jump section2_cont
    
label TWC_term_2:
    
    if Keypoint6_unlock == "no":                                ## If we didn't choose this option before  this should play out so that we will see the notification.
        $ renpy.notify('{color=#ff0000}Keypoint unlocked{/color}: Terminals')        ## This is the notification that appears on screen.
        ## Unlock Keypoint 6: Terminal
        $ persistent.unlock_tip_6 = True                            ## This is what will unlock the tip.
        $ Keypoint6_unlock = "yes"                                ## This is the flag that should remember we saw the notification.
        jump section2_cont
        
            #### If we did choose this option before, it should skip showing the notification and continue with the choice made. 
    		#### However if we haven't picked this choice it still has to carry through with the rest within the else.
            
    "Scott found a {color=#ff0000}terminal{/color} so he could check his account."
    "He pulled out a card from his wallet and scanned it."
    "He inputted any necessary credentials it asked for."

    sc "Okay... Let's see here..."
    
    "He pressed a few things on the screen and transferred some of his money into another one of his accounts."
        
    jump section2_cont
    
label TWC_stay_2:
    
    "Scott contemplated on the idea of going to Erotica."

User avatar
SpicyMayo1429
Regular
Posts: 36
Joined: Tue Mar 20, 2018 11:23 am
Contact:

Re: flagged choices/variables not working as intended/properly

#5 Post by SpicyMayo1429 » Thu May 09, 2019 8:51 am

Saa wrote:
Thu May 09, 2019 8:42 am
If you need it to go to the "Scott found a (...)" text, don't use the "else", because the game only does what's in the "else" if it didn't meet the conditions for the "if". Instead, just don't have an "else" at all:
OMG IT WORKED! IT WORKS PROPERLY!!! :D THANKS SO MUCH! (finally I can rest easy.)

Post Reply

Who is online

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