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.
I have a list of labels I want to call, and made a for loop. But once it's done running the first called label, the loop skips the remaining code block and exits. Am I using a wrong return statement or something? I was also having trouble running a for loop without making it a python block. If there's a way to do it with renpy, please let me know.
init python:
chapters = [
("Prologue", "prologue"),
("Chapter 1", "chapter1"),
("Epilogue", "epilogue")
]
label play:
python:
for label in chapters:
renpy.call(label)
#only prologue label gets run
#code exits here straight to where play is called and continues normally
renpy.say("","Hello world.") #This doesn't show up
return
label prologue:
"This is the prologue."
return
label start:
call play
"This still gets run."
return
Last edited by aegis-of-justice on Sun Mar 09, 2014 9:20 pm, edited 1 time in total.
"renpy.call()" is a bit tricky to use: the way control flow functions work in Ren'Py is that they throw exceptions which are caught by the runtime. So everything in a Python block after the first call to "renpy.call()" never runs.
Control flow using Ren'Py statements is a bit more awkward (there isn't any for loop), but something like the following works: