Adding +1 to var every one "real-time "minute [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.
Message
Author
User avatar
mugenjohncel
Hentai Poofter
Posts: 2121
Joined: Sat Feb 04, 2006 11:13 pm
Organization: Studio Mugenjohncel
Location: Philippines
Contact:

Adding +1 to var every one "real-time "minute [SOLVED]

#1 Post by mugenjohncel »

I have this little var thing in the code (I forgot the proper name)

Code: Select all

    $ minutes = 0
By default you could add points to it by doing something like this (2 points in this case)

Code: Select all

    $ minutes += 2
So the question is...

Is it possible for Renpy to bind this to actual minutes. Meaning, for every "real-time" minute that passed it will add +1 to...

Code: Select all

    $ minutes = 0
So after 60 "real-time" minutes you will have something like this...

Code: Select all

    $ minutes = 60
Anyway, this is basically my problem in layman's term...
Image

I know there is a code somewhere around here that can detect accumulated "real-time" minutes and translate that to something that can be used to activate specific events.

"POOF" (Waits patiently with Puppy Eyes)

Edit:
OK, I think I partially recalled that code. It's a persistent thingy that runs in the background and for every "Real-Time" minute that passed it adds +1 value to whatever var thingy you assigned it (Again sorry... I forgot the proper name) but I can't seem to recall where it was around here...

;_;

Edit 2:
In case you're wondering, it's for this Analog Clock found in the Ren'py Cookbook.
http://www.renpy.org/wiki/renpy/doc/coo ... alog_Clock
Last edited by mugenjohncel on Mon May 31, 2010 10:52 pm, edited 2 times in total.

number473
Regular
Posts: 195
Joined: Tue Dec 15, 2009 4:20 am
Projects: The Duke's Daughter
Location: Cape Town
Contact:

Re: Adding +1 to var every one "real-time "minute

#2 Post by number473 »

Very good explanation of the problem ^^;;;

Maybe this?

Edit: Or, more likely this or this?
Mental weather report: Cloudy with a possibility of brain storms.

Cironian
Regular
Posts: 33
Joined: Sun Aug 26, 2007 5:34 pm
Projects: Dragon Story
Contact:

Re: Adding +1 to var every one "real-time "minute

#3 Post by Cironian »

Something like this should work:

Code: Select all

python:
    def clocktick():
        global minutes
        minutes += 1
        return

ui.timer(60.0, clocktick, repeat=True)
I use this method with a far smaller timeout for a credits scroller, and apart from the current lack of vsync support in Renpy it works fine.

User avatar
mugenjohncel
Hentai Poofter
Posts: 2121
Joined: Sat Feb 04, 2006 11:13 pm
Organization: Studio Mugenjohncel
Location: Philippines
Contact:

Re: Adding +1 to var every one "real-time "minute

#4 Post by mugenjohncel »

Cironian wrote:

Code: Select all

python:
    def clocktick():
        global minutes
        minutes += 1
        return

ui.timer(60.0, clocktick, repeat=True)
Whe I tried your code, I got something like this...

Code: Select all

On line 508 of C:\Documents and Settings\rape\My Documents\renpy-6.10.2\Final Days of Lucy/game/options.rpy: expected statement.
ui.timer(60.0, clocktick, repeat=True)
Help...

LVUER
King of Lolies
Posts: 4538
Joined: Mon Nov 26, 2007 9:57 pm
Completed: R.S.P
Location: Bandung, West Java, Indonesia
Contact:

Re: Adding +1 to var every one "real-time "minute

#5 Post by LVUER »

If I'm not mistaken, RenPy could count your playtime. I don't know the function but could you also use that feature to count time?
"Double the princesses, quadruple the fun!" - Haken Browning (SRW-OG Endless Frontier)

DeviantArt Account
MoeToMecha Blog (under construction)
Lolicondria Blog (under construction) <- NSFW

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Adding +1 to var every one "real-time "minute [NOT SOLVE

#6 Post by Aleema »

Restart the interaction, and Cironian's script works. Put the timer in an overlay, and it seemed to work without having to paste it in the main script.

Code: Select all

init python:
    def clocktick():
        global minutes
        minutes += 1
        renpy.restart_interaction()
        return
        
    timegoes = True
        
    def timer():
        if timegoes:
            ui.timer(60.0, clocktick, repeat=True)
    config.overlay_functions.append(timer)

User avatar
mugenjohncel
Hentai Poofter
Posts: 2121
Joined: Sat Feb 04, 2006 11:13 pm
Organization: Studio Mugenjohncel
Location: Philippines
Contact:

Re: Adding +1 to var every one "real-time "minute [NOT SOLVE

#7 Post by mugenjohncel »

Aleema wrote:Restart the interaction, and Cironian's script works. Put the timer in an overlay, and it seemed to work without having to paste it in the main script.
WHAO!... It's working!... PROBLEM SOLVED! It's now a real "working" analog clock using "real" time... I'm gonna fine tune this one to support a "seconds" hand and put this in the cookbook with possible usages, a demo game and examples...

Thanks everyone... Really...

"POOF" (Disappears)

Black_Saber
Regular
Posts: 74
Joined: Wed Jul 14, 2010 4:56 am
Completed: cafe minigame
Projects: Beach Restaurant
Location: Indonesia
Contact:

Re: Adding +1 to var every one "real-time "minute [SOLVED]

#8 Post by Black_Saber »

i'm sorry if I'm bumping into someone else thread, but I wanted to ask regarding this issue.

How can I catch the var for this clocktick? I've tried using :

Code: Select all

init :

$ minutes = 540
[above code along with the analog clock]

label start:

e "Let's wait for the clocks to ticks.."

if minutes == 541:
    jump next_scene
but it didn't jump into the next scene while the clock ticks every minutes.
"*cackle*cackle*! In short, it's all about cleverly using the gaps between jobs to play. If it goes too far, it can turn to laziness. However, people only become mature when they learn to balance work with pleasure. Simply put, if all you care about is work all the time, you're not fully mature." - Gaap (Umineko no Naku Koro ni)

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Adding +1 to var every one "real-time "minute [SOLVED]

#9 Post by Aleema »

This is probably stupid and of no help, but try saying ">=" greater than or equal to 541 if the number you're comparing is never exactly 541 or isn't an integer or something else like that.

Black_Saber
Regular
Posts: 74
Joined: Wed Jul 14, 2010 4:56 am
Completed: cafe minigame
Projects: Beach Restaurant
Location: Indonesia
Contact:

Re: Adding +1 to var every one "real-time "minute [SOLVED]

#10 Post by Black_Saber »

Aleema wrote:This is probably stupid and of no help, but try saying ">=" greater than or equal to 541 if the number you're comparing is never exactly 541 or isn't an integer or something else like that.
looks like it still can't catch the integer, while 540 defined in the init was to begin the clocks at 9 AM.

hmm, I've tried using the analog one without clockticks function above, and it's worked if I use :

Code: Select all

init : 
$ minutes = 540

[analog code]
label start:

$ clock = True
with dissolve

e "Test"

$ minutes += 2

e "Look at the clock, it's moving by 2 every time I'm talking"

$ minutes += 2

e "That's funny, you know."

if minutes == 544:
   jump next_scene
it's working(yes, with a click too, why I didn't notice it sooner). But what I wanted to achieve are an event based by user interaction with actual time spent on it.(yea, my cafe project)

EDIT :

Er, it's actually worked with == and >=. I just need to click and it's jumped into the next scene.

So, looks like this code won't work automatically, eh?

did renpy have an auto trigger function?
"*cackle*cackle*! In short, it's all about cleverly using the gaps between jobs to play. If it goes too far, it can turn to laziness. However, people only become mature when they learn to balance work with pleasure. Simply put, if all you care about is work all the time, you're not fully mature." - Gaap (Umineko no Naku Koro ni)

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Adding +1 to var every one "real-time "minute [SOLVED]

#11 Post by Aleema »

Okay, the problem isn't the time or how you're checking, it's when you're checking. While you're on a line of dialogue, the game is frozen there. You have a conditional after that line, and it will only check minutes after you proceed past there, and if you do it too early it will return false and move on. It won't keep checking minutes. If you want to do that, I suggest another overlay. Overlays refresh constantly, I believe, so if you check it in one of those and then jump with renpy.jump("next_scene") it may work.

Black_Saber
Regular
Posts: 74
Joined: Wed Jul 14, 2010 4:56 am
Completed: cafe minigame
Projects: Beach Restaurant
Location: Indonesia
Contact:

Re: Adding +1 to var every one "real-time "minute [SOLVED]

#12 Post by Black_Saber »

Aleema wrote:Okay, the problem isn't the time or how you're checking, it's when you're checking. While you're on a line of dialogue, the game is frozen there. You have a conditional after that line, and it will only check minutes after you proceed past there, and if you do it too early it will return false and move on. It won't keep checking minutes. If you want to do that, I suggest another overlay. Overlays refresh constantly, I believe, so if you check it in one of those and then jump with renpy.jump("next_scene") it may work.
so I need to make another def function with a 'refresh the layer constantly' (every second i guess?), adding the renpy.jump within it and finished it with config.overlay_function(that def), is that it?

k, I'll try searching within lemmasoft first if someone already ask or solved that kind of trial and trying myself, first.

thanks for the advice Aleema. Happy New Year :)
"*cackle*cackle*! In short, it's all about cleverly using the gaps between jobs to play. If it goes too far, it can turn to laziness. However, people only become mature when they learn to balance work with pleasure. Simply put, if all you care about is work all the time, you're not fully mature." - Gaap (Umineko no Naku Koro ni)

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Adding +1 to var every one "real-time "minute [SOLVED]

#13 Post by Aleema »

Not that hard, just something like this:

Code: Select all

    checking_for_scene_change = True
    def scene_checker():
        global minutes
        if checking_for_scene_change:
            if minutes >= 541:
                renpy.jump("next_scene")
    config.overlay_functions.append(scene_checker)
And thanks, happy new year to you, too. :D

Black_Saber
Regular
Posts: 74
Joined: Wed Jul 14, 2010 4:56 am
Completed: cafe minigame
Projects: Beach Restaurant
Location: Indonesia
Contact:

Re: Adding +1 to var every one "real-time "minute [SOLVED]

#14 Post by Black_Saber »

Aleema wrote:Not that hard, just something like this:

Code: Select all

    checking_for_scene_change = True
    def scene_checker():
        global minutes
        if checking_for_scene_change:
            if minutes >= 541:
                renpy.jump("next_scene")
    config.overlay_functions.append(scene_checker)
And thanks, happy new year to you, too. :D
here what i got :

Code: Select all

Exception: ui.interact called with non-empty widget/layer stack. Did you forget a ui.close() somewhere?

While running game code:
 - script at line 84 of D:\Data Rizka\Master\cobajam/game/script.rpy
in the line 84 are :

Code: Select all

82 label next_scene:
83
84   e "Congrats, you jumped into this part"
and no, I'm not using any ui.interact, so looks like the problem lies within ui.add in the analog clock?

EDIT :

as I've read from http://lemmasoft.renai.us/forums/viewto ... f=8&t=4998

you can't call a new context within overlay function.. so, judging from that, the problem lies in renpy.jump("next_scene") ?
Last edited by Black_Saber on Sun Jan 02, 2011 10:59 pm, edited 1 time in total.
"*cackle*cackle*! In short, it's all about cleverly using the gaps between jobs to play. If it goes too far, it can turn to laziness. However, people only become mature when they learn to balance work with pleasure. Simply put, if all you care about is work all the time, you're not fully mature." - Gaap (Umineko no Naku Koro ni)

User avatar
Aleema
Lemma-Class Veteran
Posts: 2677
Joined: Fri May 23, 2008 2:11 pm
Organization: happyB
Tumblr: happybackwards
Contact:

Re: Adding +1 to var every one "real-time "minute [SOLVED]

#15 Post by Aleema »

Jumping wouldn't create a new context, "call in new context" and such would. (Or maybe it does and I'm a dummy) So, hmm. That error usually happens when I just plain forget a ui.close, but I suspect this is because another interface is trying to build but a code interrupted it (so it never got to its ui.close). When does the error appear? After you've jumped or before you jump or what?
Last edited by Aleema on Fri Dec 31, 2010 7:28 am, edited 1 time in total.

Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], decocloud