Menus in the middle of my script

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.
Post Reply
Message
Author
notanumber
Newbie
Posts: 16
Joined: Mon Jul 08, 2019 6:19 pm
Contact:

Menus in the middle of my script

#1 Post by notanumber »

I'm working on a screen for my game with a menu for the player to do some resource management, and then resume the normal flow.
I can get the screen to show up and all, but I'm having a hard time making the game flow not do anything while that screen is being displayed.
I tried something like:

Code: Select all

    show screen teamManager
    while exitConfirmation == False:
        pause 1
(hitting the done button on the screen sets the exitConfirmation variable to True)
not only am i getting an empty dialogue screen in the middle of the scene i want to display, but it crashes when i hit done.
Is there a way to just make the game flow "stay here and don't do anything until the player hits the 'Done!' button on the screen"?

And while we're at it, any way to disable pressing Esc to pull out the menu while the screen is displayed?

User avatar
Per K Grok
Miko-Class Veteran
Posts: 882
Joined: Fri May 18, 2018 1:02 am
Completed: the Ghost Pilot, Sea of Lost Ships, Bubbles and the Pterodactyls, Defenders of Adacan Part 1-3, the Phantom Flyer
itch: per-k-grok
Location: Sverige
Contact:

Re: Menus in the middle of my script

#2 Post by Per K Grok »

notanumber wrote: Sun Jul 28, 2019 11:38 pm I'm working on a screen for my game with a menu for the player to do some resource management, and then resume the normal flow.
I can get the screen to show up and all, but I'm having a hard time making the game flow not do anything while that screen is being displayed.
I tried something like:

Code: Select all

    show screen teamManager
    while exitConfirmation == False:
        pause 1
(hitting the done button on the screen sets the exitConfirmation variable to True)
not only am i getting an empty dialogue screen in the middle of the scene i want to display, but it crashes when i hit done.
Is there a way to just make the game flow "stay here and don't do anything until the player hits the 'Done!' button on the screen"?

And while we're at it, any way to disable pressing Esc to pull out the menu while the screen is displayed?


You could call the screen instead of showing it. You should in that case set the action of the 'Done'-button to 'Return'

call screen teamManager

textbutton "Done" action Return


On the Esc question you can read on how to add and remove keys from the keymap here:
https://www.renpy.org/doc/html/keymap.h ... ht=keymaps

notanumber
Newbie
Posts: 16
Joined: Mon Jul 08, 2019 6:19 pm
Contact:

Re: Menus in the middle of my script

#3 Post by notanumber »

Calling the screen worked, so thanks!
Unfortunately "action Return" isn't. I worked around it with
textbutton "Done" action [Hide("teamManager"), Jump(nextlabel)]
which isn't elegant but gets the job done.

User avatar
Imperf3kt
Lemma-Class Veteran
Posts: 3795
Joined: Mon Dec 14, 2015 5:05 am
itch: Imperf3kt
Location: Your monitor
Contact:

Re: Menus in the middle of my script

#4 Post by Imperf3kt »

You should use action Return(), because otherwise you are still within the new context. You need to pop the call stack... Something something

This is getting into territory I'm only vaguely familiar with, but basically you should use Return(), not hide.

https://www.renpy.org/doc/html/label.ht ... -statement
Warning: May contain trace amounts of gratuitous plot.
pro·gram·mer (noun) An organism capable of converting caffeine into code.

Current project: GGD Mentor

Twitter

Post Reply

Who is online

Users browsing this forum: Reficul Hopes