renpy.jump with parameter

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.
Post Reply
Message
Author
User avatar
trekopedia
Regular
Posts: 25
Joined: Thu Sep 14, 2017 11:38 pm
Location: Toronto, Canada
Contact:

renpy.jump with parameter

#1 Post by trekopedia » Sat Oct 07, 2017 8:43 pm

Hi again everyone,

I know that it is possible in renpy script to call a label while passing a parameter. Per the documentation, I could do this:

<code>
call expression "subroutine" pass (count=3)

# ...

label subroutine(count=1):
</code>

Is it also possible to do something similar from python code? How would I pass a parameter from a jump method (renpy.jump()) to the label's code? At the moment, the only option I can think of is to set a global variable prior to the jump and then have that variable checked in the label's code -- but that seems awfully inelegant. Are there any better solutions?

Thanks in advance!

philat
Eileen-Class Veteran
Posts: 1853
Joined: Wed Dec 04, 2013 12:33 pm
Contact:

Re: renpy.jump with parameter

#2 Post by philat » Sun Oct 08, 2017 1:09 am

Nope. If that feature existed, it would probably be documented.

User avatar
Remix
Eileen-Class Veteran
Posts: 1628
Joined: Tue May 30, 2017 6:10 am
Completed: None... yet (as I'm still looking for an artist)
Projects: An un-named anime based trainer game
Contact:

Re: renpy.jump with parameter

#3 Post by Remix » Sun Oct 08, 2017 6:27 am

As philat says, jump has no additional arguments other than just label name passed to it, so cannot support what you want.

Even though call can support extra arguments (as you saw in the docs), it has to know where in the script it is located (so it can return to that point if needed). Therefore, to even effectively do a renpy.ast.Call with bonus parameters you would need to add the filename, linenumber tuple which quickly gets messy and might well glitch save/rollback

Though inelegant, the setting global variable values option does seem the best way to go
Frameworks & Scriptlets:

User avatar
trekopedia
Regular
Posts: 25
Joined: Thu Sep 14, 2017 11:38 pm
Location: Toronto, Canada
Contact:

Re: renpy.jump with parameter

#4 Post by trekopedia » Sun Oct 08, 2017 11:34 am

OK. Thanks. I figured the jump method itself wasn't going to be the solution since it wasn't documented, but I thought perhaps I was missing some similar option. Global variable it is! :-)

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot]