Page 1 of 1

Trouble with Remembering Menu Choices

Posted: Mon Jan 18, 2016 5:24 pm
by Ruko
I wouldn't have considered asking a question here usually, as I've been thoroughly locating tutorials and what not as I'm incredibly new to this program, and just as new to programming in general.
However I am at a loss where to find help with this any more, so I thought I'd ask here.

I've erased all the irrelevant information below, but here is the jist of what's going on in my code:

Code: Select all

label start:
    $ onyuarc = False

#various script in-between here

label menu_choice:
menu:
    if onyuarc == False:
        "Talk to Onyu":
            "You decide to try talking to No Onyu. He might seem a little strange, but maybe he has some answers."
            jump choiceonyu

#various script in-between here

menu:
    "Option 1":
        y "Blah blah."
        jump choice_onyucontinue1
    
    "Option 2":
        y "Blah blah.."
        if onyu < 1:
            jump choice_onyufight        
        if onyu > 1:
           $ onyuarc = True
           jump choice_onyuend

    "Option 3?":
        o "Blah blah?"
        jump choice_onyucontinue1

label choice_onyuend:
o "I give up!"
jump menu_choice

The aim is that if the value of onyu is more than 1 then it will cycle back round to the previous menu but with the option to interact with him erased.
I've tried all manner of indentations, arrangements and now I'm just at a loss.

The script seems to work back all right, and works with the value of onyu changing, but the option in the menu isn't hidden upon the second time going round after changing onyuarc to true.

Am I missing something here?

Re: Trouble with Remembering Menu Choices

Posted: Mon Jan 18, 2016 6:03 pm
by chocojax
Have you tried this to hide the menu choice? http://renpy.org/wiki/renpy/doc/tutoria ... nu_options

Code: Select all

menu:
    "Talk to Onyu" if onyuarc == False:

Re: Trouble with Remembering Menu Choices

Posted: Tue Jan 19, 2016 6:44 am
by Ruko
I already tried that before and it didn't work, however I tried it again to test it and it is still not working.

Code: Select all

menu:
    "Talk to Onyu" if onyuarc == False:
        "You decide to try talking to No Onyu. He might seem a little strange, but maybe he has some answers."
        jump choiceonyu
The choise is still showing up, the tutorial you linked is the thing I was following.

Re: Trouble with Remembering Menu Choices

Posted: Tue Jan 19, 2016 7:10 am
by Iylae
If you're having trouble, you could build your menus dynamically using python:

See this post (2nd code block) by PyTom which is now how I use menus exclusively.

To expand, you'd have something like this:

Code: Select all

$ choices = []

$ if onyuarc == False: choice.append(("Talk to Onyu", "choiceonyu"))

$ result = renpy.display_menu(choices)

jump expression result
Note I didn't test the code above.

Re: Trouble with Remembering Menu Choices

Posted: Tue Jan 19, 2016 8:11 am
by Onishion
Ok, first, you can't put an if statement inside a menu, so the first way you wrote it should throw back an error right off the bat. If you want conditional menu options you have to write them like Chocojax said, putting it after the intended statement. If it's still showing up when using that method, then maybe onyuarc IS False? Try hitting shift-D and opening the dev menu, then the variable viewer, and see what that variable is set to while looping. One other way of writing that out is:

Code: Select all

menu:
    "Talk to Onyu" if not onyuarc:
        "You decide to try talking to No Onyu. He might seem a little strange, but maybe he has some answers."
        jump choiceonyu

"not Variable" and "Variable" are the same thing as "Variable == False" and "Variable == True".

A couple other things I'm unclear on. On the second question, you have an "if <1" and an "if >1", but what happens if it IS 1, exactly? Currently if you choose option 2 and the variable is exactly 1, then it falls through, which in that case would drop it through to "label choice_onyuend:" and beyond. This might be an intended behavior, but if not, you probably want to set one of those choices to something else. If you want it to be an "either/or" situation, then maybe set the second one to just "else." Basically:

Code: Select all

"Option 2":
        y "Blah blah.."
        if onyu < 1:
            jump choice_onyufight       
        if onyu > 1:
           $ onyuarc = True
           jump choice_onyuend
# This version will pass the first condition if less than 1, the second if greater, and fall through if exactly 1.
"Option 2":
        y "Blah blah.."
        if onyu <= 1:
            jump choice_onyufight       
        if onyu > 1:
           $ onyuarc = True
           jump choice_onyuend
# This version will pass the first one on a 1 or below, the second on anything over 1, nothing passes through.
"Option 2":
        y "Blah blah.."
        if onyu < 1:
            jump choice_onyufight       
        else:
           $ onyuarc = True
           jump choice_onyuend
# This one passes the first condition only on things less than 1, otherwise the second passes, nothing falls through.
Did this help any?

Re: Trouble with Remembering Menu Choices

Posted: Tue Jan 19, 2016 4:45 pm
by Ruko
Okay somehow it was just an error with me not using '>=' instead of '>' on it's own, as it seems to be working now. Surprised how such a small detail could seemingly effect something unrelated, but there you go.

Thank you for your help!