add variable every 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.
Post Reply
Message
Author
de_nederlander
Newbie
Posts: 21
Joined: Thu Aug 04, 2016 8:26 am
Contact:

add variable every minute [SOLVED]

#1 Post by de_nederlander » Wed Aug 10, 2016 2:51 pm

I wanted to make a script that would add a variable to another variable every minute.

for example I have variable "money" and I want to add variable "income" to it every 60 seconds, no matter on which label/screen the player currently is.

thanks for your help.
Last edited by de_nederlander on Wed Aug 10, 2016 5:47 pm, edited 1 time in total.

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: add variable every minute

#2 Post by kivik » Wed Aug 10, 2016 3:56 pm

I think timer is the way to do it:

https://www.renpy.org/doc/html/screens.html#timer

I think the code may look something like this:

Code: Select all

timer 60.0 repeat action SetVariable('money', money + income)

de_nederlander
Newbie
Posts: 21
Joined: Thu Aug 04, 2016 8:26 am
Contact:

Re: add variable every minute

#3 Post by de_nederlander » Wed Aug 10, 2016 4:04 pm

kivik wrote:I think timer is the way to do it:

https://www.renpy.org/doc/html/screens.html#timer

I think the code may look something like this:

Code: Select all

timer 60.0 repeat action SetVariable('money', money + income)
does this work no matter what screen you're on?

de_nederlander
Newbie
Posts: 21
Joined: Thu Aug 04, 2016 8:26 am
Contact:

Re: add variable every minute

#4 Post by de_nederlander » Wed Aug 10, 2016 4:08 pm

Code: Select all

timer 60.0 repeat action SetVariable('money', money + income)
i tried this but it says it expects a statement

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: add variable every minute

#5 Post by kivik » Wed Aug 10, 2016 4:09 pm

de_nederlander wrote:
kivik wrote:I think timer is the way to do it:

https://www.renpy.org/doc/html/screens.html#timer

I think the code may look something like this:

Code: Select all

timer 60.0 repeat action SetVariable('money', money + income)
does this work no matter what screen you're on?
I'm afraid you'll have to test it yourself. I suspect what you can do is just add an invisible screen that's always showing but doesn't conflict with anything.

de_nederlander
Newbie
Posts: 21
Joined: Thu Aug 04, 2016 8:26 am
Contact:

Re: add variable every minute

#6 Post by de_nederlander » Wed Aug 10, 2016 4:30 pm

I'm afraid you'll have to test it yourself. I suspect what you can do is just add an invisible screen that's always showing but doesn't conflict with anything.
and how does an invisible screen work?

kivik
Miko-Class Veteran
Posts: 786
Joined: Fri Jun 24, 2016 5:58 pm
Contact:

Re: add variable every minute

#7 Post by kivik » Wed Aug 10, 2016 5:30 pm

Basically have nothing but the timer in it. This is test code that worked for me:

Code: Select all

label start:
    $ test_var = 0
    show screen invi
    pause
    "[test_var]"

screen invi:
    timer 1.0 repeat True action SetVariable("test_var", test_var+10)

de_nederlander
Newbie
Posts: 21
Joined: Thu Aug 04, 2016 8:26 am
Contact:

Re: add variable every minute

#8 Post by de_nederlander » Wed Aug 10, 2016 5:44 pm

kivik wrote:Basically have nothing but the timer in it. This is test code that worked for me:

Code: Select all

label start:
    $ test_var = 0
    show screen invi
    pause
    "[test_var]"

screen invi:
    timer 1.0 repeat True action SetVariable("test_var", test_var+10)
I think I can make it work with that, thanks.

Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot], span4ev