EasyEB Posted May 4, 2015 Posted May 4, 2015 Hi all! Is it possible to, via scripting, make the mission automatically set mission time and date to computers current time and date? Cheers!
FSFIan Posted May 4, 2015 Posted May 4, 2015 Let me answer this in two parts. (1) Can we get the system date and time from Lua? Lua has os.date() and os.time(), but mission scripts do not have access to the os module (because you don't expect a mission file that you have downloaded from the internet to host on your server to be able to read and modify every file your user has access to). This protection can be disabled by modifying the MissionScripting.lua file in your the DCS: World installation. (2) Can a Lua script set the mission's date and time? As far as I know, no. I don't want to say "this is impossible", because if you are willing to accept arbitrarily complex and convoluted workarounds very few things are truly impossible, but there is no direct way to do it. One such impractical workaround could be to edit the .miz file at mission start and then switch tot the modified mission. DCS-BIOS | How to export CMSP, RWR, etc. through MonitorSetup.lua
EasyEB Posted May 4, 2015 Author Posted May 4, 2015 Thanks for your answer! The mission I want this function for is my own mission which I play from the mission editor so I guess it's not simpler than me editing the time to match current time. In a dream world though, wouldn't it be cool if the missions could read current time, date and weather data and put it in the sim? One can dream :) Thanks again!
FSFIan Posted May 4, 2015 Posted May 4, 2015 You could write a separate program that you run before starting the mission. Such a program (written in whatever language you are most comfortable with) could get weather data from the internet and the current date and time from the system and edit the mission to match this. DCS mission files are ZIP archives. The most important file in that archive is called "mission" and is a serialized Lua table, which you can manipulate fairly easily either by writing your program in Lua or by embedding a Lua interpreter. To find out how to modify that data structure, you can change the setting in the mission editor, save the mission and then look at what changed. DCS-BIOS | How to export CMSP, RWR, etc. through MonitorSetup.lua
Coug4r Posted September 8, 2015 Posted September 8, 2015 And how about reading the mission time, the one that is visible when viewing the map for example, can it be read? - If man were meant to fly he'd be filled with helium.
Grimes Posted September 8, 2015 Posted September 8, 2015 timer.getAbsTime() returns the current mission time in seconds. With mist 3.7 I added a few time related functions for displaying the date/time. 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
Coug4r Posted September 9, 2015 Posted September 9, 2015 (edited) Great! Thank you :) E: mist.time.getDHMS() makes the script crash though, timer.getAbsTime() is a good alternative it seems. Edited September 9, 2015 by Coug4r - If man were meant to fly he'd be filled with helium.
Recommended Posts