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.
label testFunction(val):
if val = "one":
return("hello")
else:
return("okay")
screen test:
vbox:
# should get set to a value of string "okay"
$ globalVariable = testFunction("two")
init python:
def testFunction(val):
if val = "one":
return "hello"
else:
return "okay"
screen test:
vbox:
# should get set to a value of string "okay"
$ globalVariable = testFunction("two")
A label as control flow like that would likely be ran using renpy.run( renpy.call( "label" ) ) or through an Action of a button using Call( "label" )
Okay, I switched to python function, but the string value returned from the function always results in the name of the function, not the actual return value. Do you know why it's doing that?
Instead of returning "wtf", it returns the name of the function: