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.
Hello! I have a death scene in my game, at the bottom of the script, but when I have a screen jump to the label, it plays the scene but then returns back to where the player was prior to dying.
Any reason for this?
return returns to the place at the top of so-called call stack or to main menu if call stack is empty. Each time you call a label, you place line where you call from on top of the call stack. Anyreturn will return to that place. For example:
label death:
"I am dead"
return
label start:
"..."
# if you die here, you will return to the main menu
call some_scene
"I survived"
return
label some_scene:
"..."
# if you die here, you will return to the place this label was called from
return
If you want unconditional return to the main menu, use $ renpy.full_restart() instead.
Ocelot wrote: ↑Mon Jul 26, 2021 6:54 pmreturn returns to the place at the top of so-called call stack or to main menu if call stack is empty. Each time you call a label, you place line where you call from on top of the call stack. Anyreturn will return to that place. For example:
label death:
"I am dead"
return
label start:
"..."
# if you die here, you will return to the main menu
call some_scene
"I survived"
return
label some_scene:
"..."
# if you die here, you will return to the place this label was called from
return
If you want unconditional return to the main menu, use $ renpy.full_restart() instead.
Ok, thank you, I’ll try this! Can I ask though, does it matter where you place the death label? Does it need to be at the end of the script?
label death:
"I am dead"
$ renpy.full_restart()
# does not matter where it is, because control will not leave it anyway
label start:
"start"
# relative positioning of start and scene01 labels is important
# because we want scene01 play right after the start scene
label scene01:
"scene 1"
jump death
# what after scene01 does not matter because we are explicitely jumping to the next label.
Ocelot wrote: ↑Mon Jul 26, 2021 7:14 pm
No, label placement only matters if you "fall through" it without returning or jumping: in this case next label will be run:
label death:
"I am dead"
$ renpy.full_restart()
# does not matter where it is, because control will not leave it anyway
label start:
"start"
# relative positioning of start and scene01 labels is important
# because we want scene01 play right after the start scene
label scene01:
"scene 1"
jump death
# what after scene01 does not matter because we are explicitely jumping to the next label.