Mangrove Jack Posted June 14, 2021 Posted June 14, 2021 I have been trying to get a message out of the time when a trigger is activated with a value - say 'x' minutes - added to it. I have managed to get the time in seconds but need to convert to hrs/min and maybe sec - not sure about them, and output conversion. I was looking at local time but just yesterday realised that only zulu time is available in Hornet, so I adjust for that (4hrs on PG map). Message is advising co-op mission participants to be on target at 'X' time. I am currently putting message out as 'x' minutes to TOT. I wanted to change that to hrs minutes to help with inputting the TOT in the UFC. What I have got out currently and working is: local _missionTime = timer.getAbsTime() local _z_adj_TOT = timer.getAbsTime() - 14400+420 --this time into mission in my example from trigger at 08:00:40 and adjusts for Zulu difference of 4 hrs and ads 420 seconds. Returns 14860.801 (which is = 04.128 hrs) WORKS trigger.action.outText( 'Mission Time is: ' .._z_adj_TOT, 40 ) However I have not been able to work out how to covert to 24 hr time format and output in message. Anyone able to give any pointers? Intel i7-7700@3.6GHz 16GB NVIDIA GeForce GTX1060 6GB
toutenglisse Posted June 14, 2021 Posted June 14, 2021 1 hour ago, Mangrove Jack said: ...However I have not been able to work out how to covert to 24 hr time format and output in message. Anyone able to give any pointers? This code does it : Spoiler local _z_adj_TOT = timer.getAbsTime() - 14400+420 --this time into mission in my example from trigger at 08:00:40 and adjusts for Zulu difference of 4 hrs and ads 420 seconds. Returns 14860.801 (which is = 04.128 hrs) WORKS if _z_adj_TOT < 0 then _z_adj_TOT = 86400 + _z_adj_TOT end if _z_adj_TOT == 0 then trigger.action.outText( 'Mission Time is : 0 Hr 0 Mn 0 Sec.', 40 ) else local Hour1 = _z_adj_TOT / 3600 local Hour2 = math.floor (Hour1) local Hour3 = Hour1 - Hour2 if Hour3 == 0 then trigger.action.outText( 'Mission Time is : ' .. Hour2 .. ' Hr 0 Mn 0 Sec.', 40 ) else local Min1 = 60 / (1 / Hour3) local Min2 = math.floor (Min1) local Min3 = Min1 - Min2 if Min3 == 0 then trigger.action.outText( 'Mission Time is : ' .. Hour2 .. ' Hr ' .. Min2 .. ' Mn 0 Sec.', 40 ) else local Sec1 = 60 / (1 / Min3) local Sec2 = math.floor (Sec1) trigger.action.outText( 'Mission Time is : ' .. Hour2 .. ' Hr ' .. Min2 .. ' Mn ' .. Sec2 .. ' Sec.', 40 ) end end end 1 1
Mangrove Jack Posted June 15, 2021 Author Posted June 15, 2021 toutenglisse thank you very much, that is what I needed and I had not come across it anywhere in my searches. Intel i7-7700@3.6GHz 16GB NVIDIA GeForce GTX1060 6GB
Recommended Posts