Quick question on "Timers"

Ask and answer questions about making games and related topics. Unrelated topics go in that other forum.

Moderators: marionline, SDHawk

Post Reply
User avatar
guo
Metal Slime
Posts: 718
Joined: Fri Dec 04, 2009 9:12 pm

Quick question on "Timers"

Post by guo »

Hello again,

Just a quick question here. If I set a timer with "set timer", is there a way to "add time" to that timer with the set timer function?

For example - I have timer "0" set to 300 seconds and it will decrement by 1 every 18 ticks (1 second roughly). Can I then use a command similar to :

"set timer (0, +60, 18, etc, etc, etc)"

to add or subtract from the timer?

I've never been great at this scripting stuff, so to boil it down:

I want a timer that counts down, when it hits zero something happens. I want there to be items/events that can either increase or decrease the length of the timer and have it continue running with the new length. What is the best way to achieve this?

Regards.
vvight.wordpress.com
User avatar
Foxley
Metal Slime
Posts: 832
Joined: Sat Nov 09, 2013 5:54 pm

Post by Foxley »

Just off the top of my head, maybe have the timer repeat itself every 1 sec/18 ticks while decrementing a global variable that's an integer value of the seconds left? Then other things in the script can reduce or increase the value of that variable in bursts, from penalties or bonuses.
User avatar
msw188
Metal Slime
Posts: 783
Joined: Tue Oct 16, 2007 1:43 am
Location: Los Angeles, CA

Post by msw188 »

Is there no command to read the value of the timer? so that you want

set timer (0, (readtimer(0) + 60), etc)
I am Srime
User avatar
guo
Metal Slime
Posts: 718
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

"Just off the top of my head, maybe have the timer repeat itself every 1 sec/18 ticks while decrementing a global variable that's an integer value of the seconds left? Then other things in the script can reduce or increase the value of that variable in bursts, from penalties or bonuses."

Would this still work during battles? I plan on having the timer running at all times. Again, I'm not terribly clued on scripts sorry.
vvight.wordpress.com
TMC
Metal King Slime
Posts: 4101
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

msw is right. In fact you can leave out all other arguments to settimer and the existing settings will be preserved, even if the timer has already expired. So write "set timer (0, read timer(0) + 60)".
User avatar
guo
Metal Slime
Posts: 718
Joined: Fri Dec 04, 2009 9:12 pm

Post by guo »

Thanks so much ! This is just what I need.
vvight.wordpress.com
Post Reply