Page 1 of 1

issue using an imagebuton to change a variable

Posted: Sun Jan 18, 2015 9:27 pm
by Luckstar
Howdy,
I'm trying to use a clickable button to change a variable from true to false

Code: Select all

$ show_stat_box=False

screen stat_button():
    imagebutton auto "ui/stat_button_%s.png" xpos 0.01 ypos 0.01 focus_mask True action SetVariable(show_stat_box=True)
This seems to actually crash ren'py and cause an error report

I've tried multiple functions like ToggleVariable, set, even had a go just trying $ show_stat_box=True

It's been a few hours, at this stage any clickable that changes a variable would be a fine solution

Re: issue using an imagebuton to change a variable

Posted: Sun Jan 18, 2015 9:52 pm
by SundownKid
Here is the correct syntax:

Code: Select all

screen stat_button():
    imagebutton auto "ui/stat_button_%s.png" action SetVariable('show_stat_box',True) xpos 0.01 ypos 0.01 focus_mask True 
If you are trying to show and hide a screen however, may I suggest:

Code: Select all

screen stat_button():
    imagebutton auto "ui/stat_button_%s.png" action Show('stat_box') xpos 0.01 ypos 0.01 focus_mask True 
(Where "stat_box" is the name of the screen?)

Re: issue using an imagebuton to change a variable

Posted: Sun Jan 18, 2015 10:02 pm
by Luckstar
Glorious, thank you!

That is crazy helpful!