[SOLVED] SetVariable in imagebutton

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
Jezzy
Regular
Posts: 30
Joined: Wed Jun 21, 2017 2:18 pm
Contact:

[SOLVED] SetVariable in imagebutton

#1 Post by Jezzy » Thu Jul 27, 2017 8:52 am

Hello!

I am trying to set the value of a class object variable into an image button but its not working.

Code: Select all

SetVariable("myClass.variable", True)

Code: Select all

imagebutton auto "gui/mybutton_%s.png" action [ SetVariable("myClass.variable", True), Play ("sound", "sfx/email sfx.ogg")] hovered [ Play ("sound", "sfx/click.wav") ] xpos int(x+500) ypos int(y+60)
This return :

Code: Select all

AttributeError: 'StoreModule' object has no attribute 'myClass.variable'
However, if I do this into my screen :

Code: Select all

text "{=jobs_listing}{font=DejaVuSans.ttf}[myClass.variable]" xpos x ypos int(y+80) xmaximum 600
I clearly see False on my screen.

So my question is, is it even possible to set the value of a class object variable throught SetVariable into a imagebutton action?

Thank you ^.^
Last edited by Jezzy on Thu Jul 27, 2017 9:17 am, edited 1 time in total.

User avatar
Natalie
Newbie
Posts: 17
Joined: Thu Jun 16, 2016 10:50 pm
Projects: Serment - Contract with a Devil
Contact:

Re: SetVariable in imagebutton

#2 Post by Natalie » Thu Jul 27, 2017 9:09 am

Use SetField instead.

Code: Select all

SetField(myClass, "variable", True)
Image
Follow Serment (JRPG dungeon crawler/Visual Novel hybrid) on Steam!

Jezzy
Regular
Posts: 30
Joined: Wed Jun 21, 2017 2:18 pm
Contact:

Re: SetVariable in imagebutton

#3 Post by Jezzy » Thu Jul 27, 2017 9:15 am

Thank you a lot Natalie! It works!

Post Reply

Who is online

Users browsing this forum: Google [Bot]