Problems with screen actions On Hide [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
User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Problems with screen actions On Hide [Solved]

#1 Post by trooper6 » Tue Feb 03, 2015 12:03 am

Hello All!

I'm doing some testing with screen actions...and I've run into a problem.

So in my test project I have two test variables, "checker1" and "checker2"; they are initialized to be None at the start of my project.
So far so good.
I have added the following code to the preferences screen:

Code: Select all

    on "show" action SetVariable("checker1", 1)
    on "hide" action SetVariable("checker2", 2)
So I run my project. Then I pull up the preferences and then either escape back or return back to the game. Then I check my variables.
What do I get?
checker1 == 1
checker2 == None

So the on show is working, but the on hide isn't.

So rather than on "hide", I tried on "replaced" and also on "replace"--no luck. There are no other On events.

I don't get any errors. And the variable is changed on show...but nothing happens on hide.
So...what is going on?
Last edited by trooper6 on Tue Feb 03, 2015 2:41 am, edited 1 time in total.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
nyaatrap
Crawling Chaos
Posts: 1824
Joined: Mon Feb 13, 2012 5:37 am
Location: Kimashi Tower, Japan
Contact:

Re: Problems with screen actions On Hide

#2 Post by nyaatrap » Tue Feb 03, 2015 1:10 am

As far as I know, The game menu is called in a new context. When returning to the game from a new context, it terminates the new context. So on hide statement doesn't work in the game menu.
You have to use functions before return statement.

Code: Select all

key "game_menu" action [SetVariable(), Return()]

User avatar
trooper6
Lemma-Class Veteran
Posts: 3712
Joined: Sat Jul 09, 2011 10:33 pm
Projects: A Close Shave
Location: Medford, MA
Contact:

Re: Problems with screen actions On Hide

#3 Post by trooper6 » Tue Feb 03, 2015 2:40 am

That works, I'll try to keep that in mind for future leaving game menu excitement! Though it turns out that since game menu is a new context, if I stop playing music while in the game menu and return to the game...the music starts back up again on its own. So that it pretty awesome.
A Close Shave:
*Last Thing Done (Aug 17): Finished coding emotions and camera for 4/10 main labels.
*Currently Doing: Coding of emotions and camera for the labels--On 5/10
*First Next thing to do: Code in all CG and special animation stuff
*Next Next thing to do: Set up film animation
*Other Thing to Do: Do SFX and Score (maybe think about eye blinks?)
Check out My Clock Cookbook Recipe: http://lemmasoft.renai.us/forums/viewto ... 51&t=21978

User avatar
octacon100
Regular
Posts: 163
Joined: Thu Sep 12, 2013 11:23 pm
Projects: Regeria Hope
Organization: Golden Game Barn
IRC Nick: Octacon100
Location: Boston, MA
Contact:

Re: Problems with screen actions On Hide [Solved]

#4 Post by octacon100 » Tue Feb 03, 2015 3:48 pm

I've had some luck using SetScreenVariable() with variables that need to change immediately, but I'm not sure if that will work with hiding a screen. Would be interesting to know. Hope that helps!
Image
Current Digital Projects -
Image
Regiera Hope Completed Game Forum Post

Post Reply

Who is online

Users browsing this forum: zyric