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.
-
hapciupalit
- Regular
- Posts: 52
- Joined: Tue Nov 13, 2018 6:00 am
-
Contact:
#1
Post
by hapciupalit » Fri Mar 06, 2020 5:45 am
Hello guys,
I have simplified my problem in this example, but what I need right now is a way to do the Return() in a python method.
Code: Select all
label test:
"something goes here"
call test2()
"something else goes here"
label test2:
call screen test_screen()
screen test_screen():
key "K_UP" action Function(testFunction)
key "e" action Return()
init python:
testFunction():
#doing some stuffs and x becomes either True or False
if x:
#I need here a way to leave everything. something like renpy.return(), but this function doesn't exist.
# If I do renpy.jump("test") it will start everything from the beginning.
# So basically I need to call the same function as if I'd pressed 'E'
# If I just write return it will just leave the function so that won't work either
else:
#something else happen
-
rames44
- Veteran
- Posts: 232
- Joined: Sun May 29, 2016 4:38 pm
-
Contact:
#2
Post
by rames44 » Fri Mar 06, 2020 1:32 pm
Instead of using Function, try using
action If(“testFunction()”, true = Return())
If() will evaluate the first expression, in this case, a call to your function, and then choose between two actions based on whether the expression returns True or False.
-
Alex
- Lemma-Class Veteran
- Posts: 2981
- Joined: Fri Dec 11, 2009 5:25 pm
-
Contact:
#3
Post
by Alex » Fri Mar 06, 2020 1:34 pm
Try
Code: Select all
label test:
"something goes here"
call test2()
"something else goes here"
return # to return to main menu instead of going to next line of code (that is label test2)
label test2:
call screen test_screen()
return # to return from this label
init python:
def testFunction():
#doing some stuffs and x becomes either True or False
if x:
return True # or return x # to return from screen that been called