Non-trivial F1 handler and related things (solved)

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
iichan_lolbot
Veteran
Posts: 206
Joined: Tue Dec 30, 2008 9:18 am
Projects: iichan erogame
Contact:

Non-trivial F1 handler and related things (solved)

#1 Post by iichan_lolbot » Sun Jan 04, 2009 9:40 am

I'm using non-trivial F1 handler (a dialogue with a character in a new context). Here are some troubles I had implementing it, maybe somebody would find this text usefull:

Trouble 1 (solved). Several presses = several help screens. F1 can be pressed several times with showing several help dialogues in a stack way.
  • A value was set to 1 in the beginning of help, to 0 in the end.
  • I inserted a value check in the beginning of help, so no second calls are possible.

Code: Select all

init:
    $ game_is_in_help = 0
label help:
    if game_is_in_help:
        return
    $ game_is_in_help = 1
    jump help_loop
label help_loop:
    #your help dialogues goes here
label help_finish:
    $ game_is_in_help = 0
    return
Trouble 2 (solved). game_is_in_help=1, but not inside help. WTF?! There was a way to destroy data integrity, to leave help without setting this value to 0. When calling help from the main menu, it is possible to destroy context by pressing Esc or RightMouseButton. It was the only known point of unusual exit.
  • I decided to have my own F1 handler, that would work only inside of game, not in main menu. See "Konami code" in cookbook for details on keypress handlers.
  • I just inserted "Help" to main menu list to make it possible to read help outside of game process.
Trouble 3 (solved). Window title or subtitle change. I wanted a window title to be changed to "MyGame - Help" during help, so the user would better understand, that this game-like area is not a game in fact.
  • Let's upgrade the code from above.

Code: Select all

label help:
    if game_is_in_help:
        return
    python:
        game_is_in_help = 1
        tmp_window_subtitle = _window_subtitle
    jump help_loop
label help_loop:
    $ _window_subtitle = u" - Help"
    #your help dialogues goes here
label help_finish:
    python:
        _window_subtitle = tmp_window_subtitle
        game_is_in_help = 0
    return

Trouble 4 (solved). Saves inside help is enabled and buggy. Save game name and screenshot are from help, save point is a point from where help was called. Also, you can't save when in a new context, due to not being able to persist the state of python code.
  • I want to implement some disabling functions for my own user environment (quick save by F6, floating widgets bar, etc...)
  • I also want to disable right mouse click or escape keys by setting _game_menu_screen to None (or something different from usual, to handle event more properly).
Last edited by iichan_lolbot on Sun Jan 04, 2009 2:45 pm, edited 1 time in total.

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Non-trivial F1 handler and related things

#2 Post by PyTom » Sun Jan 04, 2009 2:24 pm

WRT to the first 3, you can probably make your life easier by using renpy.dynamic. If you do something like:

Code: Select all

init:
     game_is_in_help = False

label help:
     if game_is_in_help:
            return
     $ renpy.dynamic("game_is_in_help")
     $ renpy.dynamic("_window_subtitle")

     game_is_in_help = True
     _window_subtitle = " - Help"

     # lots of code here.
   
     return # resets game_is_in_help and _window_subtitle
You can't save when in a new context, due to not being able to persist the state of python code. You could disable saving by setting _game_menu_screen to None, which disables the game menu entirely. Or you could just live with it, and trust that it's unlikely for a user to save while in the help system.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

iichan_lolbot
Veteran
Posts: 206
Joined: Tue Dec 30, 2008 9:18 am
Projects: iichan erogame
Contact:

Re: Non-trivial F1 handler and related things

#3 Post by iichan_lolbot » Sun Jan 04, 2009 2:38 pm

>>>WRT to the first 3
Sorry, what? English is not my native language, also I don't know any slang dictionary, so...

>>>make your life easier by using renpy.dynamic
Oh, thanks. It's very interesting!

>>>You can't save when in a new context, due to not being able to persist the state of python code.
I know, that this trouble exists, that's why I asked. It's also the reason I couldn't just live with it.

>>>setting _game_menu_screen to None
Yes, it's a good idea. renpy.dynamic would be very handy there too, I guess.

User avatar
PyTom
Ren'Py Creator
Posts: 15893
Joined: Mon Feb 02, 2004 10:58 am
Completed: Moonlight Walks
Projects: Ren'Py
IRC Nick: renpytom
Github: renpytom
itch: renpytom
Location: Kings Park, NY
Contact:

Re: Non-trivial F1 handler and related things

#4 Post by PyTom » Sun Jan 04, 2009 4:16 pm

iichan_lolbot wrote:>>>WRT to the first 3
Sorry, what? English is not my native language, also I don't know any slang dictionary, so...
Sorry... WRT means With Respect To.
Supporting creators since 2004
(When was the last time you backed up your game?)
"Do good work." - Virgil Ivan "Gus" Grissom
"Silly and fun things are important." - Elon Musk
Software > Drama • https://www.patreon.com/renpytom

iichan_lolbot
Veteran
Posts: 206
Joined: Tue Dec 30, 2008 9:18 am
Projects: iichan erogame
Contact:

Re: Non-trivial F1 handler and related things (solved)

#5 Post by iichan_lolbot » Mon Jan 05, 2009 4:59 am

Oh, thanks! *^_^*

Post Reply

Who is online

Users browsing this forum: No registered users