Scripts / Timers

Author
Message
MChapman
8
Years of Service
User Offline
Joined: 19th May 2015
Location: USA
Posted: 25th Mar 2016 23:40
Is there any way of labeling timers maybe make a new function? The reason I'm asking is because instead of having just timer I could name the timer like
StartTimer(lootTimer, 1000)
StartTimer(timer name, timer time)
A little bit more control of the timers cause at the moment I'm not sure if they are counting down or up...
Markchapman10 is my Skype let's have some dev talk.
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 26th Mar 2016 00:09
timers count up.
StartTimer(e) will reset it back to 0.
right now a timer is linked to an existing object (i.e. (e))
so 1 timer per object but you can use timers from objects that aren't using them as long as you dont accidently reset one being use in another script....

you may want to look into using g_Time though, it's a little more set up but allows you to use as many timers as you like
g_Time basically returns the current amount of milliseconds the game has been running for
i.e.

lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
MChapman
8
Years of Service
User Offline
Joined: 19th May 2015
Location: USA
Posted: 26th Mar 2016 00:24 Edited at: 26th Mar 2016 02:00
As always you come to my rescue.
I was making my own battery/flashlight script when I ran into the timer problem.

edit: Is there a way to end a timer? or reset it?

edit again:

I'm working on an internal clock of sorts. here is my code based of your example code.


I get this error
https://www.dropbox.com/s/x2ryl1k9kuov32r/lua_Error.png?dl=0
Markchapman10 is my Skype let's have some dev talk.
smallg
Community Leader
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location:
Posted: 26th Mar 2016 13:05 Edited at: 26th Mar 2016 13:06
for the error you just need to use an equals when defining arrays -> timer = {}
Quote: "Is there a way to end a timer? or reset it?"

not really but you shouldnt need to as all it really does it compare 2 values.
you just need to reset the seconds/minutes/hours, so your code looks like this

lua guide for GG
https://steamcommunity.com/sharedfiles/filedetails/?id=398177770
windows 10
i5 @4ghz, 8gb ram, AMD R9 200 series , directx 11
MChapman
8
Years of Service
User Offline
Joined: 19th May 2015
Location: USA
Posted: 26th Mar 2016 23:12
Can we put things like this timer in the Global game loop script? and it work, cause it would make more since there it being a clock. If possible I would like a few of my other scripts to work off this time of this clock. Just a question but not important.
Markchapman10 is my Skype let's have some dev talk.
PartTimeCoder
9
Years of Service
User Offline
Joined: 9th Mar 2015
Location:
Posted: 27th Mar 2016 10:40
here's how I approach the timer limitation.... I simply made my own



so with the above functions you can have multiple global timers and multiple entity timers, usage example below
PM

Login to post a reply

Server time is: 2024-05-03 07:32:24
Your offset time is: 2024-05-03 07:32:24