How to constantly check variable [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
chewpower
Regular
Posts: 36
Joined: Mon Feb 11, 2013 11:08 pm
Contact:

How to constantly check variable [solved]

#1 Post by chewpower » Tue Apr 23, 2013 1:29 am

In my game, the gameplay requires a player to answer a phonecall to accomplish a mission, but the phonecall can happen at any random time. So assuming I can find a way to set a random timer to decide when to call the player and I put this in a variable that say

Code: Select all

$ call_now = True
or something like that, the question is, how can I make the game constantly check the value of "call_now" so that I can display an image or something when that happens?

Or is there any other way I can accomplish this?
Last edited by chewpower on Wed Apr 24, 2013 8:13 am, edited 1 time in total.
I'm sorry if I'm too stupid, but I can't learn to walk on my own

User avatar
kankan
Regular
Posts: 80
Joined: Tue Mar 06, 2012 1:47 am
Contact:

Re: How to constantly check variable

#2 Post by kankan » Tue Apr 23, 2013 8:47 pm

The only thing I can think of off the top of my head is an overlay. Alternatively, you could make your timer "randomly" call a new label which would include the details of the phone call (but this might not be as random as you'd like, probably a pseudo-random event or something...).

apricotorange
Veteran
Posts: 479
Joined: Tue Jun 05, 2012 2:01 am
Contact:

Re: How to constantly check variable

#3 Post by apricotorange » Tue Apr 23, 2013 9:44 pm

Please describe the gameplay in the section in question a bit more clearly. What do you mean by "any random time"? An arbitrary point in the game which you decided in advance, a point in in-game time you want the computer to pick for you, a point in real-time you want the computer to pick for you, or something else?

User avatar
chewpower
Regular
Posts: 36
Joined: Mon Feb 11, 2013 11:08 pm
Contact:

Re: How to constantly check variable

#4 Post by chewpower » Tue Apr 23, 2013 11:37 pm

kankan wrote:The only thing I can think of off the top of my head is an overlay.
Thanks, I'll try to dig it out.
apricotorange wrote:What do you mean by "any random time"?
Thanks, I'm thinking more like few minutes after the player trigger the mission. So when the player comes to a part where this mission begins, I'll start a function where it keeps track of renpy.get_game_runtime(), and when it hit 5 minutes for example, I'll set the call_now to True. When the value of call_now becomes True, there should be an image/button on the screen indicating that the player has a phonecall he should pick up.

Now that I explained it I realize I also don't know how to run a function in background, I mean the function should run regardless what the player is doing on the user interface. He can jump from label to label but the function should be still running. Just like daemon process, or something. I'm sorry because I don't know if Ren'Py has any better alternative of how I'm doing it. Please advice?
Last edited by chewpower on Wed Apr 24, 2013 1:13 am, edited 1 time in total.
I'm sorry if I'm too stupid, but I can't learn to walk on my own

apricotorange
Veteran
Posts: 479
Joined: Tue Jun 05, 2012 2:01 am
Contact:

Re: How to constantly check variable

#5 Post by apricotorange » Wed Apr 24, 2013 12:34 am

You can accomplish all that with a screen. To make a button only show when a certain variable is set, see http://www.renpy.org/doc/html/screens.html#if . To trigger a change to the variable based on time, you can use a timer: http://www.renpy.org/doc/html/screens.html#timer .

That said, I'd suggest you think carefully about the gameplay implications here. There are two issues: one, does the player make any choices during the phone call? That could be confusing because the interaction is happening in the middle of another interaction. The other issue is that visual novels are generally not real-time, so having effects based on actual time could be surprising for the player. For example, what if someone completes the mission in question faster than 5 minutes, or what if someone start the mission, then gets up and leaves the computer for an hour?

User avatar
chewpower
Regular
Posts: 36
Joined: Mon Feb 11, 2013 11:08 pm
Contact:

Re: How to constantly check variable

#6 Post by chewpower » Wed Apr 24, 2013 1:49 am

Thank you, apricotorange. I didn't know much about screen yet and any of it's useful features so I'll start reading the documentation now. About the gameplay I'm now considering not to use the timer, maybe I'll just pop the phonecall at randomly selected "available" points in the game. Of course I'll chose the points carefully as to avoid any unwanted weirdness in the gameplay... You see, I'm trying to make the game feel "different" everytime the player is playing it because you wouldn't know when the call is happening.
I'm sorry if I'm too stupid, but I can't learn to walk on my own

Post Reply

Who is online

Users browsing this forum: Bing [Bot]