Page 1 of 1

renpy.return?

Posted: Fri Mar 06, 2020 5:45 am
by hapciupalit
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 		

Re: renpy.return?

Posted: Fri Mar 06, 2020 1:32 pm
by rames44
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.

Re: renpy.return?

Posted: Fri Mar 06, 2020 1:34 pm
by Alex
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