JedimasterLu Posted April 20, 2023 Posted April 20, 2023 I'm trying to export data through Export.lua file. I read the example but couldn't find a function returning the velocity of all the units. Therefore, I wonder if I can manually calculate the velocity base on the difference between the position in each frame. In order to calculate the velocity, I have got to know the time between each simulation frames. Is it a constant value like 60? Or is it the actual FPS of the game? And are there other ways to get velocity of an object by its ID in Export.lua? Thanks for all the help!
Solution Grimes Posted April 20, 2023 Solution Posted April 20, 2023 My experience with export is limited, but IIRC there is no "schedule function" to make sure something runs in X seconds from now or anything like that. But what you can do is use onSimulationFrame to check the time between it was last run and you can then execute functionality every x seconds rather than every single frame. It might aim for 60, but its best to sample the time each time it is run and check the difference. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum
JedimasterLu Posted April 20, 2023 Author Posted April 20, 2023 16 minutes ago, Grimes said: sample the time each time it is run and check the difference. Thanks! I find a function called, LoGetModelTime() -- returns current model time (args - 0, results - 1 (sec)) and it do return the actual time!
PravusJSB Posted April 20, 2023 Posted April 20, 2023 On your client side instance it will depend on your FPS, on a dedicated server its a fixed time, 0.0154 the last time i checked. 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