Questions about disabling/bypassing menus and auto-saving!

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
User avatar
Offworlder
Regular
Posts: 107
Joined: Mon Aug 20, 2018 6:33 pm
Contact:

Questions about disabling/bypassing menus and auto-saving!

#1 Post by Offworlder » Fri Dec 28, 2018 5:58 am

For my current project, I essentially need to disable several standard functions. Due to that, I also need to make sure the player's progress is always being saved. I have several questions related to both topics, and it would be a huge help if anyone can point me in the right direction!

------

1. How would I force the game to completely bypass the main menu? Any time the application is launched, I want it to jump straight to the game itself without having to click "Start", etc.

2. How would I disable ALL other menus as well? Save/Load, Preferences, everything. I want to make sure there are no on-screen buttons for these menus, and that they can't be accessed via keyboard shortcuts (or mouse-clicks) either.

3. How do I ensure the game auto-saves anytime the window closes? This includes the player manually closing it, and the game quitting itself. I want to make sure there is only one possible auto-save at a time (with each new auto-save overwriting the last).

4. Related to the above, how do I ensure the game picks up from the auto-save when it is re-launched? Beyond that, I would like for the game to recognize when it's been re-launched by playing particular lines of dialogue.

------

I...think that's it for now. ^^;;
I wonder what sort of impression these questions give of the game? Haha...
Any and all help is greatly appreciated!
Last edited by Offworlder on Fri Dec 28, 2018 8:11 am, edited 2 times in total.

User avatar
Enchant00
Regular
Posts: 135
Joined: Tue Jan 12, 2016 1:17 am
Contact:

Re: Questions about disabling/bypassing menus and auto-saving!

#2 Post by Enchant00 » Fri Dec 28, 2018 7:21 am

1. You can put a condition for the main menu that checks if the game ran for at least once then auto jump to a specific save point.
2. For keyboard shortcuts, you can call a new screen which maps existing keyboard buttons to nothing or you can remove already existing keyboard shortcuts or you can disable keyboard input. For your buttons, you can just redefine you windows screen and whatnot and just show the text window itself.
3. You can force an autosave/quicksave at specific points without opening the saves screens.
5. Questions 5 is related to question 1, put a condition then force the game to autoload a quicksave/autosave so that your game starts there.

If you need some code, just say and I'll try to cook something up XD

User avatar
Offworlder
Regular
Posts: 107
Joined: Mon Aug 20, 2018 6:33 pm
Contact:

Re: Questions about disabling/bypassing menus and auto-saving!

#3 Post by Offworlder » Fri Dec 28, 2018 7:57 am

Enchant00 wrote:
Fri Dec 28, 2018 7:21 am
Thanks for responding to my questions!
Unfortunately, I'm very new to coding and not quite certain how to do the various things you're suggesting. D:


I found this code, which seems to prevent the main menu from being accessed. However, the game just starts from the beginning whenever it's loaded. I'm not sure what to add to make it start from an auto-save instead.

Code: Select all

label main_menu:
    return

As far as forcing an auto-save, I found this in the Ren'py documentation. But, I can't figure out how to actually implement it into the script.

Code: Select all

renpy.force_autosave(take_screenshot=False)
Lastly, I figure out how to hide the menu buttons in-game by just setting "default quick_menu" to "False". I looked, but I'm not sure where to disable specific keyboard shortcuts/mouse buttons. I definitely don't want to disable text input altogether, though.

rames44
Veteran
Posts: 204
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: Questions about disabling/bypassing menus and auto-saving!

#4 Post by rames44 » Fri Dec 28, 2018 1:10 pm

Keyboard and mouse shortcuts are controlled by the “keymap”. Basically, you want to remove entries from it.

Manipulating the keymap is documented here: https://www.renpy.org/doc/html/keymap.html

User avatar
Enchant00
Regular
Posts: 135
Joined: Tue Jan 12, 2016 1:17 am
Contact:

Re: Questions about disabling/bypassing menus and auto-saving!

#5 Post by Enchant00 » Fri Dec 28, 2018 4:08 pm

Thanks for responding to my questions!
Unfortunately, I'm very new to coding and not quite certain how to do the various things you're suggesting. D:
Np, let me see what I can do for you XD

Paste this above label start:

Code: Select all

default persistent.menu_first_time_done = False
define config.autosave_slots = 1

screen disable_features:
    key "game_menu" action NullAction()
    on 'show' action SetVariable('quick_menu', False)
    on 'hide' action SetVariable('quick_menu', True)

