I Can't Figure Out How To Finish This Code

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
AllegraTown
Newbie
Posts: 13
Joined: Wed Jul 04, 2018 10:12 pm
Projects: ARTISAN
Organization: The Order Of The Frame
Contact:

I Can't Figure Out How To Finish This Code

#1 Post by AllegraTown »

Hey. I'm new to Renpy and I usually try to figure things out myself but I'm pretty stumped this time. I'm trying to create a dialogue tree that looks like this.

>Talk to Rumi
.....>Rumi question 1
.....>Rumi question 2
.....>Rumi question 3
>Talk to Cruz
.....>Cruz question 1
.....>Cruz question 2
.....>Cruz question 3
>Continue...

The tricky part is that I want the player to click on all 6 questions before being allowed to press the continue button. Here is a bit of what I've been able to figure out so far...

Code: Select all

label start:
    default Rumi_question_01 = False
    default Rumi_question_02 = False
    default Rumi_question_03 = False
    default Cruz_question_01 = False
    default Cruz_question_02 = False
    default Cruz_question_03 = False

    label choice_07_previous:
    menu:
        "Talk to Rumi":
            jump choice_07a
        "Talk to Cruz":
            jump choice_07b
        "(Continue)" if convo_07_done == False:
            jump continue_07
What I need to happen is for

Code: Select all

"(Continue)" if convo_07_done == False:
To become

Code: Select all

"(Continue)" if convo_07_done == True:
The moment all 6 defaults become

Code: Select all

default Rumi_question_01 = True
default Rumi_question_02 = True
default Rumi_question_03 = True
default Cruz_question_01 = True
default Cruz_question_02 = True
default Cruz_question_03 = True
Everything else works fine, I'm just missing this next step. There is probably a much cleaner way to do this but I'm not a good coder and I don't even know if it's possible to do lol. Any help would be really appreciated, I've been racking my brain for days. Thanks everyone.

User avatar
Alex
Lemma-Class Veteran
Posts: 3090
Joined: Fri Dec 11, 2009 5:25 pm
Contact:

Re: I Can't Figure Out How To Finish This Code

#2 Post by Alex »

AllegraTown wrote: Thu Sep 23, 2021 3:27 pm ...

Code: Select all

default Rumi_question_01 = False
This line sets the default value of variable. It shouldn't be placed inside any label (you can set all the variables at the beginning of the script file, such lines doesn't need to be indented).

Code: Select all

$ Rumi_question_01 = True
This line is used to change value of the variable in mid-game,

So, if you need your "Continue" option to be active if 'convo_07_done' is True, then try it like

Code: Select all

    menu my_named_menu:
        "Talk to Rumi":
            # you can put some code inside menu choice (if needed)
            $ Rumi_question_01 = True # change the value
            jump choice_07a
        "Talk to Cruz":
            $ Cruz_question_01 = True
            "You can jump to named menu"
            jump my_named_menu
        "(Continue)" if convo_07_done: # convo_07_done is the same as convo_07_done == True
            jump continue_07 

https://www.renpy.org/doc/html/quicksta ... -and-jumps
https://www.renpy.org/doc/html/python.html

rayminator
Miko-Class Veteran
Posts: 793
Joined: Fri Feb 09, 2018 12:05 am
Location: Canada
Contact:

Re: I Can't Figure Out How To Finish This Code

#3 Post by rayminator »

first thing to fix is the placement of your defaults put them above label start or in new page like init.rpy or default.rpy

for this to become true

Code: Select all

"(Continue)" if convo_07_done == True:
you would use and put it in the place that it needs to be

Code: Select all

$ convo_07_done = True

jeffster
Veteran
Posts: 361
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: I Can't Figure Out How To Finish This Code

#4 Post by jeffster »

Also menu choices can disappear after they were processed:

https://patreon.renpy.org/very-old-feat ... #menu-sets

Code: Select all

define menu_set = set()

menu choice_07:
    set menu_set

    "Rumi question 1":
        ...

    "Rumi question  2":
        ...

    "Rumi question  3":
        ...

    "Cruz question  1":
        ...

    "Cruz question  2":
        ...

    "Cruz question  3":
        ...

label after_choice_07:
    # If set not empty, jump back to choices:
    if menu_set:
        jump choice_07

    "Thank you guys. It's time to move on now."

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: I Can't Figure Out How To Finish This Code

#5 Post by Remix »

If you use sets the captions are added when clicked... You can test length of those sets though and conditionally show choices...

Code: Select all


default rumi_set = set()
default cruz_set = set()

label chat():
    menu chat_menu:
        "Talk to Rumi" if len(rumi_set) < 3: # Only show if chat is still available
            menu:
                set rumi_set
                "Chat 1":
                    pass
                "Chat 2":
                    pass
                "Chat 3":
                    pass
            jump chat_menu ## After each chat we jump back to main chat_menu
        "Talk to Cruz" if len(cruz_set) < 3: # Only show if chat is still available:
            menu:
                set cruz_set
                "Chat 1":
                    pass
                "Chat 2":
                    pass
                "Chat 3":
                    pass
            jump chat_menu ## After each chat we jump back to main chat_menu
    "After chatting"
    return
After doing all 6 chats we jump back and (because the menu now has no options (as both "Talk to Rumi" and "Talk to Cruz" are now removed)) we pass straight past the menu to continue
Frameworks & Scriptlets:

jeffster
Veteran
Posts: 361
Joined: Wed Feb 03, 2021 9:55 pm
Contact:

Re: I Can't Figure Out How To Finish This Code

#6 Post by jeffster »

Yes, right, I misunderstood that. Instead of

Code: Select all

if menu_set:
        jump choice_07
I should say:

Code: Select all

if len(menu_set) < 6:
        jump choice_07"
Thank you!

Post Reply

Who is online

Users browsing this forum: Google [Bot]