Page 1 of 1

How to set a timer

Posted: Sun Oct 20, 2024 7:30 pm
by Eboreg
So... I've been looking in to setting a timer for an event to go off, say... five minutes after a previous event was fired. i.e. a side has been told to change from weapons hold to weapons tight and I want to reset it back to weapons hold 5 minutes later. However, the lua code I have now sets the timer to go off at Jan 1, 1 AD at 0000Z. What am I doing wrong?

Code: Select all

local current = ScenEdit_CurrentTime()
local newtime = current + (5*60)
local trigger = ScenEdit_SetTrigger({description='Check For Stand Down', Time=newtime})

Re: How to set a timer

Posted: Mon Oct 21, 2024 6:53 am
by blu3s

Code: Select all

local newTime = os.date('%d/%m/%Y %H:%M:%S', ScenEdit_CurrentTime() + (5*60))
local trigger = ScenEdit_SetTrigger({description='Check For Stand Down', Time=newTime })

Re: How to set a timer

Posted: Mon Oct 21, 2024 12:48 pm
by Eboreg
blu3s wrote: Mon Oct 21, 2024 6:53 am

Code: Select all

local newTime = os.date('%d/%m/%Y %H:%M:%S', ScenEdit_CurrentTime() + (5*60))
local trigger = ScenEdit_SetTrigger({description='Check For Stand Down', Time=newTime })
Tried to run that code and this is what I got

Code: Select all

ScenEdit_SetTrigger 0 : ,Error in Trigger.Time!

Re: How to set a timer

Posted: Mon Oct 21, 2024 4:33 pm
by blu3s
Mmm, maybe you need to set the format time to your locale format time

Re: How to set a timer

Posted: Tue Oct 22, 2024 6:17 pm
by Eboreg
blu3s wrote: Mon Oct 21, 2024 4:33 pm Mmm, maybe you need to set the format time to your locale format time
That... sounds like it would break if I put it on another computer.

Re: How to set a timer

Posted: Thu Oct 24, 2024 8:00 am
by blu3s
You're right


Can you try this on a new scenario?

Code: Select all

local newTime = os.date('%d/%m/%Y %H:%M:%S', ScenEdit_CurrentTime() + (5*60))
local trigger = ScenEdit_SetTrigger({description='Check For Stand Down',mode='add',type = 'Time', Time=newTime })

Re: How to set a timer

Posted: Fri Oct 25, 2024 12:06 pm
by Eboreg
It set the time to Midnight, January 1st of Year 1

Re: How to set a timer

Posted: Tue Nov 12, 2024 8:47 pm
by KLAB
https://www.matrixgames.com/forums/view ... 6&t=275815

Search on this sub forum, timer issues and the LUA text needed has been covered at length.
I'm not on PC otherwise I'd find you the LUA code myself.
Cheers
K