init python:
    def clear_auto_saves():
        auto_saves = renpy.list_saved_games()
        for i in auto_saves:
            if i[0].startswith('auto'):
                renpy.unlink_save(i[0])

label main_menu:
    if not persistent.menu_first_time_done:
        $ clear_auto_saves()
        call screen main_menu
    else:
        $ renpy.load('auto-1') 
Then after label start, put this:

Code: Select all

label start:
    $ persistent.menu_first_time_done = True
    
    e 'random text'
   
So here is a basic gist of what's happening. The game will only allow 1 slot for autosaves and that will be the main autosave when player quits or otherwise a forced autosave. After label start, you see $ persistent.menu_first_time_done = True. What this does is afterif the game is opened for the first time, this will become True and the main menu screen will be skipped in the future and it will load auto save slot 1.

Now run this code whenever you need it

Code: Select all

show screen disable_features
Whenever this screen is showing, button presses and the quick menu will not display and work so if you want them to work again just hide the screen. You can put this just after $ persistent.menu_first_time_done = True if you want button presses and quick menu disabled from the start of the game.

Hope this helps you XD If you have questions just say and I'll get to you ASAP

PS: If you want to see the menu screen again, in your renpy launcher click the Delete Persistent and it will reset the thing. Also, if you use the show screen disable_features after your game has an autosave, this may not work so you might need to delete pesistent again or run this function

Code: Select all

 $ clear_auto_saves()

User avatar
Offworlder
Regular
Posts: 107
Joined: Mon Aug 20, 2018 6:33 pm
Contact:

Re: Questions about disabling/bypassing menus and auto-saving!

#6 Post by Offworlder » Fri Dec 28, 2018 7:54 pm

rames44 wrote:
Fri Dec 28, 2018 1:10 pm
Keyboard and mouse shortcuts are controlled by the “keymap”. Basically, you want to remove entries from it.

Manipulating the keymap is documented here: https://www.renpy.org/doc/html/keymap.html
I actually did see that page, but I'm not quite certain I understand it. I assumed I'd be able to find "config.keymap" in "options.rpy" or "screens.rpy", but I did a general search within the entire project for "keymap" and nothing came up.

...Or maybe I'm just misunderstanding. D:

User avatar
Offworlder
Regular
Posts: 107
Joined: Mon Aug 20, 2018 6:33 pm
Contact:

Re: Questions about disabling/bypassing menus and auto-saving!

#7 Post by Offworlder » Fri Dec 28, 2018 8:11 pm

Enchant00 wrote:
Fri Dec 28, 2018 4:08 pm
Np, let me see what I can do for you XD
I tried out your code and it definitely seems to solve at least some of my inquiries. The game now auto-saves upon closing, then re-loads from the auto-save without showing the main menu. Huzzah! Thank you so much!

As far as I can tell, though, no button presses are disabled. I'm still able to open the in-game menu with F1 and right-click, for example. Of note, I definitely want to make sure that certain buttons always work. For example, pressing Enter to continue and hiding the textbox. I just don't want any menus to open. No "rollback" or things like that, either.

On another note, I'm not sure how this code is meant to work:

Code: Select all

label start:
    $ persistent.menu_first_time_done = True
    
    e 'random text'

What it ended up doing was showing the "random text" line of dialogue the first time I opened the game, then never again. What I'm wanting to accomplish is for lines of dialogue to show up whenever the game is closed/re-opened, but different dialogue at different points in the game. It should happen every time the window is closed, then re-opened.

Thanks again for all of your help so far. ^^

User avatar
Enchant00
Regular
Posts: 135
Joined: Tue Jan 12, 2016 1:17 am
Contact:

Re: Questions about disabling/bypassing menus and auto-saving!

#8 Post by Enchant00 » Sat Dec 29, 2018 11:09 am

Change your screen disable_features to the one below

Code: Select all

screen disable_features:
    key "game_menu" action NullAction()
    key "rollback" action NullAction()
    on 'show' action SetVariable('quick_menu', False)
    on 'hide' action SetVariable('quick_menu', True)
The random text was just filler and doesn't do anything. Its basically the first dialogue of your game when you start and its up to what you want.
However, change the start to the one below:

Code: Select all

label start:
    $ persistent.menu_first_time_done = True
    show screen disable_features
Make sure those two lines are the first thing under your start label before any other dialogue.

