Is there a way to make a textbutton (or image button, whichever) change a variable directly? Right now, I have it jumping to a label, where the variable is changed, and then you're returned to the screen to make another selection.
This just seems cumbersome. If it's the way it has to be done, so be it, I was just hoping for a more elegant solution.
Textbutton change variable?
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.
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.
- SuperbowserX
- Veteran
- Posts: 270
- Joined: Sat Jan 07, 2017 3:09 pm
- Contact:
Re: Textbutton change variable?
Use the SetVariable action.
Code: Select all
$ thing = 0
textbutton _("Set to 1") action SetVariable("thing", 1)
Re: Textbutton change variable?
This doesn't seem to work with persistent variables, though? I keep getting:
When I make them non-persistent variables, it works absolutely perfect.
Code: Select all
I'm sorry, but an uncaught exception occurred.
While running game code:
File "renpy/common/00action_data.rpy", line 50, in get_selected
return getattr(self.object, self.field) == self.value
AttributeError: 'StoreModule' object has no attribute 'persistent.body'
-- Full Traceback ------------------------------------------------------------
Full traceback:
File "renpy/common/_layout/screen_main_menu.rpym", line 28, in script
python hide:
File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\ast.py", line 814, in execute
renpy.python.py_exec_bytecode(self.code.bytecode, self.hide, store=self.store)
File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\python.py", line 1719, in py_exec_bytecode
exec bytecode in globals, locals
File "renpy/common/_layout/screen_main_menu.rpym", line 30, in <module>
ui.interact()
File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\ui.py", line 285, in interact
rv = renpy.game.interface.interact(roll_forward=roll_forward, **kwargs)
File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\core.py", line 2526, in interact
repeat, rv = self.interact_core(preloads=preloads, trans_pause=trans_pause, **kwargs)
File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\core.py", line 2793, in interact_core
root_widget.visit_all(lambda i : i.per_interact())
File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\core.py", line 495, in visit_all
d.visit_all(callback)
File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\core.py", line 495, in visit_all
d.visit_all(callback)
File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\core.py", line 495, in visit_all
d.visit_all(callback)
File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\screen.py", line 403, in visit_all
self.child.visit_all(callback)
File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\core.py", line 495, in visit_all
d.visit_all(callback)
File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\core.py", line 495, in visit_all
d.visit_all(callback)
File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\core.py", line 497, in visit_all
callback(self)
File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\core.py", line 2793, in <lambda>
root_widget.visit_all(lambda i : i.per_interact())
File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\behavior.py", line 788, in per_interact
if self.is_selected():
File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\behavior.py", line 778, in is_selected
return is_selected(self.action)
File "D:\RenPy\renpy-6.99.12.4-sdk\renpy\display\behavior.py", line 359, in is_selected
return action.get_selected()
File "renpy/common/00action_data.rpy", line 50, in get_selected
return getattr(self.object, self.field) == self.value
AttributeError: 'StoreModule' object has no attribute 'persistent.body'
Windows-8-6.2.9200
Ren'Py 6.99.12.4.2187
dress up 1.0
Re: Textbutton change variable?
Okay, I got it.
Thank you!
Code: Select all
textbutton _("choice") action SetField(persistent, "variable", "value")
Who is online
Users browsing this forum: Google [Bot], Syrale