What I want is a user-defined statement containing a block with some other statements, as well as some other labels, which themselves contain blocks. Sort of like the "menu" statement in ren'py. It might be easier to look at my code:
script.rpy:
Code: Select all
label start:
$var = "start"
"start" "[var]"
test:
#some stuff
"Label":
#ren'py script beneath the label (so, two subblock_lexers deep)
$ var = "end"
"test" "testing!!!"
"end" "[var]"
return
Code: Select all
python early:
def parse_test(lex):
# get block
sub = lex.subblock_lexer()
sub.advance()
# do stuff with some other code
label = sub.string()
script = sub.subblock_lexer()
return (label, script)
def execute_test(o):
script_lexer = o[1];
# What do I put here to run the given ren'py script?
def lint_test(o):
script_lexer = o[1];
# TODO: stuff
renpy.register_statement("test", parse=parse_test, execute=execute_test, lint=lint_test, block=True)
execute_test() has the lexer with the script passed into it. What can I do with this to actually run the code? Is there a ren'py Python function that will run ren'py script from a lexer? Do I need to add it to the AST somehow/somewhere? I just want the code to run and then go back to the script where the "test:" statement was.