Jump to content

Recommended Posts

Posted

Hi all!

 

Is it possible to, via scripting, make the mission automatically set mission time and date to computers current time and date?

 

Cheers!

Posted

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.

Posted

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!

Posted

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.

  • 4 months later...
Posted

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.

Posted (edited)

Great! Thank you :)

 

E: mist.time.getDHMS() makes the script crash though, timer.getAbsTime() is a good alternative it seems.

Edited by Coug4r

-

If man were meant to fly he'd be filled with helium.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...