strikers_blade Posted April 13, 2020 Posted April 13, 2020 I know, it is most likely a LUA newbie 101 kind of question but the more I look into it, the more confused I am getting :( My task is stupidly simple; As soon as you start the mission, I want to announce every so hour that the server will reset in so many hours. I already do it with the mission editor with a series of trigger. I now want to move away from the triggers and code all of it into a LUA file (to minimize the triggers amount). Unless I am wrong, I should not be using MOOSE, MIST or any other 3rd party script just for such simple coding, right? If I look on HOGGIT, it gives me two options; timer.scheduleFunction or timer.getTime . First option being way more than what I actually need, I settled with the 2nd, which should be stupidly straight forward. Here is just a quick example; local countdown = timer.getTime() if countdown > 10 then trigger.action.outText("STEP 1",5) end if countdown > 20 then trigger.action.outText("STEP 2",5) end Obviously, it doesn't work. Why can't it be that simple? P.S. You are more than welcome to suggest good resource material beside lua.org and tutorialspoint.com My systems: Windows 10 64 bits I7-8700k 32.0 GB RAM 500Gb SSD Asus ROG 2080ti HP Reverb Windows 10 64 bits I7-6820HQ CPU @ 2.70Ghz 32.0 GB RAM 500Gb SSD Nvidia Quadro M4000M TrackIR 5
PravusJSB Posted April 14, 2020 Posted April 14, 2020 So timer.getTime() gets you the current mission time in seconds, as in 15:32, it's always going to be above 20, you need to reference the time first then do some maths. local timethen function myfunc() if timethen== nil then timethen= timer.getTime() end local timenow = timer.getTime() local countdown = timenow - timethen if countdown > 10 then trigger.action.outText("STEP 1",5) end if countdown > 20 then trigger.action.outText("STEP 2",5) end timer.scheduleFunction(myfunc, {}, timer.getTime() + 2) end Creator & Developer of XSAF ::An AI model that wants to kill you, and needs no help from humans. Discord: PravusJSB#9484 twitch.tv/pravusjsb https://www.patreon.com/XSAF https://discord.gg/pC9EBe8vWU https://bmc.link/johnsbeaslu Work with me on Fiverr: https://www.fiverr.com/pravusjsb
Recommended Posts