Mistermann Posted January 23, 2023 Posted January 23, 2023 This should be trivial. Unfortunately, my limited programming skills are hampering my ability to solve this. Essentially, I have this challenge for a racing mission I put together for my pals 1) Capture the time an aircraft crosses a start line (zone) using DO SCRIPT 2) Capture the time that aircraft crosses a finish line (different zone) using DO SCRIPT 3) Subtract #1 from #2 and output to screen using same DO SCRIPT from #2 My poor understanding of LUA isn't allowing the math operation on #3. I can post the mission if its easier. Its basically 2 triggers that I currently have on timers so they fire and there's no requirement to fly/enter the trigger zones. Start trigger local _StartTime = timer.getTime() -- Put start time into variable local _CharacterTime = mist.getClockString(_StartTime) trigger.action.outTextForGroup(1, _CharacterTime, 30, false) -- Print start time to screen for debugging End Trigger local _FinishTime = timer.getTime() -- Put finish time into variable local _ElapsedTime = (_FinishTime - _StartTime) -- Calculate Elapsed Time (this is the command that crashes scripting engine) local _CharacterTime = mist.getClockString(_ElapsedTime) trigger.action.outTextForGroup(1, _CharacterTime, 30, false) --Print ET to screen for debugging How do I perform this subtraction of variables captured at different times in the mission by different DO SCRIPT events? Also, I am using MIST because I saw some other posts using it. I do NOT have to use it. Simply looking for the easiest way in which to do this. Thanks!! System Specs: Spoiler Callsign:Kandy Processor:13th Gen Intel(R) Core(TM) i9-13900K - RAM: 64GB - Video Card: NVIDIA RTX 4090 - Display: Pimax 8kx VR Headset - Accessories: VKB Gunfighter III MCG Ultimate, VKB STECS Standard, Thrustmaster TPR Pedals, Simshaker JetPad, Predator HOTAS Mounts, 3D Printed Flight Button Box Video Capture Software: Open Broadcaster Software (OBS), Video Editing Software: PowerDirector 35 Into The Jungle (MP Mission) F18: Scorpion's Sting Apache Campaign - Griffins Kiowa Campaign - Assassins
Solution Kanelbolle Posted January 23, 2023 Solution Posted January 23, 2023 (edited) Without trying to check your script if it works, you can't use "local" if you are going to pass a variable to another script... Also If you are track the time of multiple planes, you need multiple variables or an array saving the times. Edited January 23, 2023 by Kanelbolle WARGAMES Servers: https://forum.dcs.world/topic/301046-wargames-server-pvp-and-pve-campaign-servers/ Scripts: RGC & SPGG https://github.com/AGluttonForPunishment/
Mistermann Posted January 24, 2023 Author Posted January 24, 2023 (edited) 20 hours ago, Kanelbolle said: Without trying to check your script if it works, you can't use "local" if you are going to pass a variable to another script... Man, I'm an idiot. I should haven known better. Thanks for the reminder. This works fine now. Posting the code so anyone in the future looking to do this has the answer as well. Start Trigger _StartTime = timer.getTime() _CharacterTime = mist.getClockString(_StartTime) trigger.action.outTextForGroup(1, _CharacterTime, 30, false) End Trigger _FinishTime = timer.getTime() _ElapsedTime = (_FinishTime - _StartTime) _CharacterTime = mist.getClockString(_ElapsedTime) trigger.action.outTextForGroup(1, _CharacterTime, 30, false) 20 hours ago, Kanelbolle said: Also If you are track the time of multiple planes, you need multiple variables or an array saving the times. Roger that. Probably not going that complex, but will definitely keep in mind should I want to expand the feature set. Thanks so much for the help! Edited January 24, 2023 by Mistermann 1 System Specs: Spoiler Callsign:Kandy Processor:13th Gen Intel(R) Core(TM) i9-13900K - RAM: 64GB - Video Card: NVIDIA RTX 4090 - Display: Pimax 8kx VR Headset - Accessories: VKB Gunfighter III MCG Ultimate, VKB STECS Standard, Thrustmaster TPR Pedals, Simshaker JetPad, Predator HOTAS Mounts, 3D Printed Flight Button Box Video Capture Software: Open Broadcaster Software (OBS), Video Editing Software: PowerDirector 35 Into The Jungle (MP Mission) F18: Scorpion's Sting Apache Campaign - Griffins Kiowa Campaign - Assassins
Wrecking Crew Posted February 8 Posted February 8 Say, this thread helped me to code a stopwatch -- these each run with a Do Script. Thank you for the info! -- Stopwatch Start Time _StartTime = timer.getTime() _StartTimeClock = mist.getClockString(_StartTime) trigger.action.outText("The NAVEX Start Time is " .. _StartTimeClock, 10) -- Print start time to screen for debugging -- Stopwatch Stop Time _StopTime = timer.getTime() _StopTimeClock = mist.getClockString(_StopTime) trigger.action.outText("The NAVEX Stop Time is " .. _StopTimeClock, 10) -- Print stop time to screen for debugging -- Elapsed Time _ElapsedTimeClock = mist.getClockString(_StopTime - _StartTime) -- Calculate Elapsed Time trigger.action.outText("The NAVEX Elapsed Time is " .. _ElapsedTimeClock, 10) --Print ET to screen for debugging -- Mission Complete local msg = {} msg[#msg + 1] = 'The NAVEX is complete!\n' msg[#msg + 1] = 'Good job Blue.\n' msg[#msg + 1] = '\n' msg[#msg + 1] = '---\n' msg[#msg + 1] = '\n' msg[#msg + 1] = 'The NAVEX Stop Time is ' .. _StopTimeClock .. '!\n' msg[#msg + 1] = '\n' msg[#msg + 1] = 'The NAVEX Elapsed Time is ' .. _ElapsedTimeClock .. '.\n' msg[#msg + 1] = '---\n' msg[#msg + 1] = '\n' msg[#msg + 1] = 'Use the Radio F10 Menu for mission options.' msg[#msg + 1 ]= '\n' trigger.action.outText(table.concat(msg), 24) 1 Visit the Hollo Pointe DCS World server -- an open server with a variety of COOP & H2H missions including Combined Arms. All released missions are available for free download, modification and public hosting, from my Wrecking Crew Projects site.
Mistermann Posted February 9 Author Posted February 9 Haaaa. Completely forgot I even asked this question and have no idea what I was using it for. Adding to my "script code to know" file. 1 System Specs: Spoiler Callsign:Kandy Processor:13th Gen Intel(R) Core(TM) i9-13900K - RAM: 64GB - Video Card: NVIDIA RTX 4090 - Display: Pimax 8kx VR Headset - Accessories: VKB Gunfighter III MCG Ultimate, VKB STECS Standard, Thrustmaster TPR Pedals, Simshaker JetPad, Predator HOTAS Mounts, 3D Printed Flight Button Box Video Capture Software: Open Broadcaster Software (OBS), Video Editing Software: PowerDirector 35 Into The Jungle (MP Mission) F18: Scorpion's Sting Apache Campaign - Griffins Kiowa Campaign - Assassins
Recommended Posts