issue using an imagebuton to change a variable

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
Luckstar
Newbie
Posts: 3
Joined: Sun Jan 18, 2015 9:09 pm
Contact:

issue using an imagebuton to change a variable

#1 Post 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

SundownKid
Lemma-Class Veteran
Posts: 2299
Joined: Mon Feb 06, 2012 9:50 pm
Completed: Icebound, Selenon Rising Ep. 1-2
Projects: Selenon Rising Ep. 3-4
Organization: Fastermind Games
Deviantart: sundownkid
Location: NYC
Contact:

Re: issue using an imagebuton to change a variable

#2 Post 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?)

Luckstar
Newbie
Posts: 3
Joined: Sun Jan 18, 2015 9:09 pm
Contact:

Re: issue using an imagebuton to change a variable

#3 Post by Luckstar »

Glorious, thank you!

That is crazy helpful!

Post Reply

Who is online

Users browsing this forum: Bing [Bot]