Jump to content

Call script from other script

Recommended Posts



Is there a way to call a script from another script which is placed inside the mission file? The idea is as follows: I want to use a generic init.lua file that you load in the mission init. Then, as soon as mission starts the init.lua will execute the other scripts on its own.


This is an alternative to avoid having to use the dofile for each single lua file I want to run using the triggers and be able to pack all the scripts inside a folder in the mission.


Problem I faced is that I can´t access the mission itself from the init.lua. If I try to read the mission path with debug.getinfo( 1, "S" ).source it points to the location of the temporary file created when you run the mission, but not to the content of the file itself.



Edited by geloxo

Windows 10 64bit, i7 5930K OC 4.2 GHz, AMD 295x2, 16 Gb DDR4

Link to comment
Share on other sites

env.mission is it the mission file and it is accessible via init. This is how mist compiles a list of all of the units within a mission.


The order of operations so to speak of various script files is the following:


1. Initialization

2. "Group Activate condition" - That text box next to the groups activation %, you can run a function that is run in the initialization script assuming it is global.

3. Trigger Mission Start> Time Less than 5> Do Script

4. Do script/Do Script File via waypoint action of the first waypoint on a spawned group

5. Trigger Once> Time more 0> Do Script

The right man in the wrong place makes all the difference in the world.

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

Thanks Grimes, but I can´t understand how should I use this env.mission. As far as I have seen in mist I could access coalitions and those variables for instance from there, but this seems not to be what I need.


Imagine I have a folder "scripts" with my "test.lua" script inside it and I place that folder inside the miz file via winzip. Then I run whatever the script at the mission init (let´s say a script called "initmyscripts.lua"). Then how could I call the "test.lua" from the "initmyscripts.lua"?

Windows 10 64bit, i7 5930K OC 4.2 GHz, AMD 295x2, 16 Gb DDR4

Link to comment
Share on other sites


  • Recently Browsing   0 members

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