Frenchy Posted May 25, 2015 Share Posted May 25, 2015 Hi, why i cannot use GetDevice(0) inside mission lua script and i can do that in export.lua. another question. via a lua script inside mission is it possible to send data to udp server like inside export.lua? i am trying to execute require "socket" but problem -> nil so it seems we cant do the same things in export.lua and with script inside the mission? Frenchy Link to comment Share on other sites More sharing options...
FSFIan Posted May 25, 2015 Share Posted May 25, 2015 (edited) Note for future readers (because EDGE is right around the corner): the following applies to DCS: World 1.2.x There are several isolated Lua Environments in DCS: World. Disclaimer: I don't claim to fully understand this and I don't know if the following list is complete or not. I got to the understanding I have now mostly by reading the SlMod source code and experimentation. I think Speed knows a lot more about this. The mission environment is where mission scripts run. Because the mission script is untrusted code, the set of available Lua modules is restricted (most notably, access to the "os", "io" and "lfs" modules and the "require" function is removed). That prevents a mission file (which you may have downloaded from the internet for example) from being able to delete all your files or turn your PC into a spambot. You can remove those restrictions by editing the "Scripts\MissionScripting.lua" file (sometimes called the "sanitation module") in your DCS: World installation directory. The server environment is the one that the code in "Saved Games\DCS\Scripts\net\server.lua" is executed in. It provides hook functions to be notified of events in a multiplayer server, such as players joining and leaving. It is also the only environment I know of that has a way of interacting with the other ones (the net.dostring_in function). SlMod uses that function and a modded MissionScripting.lua file to set up UDP communication between the "server" and the "mission" environment to make more information and features available to mission scripts. The export environment is the one where Export.lua executes. It has access to functions that return information about the player's current aircraft. For aircraft with a clickable cockpit, it also has access to all the indicators and switches in the cockpit and can simulate user input. via a lua script inside mission is it possible to send data to udp server like inside export.lua? i am trying to execute require "socket" but problem -> nil This requires editing the MissionScripting.lua file that is responsible for setting up the environment that mission scripts run in. Everyone who wants to host your mission will have to do the same edits on their server. While simply commenting out the line that removes access to the "require" function will work, it will also make the server vulnerable to malicious mission files. If you do that, you need to make sure to only run missions from trusted sources. A better way is to make a global function available that does the privileged work (such as communication over a network or writing to a specific file) but still remove access to the modules after that function has been defined. The function can keep a local reference to the module(s) it needs. Edited May 25, 2015 by [FSF]Ian DCS-BIOS | How to export CMSP, RWR, etc. through MonitorSetup.lua Link to comment Share on other sites More sharing options...
Frenchy Posted May 25, 2015 Author Share Posted May 25, 2015 Thanks for your answer, i understand better the different Environments in DCS. very good explanation!! Link to comment Share on other sites More sharing options...
Amine Posted January 14, 2021 Share Posted January 14, 2021 How we can export data in mission editor with export.lua in saved games \DCS\Scripts\export.lua ??!! Link to comment Share on other sites More sharing options...
Recommended Posts