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.
Hi,
I am displaying reaction choices to the player via textbuttons.
But how can I tell which textbutton was pressed?
The number of choices can vary btw, depending on the topic.
Searched around for this but couldn't find an answer.
Any help (beyond just a docu URL) would be appreciated.
screen textbutton_screen(mytextbuttons):
vbox:
for n, button in enumerate(mytextbuttons):
textbutton button:
action Return(n)
$ myInput = ["Should I come along this time?","I think I better leave!", "I guess.."]
call screen textbutton_screen(myInput)
if _result == 0:
"Should I come along this time? button was pressed"
elif _result == 1:
"I think I better leave! button was pressed"
else:
"I guess.. button was pressed"
I have added this code, but I'm getting an error when I run it.
I'm assuming that everything starting at: $ myInput = ["Should I come...
goes into the script file.
Does _result need to be declared in there?
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 94, in script
if _result == 0:
File "game/script.rpy", line 94, in <module>
if _result == 0:
NameError: name '_result' is not defined
Google search: "renpy thisismyquestion -org"
This gives you everything - except renpy.org results. Which I find useless 90% of the time.
Sigh. I cannot remember proper name for that variable. Replace all instances of _result with _return. You do not need to define it, RenPy does this automatically and places in it results of RenPy call statements.