The code $ persistent.menu_first_time_done = True is only for the first time you run the game. Of course you want the player to see the main menu when he first plays the game and next time it will load from autosave.

Lastly, in renpy launcher click delete persistent data. This will reset the code i gavw you so there wont be any problems. Everything should be fine now XD

User avatar
Offworlder
Regular
Posts: 107
Joined: Mon Aug 20, 2018 6:33 pm
Contact:

Re: Questions about disabling/bypassing menus and auto-saving!

#9 Post by Offworlder » Sat Dec 29, 2018 12:21 pm

Enchant00 wrote:
Sat Dec 29, 2018 11:09 am
Everything should be fine now XD
For the type of game I'm creating, I actually don't want the main menu screen to show at any point. Even the very first time the game is loaded.

I'm not sure why, but now none of the changes are working. x_x;
All I did was replace "screen disable_features" with the updated version you suggested, then Force Recompile (unintentionally) and Delete Persistent. Now, the game just starts as it normally would from the main menu. Instead of jumping immediately to the most recent auto-save. :(

Rollback and right-clicking to open the menu are both disabled, though! I'll need to find some way to disable the various keymaps as well.

rames44
Veteran
Posts: 204
Joined: Sun May 29, 2016 4:38 pm
Contact:

Re: Questions about disabling/bypassing menus and auto-saving!

#10 Post by rames44 » Sat Dec 29, 2018 12:55 pm

Offworlder wrote:
Fri Dec 28, 2018 7:54 pm
rames44 wrote:
Fri Dec 28, 2018 1:10 pm
Keyboard and mouse shortcuts are controlled by the “keymap”. Basically, you want to remove entries from it.

Manipulating the keymap is documented here: https://www.renpy.org/doc/html/keymap.html
I actually did see that page, but I'm not quite certain I understand it. I assumed I'd be able to find "config.keymap" in "options.rpy" or "screens.rpy", but I did a general search within the entire project for "keymap" and nothing came up.

...Or maybe I'm just misunderstanding. D:
Ah, I get it. Not every bit of Ren’py will (easily) show up in your project. A good bit of it (this part included) is set up in the Python code that makes up Ren’py. That code actually hides inside the Ren’py launcher (if I’m recalling correctly) while you’re working on your project, but then gets bundled with it when you build a distribution. So it’s there, just kind of hiding in a corner. LOL

So, remember that .rpy files are in “Ren’py language”, and can include Python, but most of the core of Ren’py is written in “pure Python” and lurks outside of your project.

User avatar
Enchant00
Regular
Posts: 135
Joined: Tue Jan 12, 2016 1:17 am
Contact:

Re: Questions about disabling/bypassing menus and auto-saving!

#11 Post by Enchant00 » Sun Dec 30, 2018 8:09 am

Offworlder wrote:
Sat Dec 29, 2018 12:21 pm
Enchant00 wrote:
Sat Dec 29, 2018 11:09 am
Everything should be fine now XD
For the type of game I'm creating, I actually don't want the main menu screen to show at any point. Even the very first time the game is loaded.

I'm not sure why, but now none of the changes are working. x_x;
All I did was replace "screen disable_features" with the updated version you suggested, then Force Recompile (unintentionally) and Delete Persistent. Now, the game just starts as it normally would from the main menu. Instead of jumping immediately to the most recent auto-save. :(

Rollback and right-clicking to open the menu are both disabled, though! I'll need to find some way to disable the various keymaps as well.
Would you mind posting your code that way I can see what you done XD

User avatar
Offworlder
Regular
Posts: 107
Joined: Mon Aug 20, 2018 6:33 pm
Contact:

Re: Questions about disabling/bypassing menus and auto-saving!

#12 Post by Offworlder » Wed Jan 02, 2019 4:14 am

I apologize for taking so long to respond! My family's holiday celebrations were held a bit late, so I've been pretty busy the past few days. Now it's back to devving!

rames44:
Knowing that the file(s) I need lurk somewhere outside of the project makes everything even more confusing, honestly.
I really have no idea where to look. D:

Enchant00:
I was early enough in development that I decided to just re-start the project from scratch. Hopefully, that'll fix whatever mysterious issue caused everything to break. I'm going to play around with the code for a bit, see if I can get it to work the way I'm imagining. Thanks a ton for all of your help!

I'll make another thread if I get stuck again. >_o

Post Reply

Who is online

Users browsing this forum: Avior, Google [Bot]