Page 1 of 1

Using a variable inside a screen

Posted: Sun Mar 29, 2020 11:00 am
by starlingmaximilian
Hi, I'm using a variable called open which is either true or false. This variable is declared at the beginning of the code.
The variable "open" is False by default.

Code: Select all

define y = ("Yukio")
default open = False

label start:
hide screen item
scene bathroom
I then change the value to True (doing certain thing in the game) but when I want to use this variable inside a screen, I just can't.

Code: Select all

screen doorknob():
            tag item
            imagebutton:
                     xalign 0.2 yalign 0.55
                     idle "doorknob.png"
                     action If(("open" == True), true = Jump("living"), false = Jump("start"))  # Here I'm trying to use the variable "open" but the screen doesn't recognize it.

Is there a way I can call the variable "open" in which the screen would recognize it?

Re: Using a variable inside a screen

Posted: Sun Mar 29, 2020 11:13 am
by gas

Code: Select all

screen doorknob():
            tag item
            imagebutton:
                     xalign 0.2 yalign 0.55
                     idle "doorknob.png"
                     action If((open), true = Jump("living"), false = Jump("start")) 
As an extra note, you don't need to check if somethin is True. It's always True if isn't False. That's why 'if open' suffice.

Re: Using a variable inside a screen

Posted: Mon Mar 30, 2020 4:55 am
by starlingmaximilian
Thank you so much!!!
So, basically, I could just use:

Code: Select all

action If((open), true = Jump("living")
Thanks!