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.
The new '{a=call:label}' hyperlink feature opens up some really interesting possibilities. I'm trying to make use of it in my current project but am unclear on how to pass parameters as part of the hyperlink.
For example, I have the following test code (which works):
label start:
$ myStr = "This is a {a=call:test}link{/a} without parameters."
"[myStr]"
call test("This direct call with parameters works!")
return
label test(param='undefined'):
"Parameter: [param]"
return
How would I modify the hyperlink to support parameters (a string in this particular case) in the hyperlink's 'call' command, the same way that I was able to pass a parameter in the subsequent standard 'call' statement?
I am guessing that creating my own scheme would involve implementing a custom 'creator-defined protocol handler', as mentioned in the changelog. Is that correct?
Is there any documentation on what's involved in doing that or, ideally, some working examples I could study?
Thanks, Remix -- that was exactly what I was looking for!
As you noted, it needed some minor debugging (missing closing quote in 'label a' plus an inadvertent indent on the config.hyperlink_handlers line).
For anyone else who learns best from studying code examples, here is the tweaked version. I switched 'label a:' to 'label start:' so that this example is ready-to-test.
init python:
def handle_call_with_args( value ):
label, args = value.split('?')
# we py_eval the args into a list for *args using eval to get variable values interpreted
renpy.call( label, *renpy.python.py_eval( "[{0}]".format( args ) ) )
define config.hyperlink_handlers = { 'call_args' : handle_call_with_args }
default var_val = 'a value'
label start:
"{a=call_args:b?12,'string',var_val}jump b{/a}"
label b( i, s, v ):
"i=[i], s=[s], v=[v]"
Again, thank you very much for taking the time to create this example. You've made my day.
Just edited my 'non working' concept to be a bit nicer format and support { a=call_args : label( string of params ) } with the () parenthesis rather than url style ?
... and fixed the *cough* typos you mentioned