[Solved] Conditional menu option not working as intended

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
Chekhov
Regular
Posts: 113
Joined: Tue Jun 26, 2018 9:19 am
Projects: Pluton
Contact:

[Solved] Conditional menu option not working as intended

#1 Post by Chekhov »

Code: Select all

menu:
    "Work on creativity": 
        $ Creativity.increase(1)
    "Work on authority":
        $ Authority.increase(1)
    "Work on hacking" if [Hacking.enabled]:
        $ Hacking.increase(1)
        
"[Hacking.enabled] is the current hacking state"
When my code gets to this point, it shows the "work on hacking" option, even though at the bottom the result is "False is the current hacking state"

And it's not a string "False" either.

It's been set here:

Code: Select all

init python:
        class Skill(object):
        def __init__(self, name="Skill_naming_error", enabled = True, start = 0, maximum = 100, minimum = 0):
            self.name = name
            self.value = start
            self.max = maximum
            self.min = minimum
            self.enabled = enabled

	Creativity = Skill("creativity")
        Authority = Skill("authority")
        Hacking = Skill("hacking", False)
How can I get the menu option "Work on hacking" to properly disappear?

I think something goes wrong between renpy/python interaction?
Last edited by Chekhov on Thu Aug 16, 2018 9:13 pm, edited 1 time in total.

philat
Eileen-Class Veteran
Posts: 1910
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: Conditional menu option not working as intended

#2 Post by philat »

In the condition: just Hacking.enabled, not [Hacking.enabled].

User avatar
Chekhov
Regular
Posts: 113
Joined: Tue Jun 26, 2018 9:19 am
Projects: Pluton
Contact:

Re: [Solved] Conditional menu option not working as intended

#3 Post by Chekhov »

That fixes it. Thanks. I always have difficulty getting those details right.

philat
Eileen-Class Veteran
Posts: 1910
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: [Solved] Conditional menu option not working as intended

#4 Post by philat »

No problem. It's confusing at first. Remember brackets for interpolation are only inside ren'py strings. Outside of strings brackets mean a list.

Post Reply

Who is online

Users browsing this forum: Google [Bot], Majestic-12 [Bot]