exil Posted April 23, 2022 Share Posted April 23, 2022 Gents, I kindly ask for your help here. I am looking for a command via mist or moose or dcs core script to run a script file when something happens. I have a script that will run some missions randomly when a helicopter lands into a FARP. Everything fine so far, but for simplicity reasons I rather would like to script something like: If helo lands at FARP - do script file (mission 1) I really can't find the lua command for 'do script file'. Thanks in advance! GeForce RTX 4090 Founders Edition - AMD Ryzen 7 5800X3D - 64Gb RAM - Win11 - HP Reverb G1 - Thrustmaster Warthog HOTAS (40cm extension) - VKB Sim T-Rudder MKIV Pedals Link to comment Share on other sites More sharing options...
toutenglisse Posted April 23, 2022 Share Posted April 23, 2022 3 hours ago, exil said: ...I really can't find the lua command for 'do script file'. Thanks in advance! For example here is a command I use to load a lua file to get a payload : local WMPayloads = dofile("CoreMods/aircraft/AH-64D/UnitPayloads/AH-64D_BLK_II.lua") WMPylons = WMPayloads["payloads"][2]["pylons"] But you can probably also put each of your mission script inside a function, for example : function mission1(), in the same whole script, load the script at start and then call the function you want when you want. Link to comment Share on other sites More sharing options...
LFCChameleon_Silk Posted April 23, 2022 Share Posted April 23, 2022 (edited) yeah sounds like you could just wrap the missions in a function and then just call that function from within a loaded file using a miz trigger, only lines that are outside a function will be done when you load the file filewithmissionsitit.lua function startmission(whatmission) -- arg1 is the mission to run if whatmission == 1 then --do mission 1 stuffs trigger.action.setUserFlag(1,true) end if whatmission == 2 then --do mission 2 stuffs trigger.action.setUserFlag(2,true) end end then if you wanted at anytime to trigger the flag to change just: startmission(1) but it sounds like you want to load a whole new miz, try adding the load miz as a trigger in the ME and tie it to a flag and then use the above to trigger each condition to then load a miz file. either way it should work just depends on your approach. Edited April 23, 2022 by LFCChameleon_Silk Link to comment Share on other sites More sharing options...
exil Posted April 23, 2022 Author Share Posted April 23, 2022 41 minutes ago, toutenglisse said: For example here is a command I use to load a lua file to get a payload : local WMPayloads = dofile("CoreMods/aircraft/AH-64D/UnitPayloads/AH-64D_BLK_II.lua") WMPylons = WMPayloads["payloads"][2]["pylons"] But you can probably also put each of your mission script inside a function, for example : function mission1(), in the same whole script, load the script at start and then call the function you want when you want. This is what I am looking for. Thanks a lot! I already did the latter in my current script. I wrapped each mission in a function and called it when needed. The problem here is, the script gets terribly long because I scripted like 10 mission into it. So, I would like to avoid losing myself in one single file. 37 minutes ago, LFCChameleon_Silk said: yeah sounds like you could just wrap the missions in a function and then just call that function from within a loaded file using a miz trigger, only lines that are outside a function will be done when you load the file filewithmissionsitit.lua function startmission(whatmission) -- arg1 is the mission to run if whatmission == 1 then --do mission 1 stuffs trigger.action.setUserFlag(1,true) end if whatmission == 2 then --do mission 2 stuffs trigger.action.setUserFlag(2,true) end end then if you wanted at anytime to trigger the flag to change just: startmission(1) but it sounds like you want to load a whole new miz, try adding the load miz as a trigger in the ME and tie it to a flag and then use the above to trigger each condition to then load a miz file. either way it should work just depends on your approach. That's even more simple! Sure, sometimes you are just blind for the simple stuff! Thanks a lot! GeForce RTX 4090 Founders Edition - AMD Ryzen 7 5800X3D - 64Gb RAM - Win11 - HP Reverb G1 - Thrustmaster Warthog HOTAS (40cm extension) - VKB Sim T-Rudder MKIV Pedals Link to comment Share on other sites More sharing options...
Recommended Posts