Code: Select all
renpy.ui.imagebutton(auto="test_images/Item_%s.png", xcenter=640, ycenter=400)
Code: Select all
renpy.ui.imagebutton(auto="test_images/Item_%s.png", xcenter=640, ycenter=400, action=SetVariable(chosen, 3))
Here is the entirety of my script.rpy and traceback.txt (I pared it down from a much larger project but it still has the same error).
How do I use renpy.ui.imagebutton()? Everything I can find is on declaring the button from a ren'py script (not a Python function), which isn't what I'm trying to do here. I searched for usages of the imagebutton() function in the example projects and a few others but it's impossible to figure out what's going on in there due to Python's moronic typing.
(I'm also interested in how to block interaction with anything behind the button(s), which I could do if I had a Screen, but again I want to set all this up in a Python function and I can't find anything on using ren'py Screens from Python)
[EDIT] I think I can actually do what I want with a Screen, but I'm still curious about what the ImageButton is doing here.
[EDIT2] Pretty sure I solved it. The variable can't be defined in the function or the ren'py script - it has to have a more global scope than that. I put it in an "init python" block with some other vars and it works now. I'm still not sure what kind of scope SetVariable has exactly.