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.
main_menu
If it exists, this label is called instead of the main menu. If it returns, Ren'Py will start the game at the start label. For example, the following will immediately start the game without displaying the main menu.
This seems appealing as a debugging shortcut, but I'm wary if sticking in debug code that I can't automatically disable with a config variable. I mean, I've forgotten to remove debug code before and I'm sure I'll do it again.
Is there any way to do this conditionally, based on something like a `debug` boolean? I mean, this doesn't work:
The `debug` variable is not my problem. The problem is that if I return, it goes to the 'start' label. If I don't return, it falls through to the next label in the script (which also happens to be 'start', though it could be anything). For this to work, I need something that conditionally disables the *existence* of the 'main_menu' label. Or else, more likely, some other way to conditionally bypass the main menu on game startup.
I would suggest using the `splashcreen` label instead, then add `$ renpy.run(Start())` as the last line of that label. Then add whatever condition you want on when to run this action.
zmook wrote: ↑Thu Feb 25, 2021 8:27 pm
The `debug` variable is not my problem. The problem is that if I return, it goes to the 'start' label. If I don't return, it falls through to the next label in the script (which also happens to be 'start', though it could be anything). For this to work, I need something that conditionally disables the *existence* of the 'main_menu' label. Or else, more likely, some other way to conditionally bypass the main menu on game startup.
if debug:
skip main menu
else:
show main menu normally
In that case, maybe replace "pass" in my psuedocode example from above with a jump to a dummy label that then returns? In theory it should get you out of the stack depth, back to main menu context.
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.
hell_oh_world wrote: ↑Thu Feb 25, 2021 8:56 pm
I would suggest using the `splashcreen` label instead, then add `$ renpy.run(Start())` as the last line of that label. Then add whatever condition you want on when to run this action.
While running game code:
File "renpy/common/00start.rpy", line 231, in script call
call _splashscreen from _call_splashscreen_1
File "game/script.rpy", line 5, in script
$ renpy.run(Start())
File "game/script.rpy", line 5, in <module>
$ renpy.run(Start())
File "renpy/common/00action_menu.rpy", line 148, in __call__
renpy.jump_out_of_context(self.label)
JumpOutException: start
I also just tried putting code into the main_menu screen itself to see if I could just trigger the action like an automated click. This also does not work:
I'm sorry, but an uncaught exception occurred.
While running game code:
File "game/script.rpy", line 36, in script call
call time_controller from _call_time_controller
File "game/time_controller.rpy", line 7, in script
"Time controller"
Exception: ui.interact called with non-empty widget/layer stack. Did you forget a ui.close() somewhere?
Stack was <Layer: u'transient'>
<Many: <Fixed at 1122f1f10>>
colin r
➔ if you're an artist and need a bit of help coding your game, feel free to send me a PM
Imperf3kt wrote: ↑Thu Feb 25, 2021 10:07 pm
In that case, maybe replace "pass" in my psuedocode example from above with a jump to a dummy label that then returns? In theory it should get you out of the stack depth, back to main menu context.
Jumping to a dummy label and then returning has the same effect as returning directly. It appears that the docs should just say: "If the label 'main_menu' exists, it will be called instead of the screen 'main_menu'. When it returns Ren'Py will start the game at the start label."