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 there, I have a label and a screen with a button. When the button is pressed I call a function which checks for something and if that is True then it should return back in the label.
label test:
"something goes here"
call screen test_screen()
"I want to be back here"
screen test_screen():
imagebutton:
auto "path_to_url"
action Function(testFunc)
init python:
def testFunc():
if something:
# what should I do here to leave the screen and go back where I left.
# I could do renpy.jump("test") but that will go back to "something goes here"
# while in my case I would like to have something similar to action Return() which
# would have return me to "I want to be back here"
else :
#something else
init python:
def myReturn(): return True # return any value other than None to end the interaction.
screen test():
texbutton "Return" action Function(myReturn)
label start:
call screen test
"Continuation... Return value is [_return]"
init python:
def testFunc():
if some_success_condition:
return "success"
## returning a NOT None value is the same as Return() ... even return False or return 0 will be ok
else:
# returning None will keep the called screen there as though nothing had happened
return None
The value returned incidentally can be later displayed or checked in the global _return variable's value
label test:
"something goes here"
call screen test_screen()
label .something:
"I want to be back here"
screen test_screen():
imagebutton:
idle "P1.jpg"
action Function(testFunc)
init python:
def testFunc():
if something:
renpy.jump("test.something")
else:
pass
Because this is a minigame that can start from different situations in the game.
I have a scene in which people come to my coffeeshop and ask for a coffee. Then I call my screen and then when I'm done preparing the coffee I should return back to the person giving, however the problem with more labels is the fact that I will then have to create a label for each situation and each customer. While if I can return where I left it solves plenty of writing.
hell_oh_world wrote: ↑Wed Nov 25, 2020 3:08 pm
If the function in the Function action returns value other than None, then it will end the interaction and return that value.
init python:
def myReturn(): return True # return any value other than None to end the interaction.
screen test():
texbutton "Return" action Function(myReturn)
label start:
call screen test
"Continuation... Return value is [_return]"
Cheers. This solved my problem.
By the way. Is there a way to know what my screen returned?
Something like this:
hapciupalit wrote: ↑Thu Nov 26, 2020 10:23 am
By the way. Is there a way to know what my screen returned?
hell_oh_world already demonstrated it, but there's a built-in special variable called _return that automatically stores whatever is returned from a screen or a return statement.
hapciupalit wrote: ↑Thu Nov 26, 2020 10:23 am
By the way. Is there a way to know what my screen returned?
hell_oh_world already demonstrated it, but there's a built-in special variable called _return that automatically stores whatever is returned from a screen or a return statement.