LUA question (Full Version)

All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion



Message


mardesich -> LUA question (12/23/2018 5:51:51 PM)

Would some one give me an example of "Activation a Mission" using LUA?
Thanks




stilesw -> RE: LUA question (12/23/2018 6:34:18 PM)

mardesich,

Two ways to accomplish this:

1. Create a mission called “Building Strike” and set it to inactive.
2. Some trigger condition such as an aircraft enters a specified area.
3. This will fire the activation event: local mission = ScenEdit_SetMission(“Building Strike”,{isactive=true})

Or, without Lua:
1. Same mission set to inactive.
2. Under “Event Actions” select “Change Mission Status”.
3. Use the same trigger condition.
4. Create an event with this trigger and the event.
5. When the trigger is activated the action will fire thus activating the event and activating the action.

Hope this helps.

-Wayne





mardesich -> RE: LUA question (12/23/2018 7:40:26 PM)

Thanks
I didn't know about the term " isactive"[




mardesich -> RE: LUA question (12/23/2018 8:09:27 PM)

ScenEdit_SetMission("B52 Recon",{isactive=true})
ERROR: [string "Console"]:1: invalid arguments to method cal
I still seem to have a error.
Thanks for your help.





stilesw -> RE: LUA question (12/23/2018 8:34:00 PM)

You need to have a variable for the result of the function call. In this case:

local x = ScenEdit_SetMission("B52 Recon",{isactive=true}). This would allow you to check the value of x for an error code. Likely won't need it but it has to be there.

-Wayne





mardesich -> RE: LUA question (12/28/2018 4:46:11 PM)

x=ScenEdit_SetMission('USA', 'b52 recon',{isactive=False})
print(x)
I have tried this with "True" and "False"
I think the LUA Script is OK, but the B52 recon mission status does not respond.
Any Ideas? Thanks for all of your help.




stilesw -> RE: LUA question (12/28/2018 4:59:38 PM)

mardesich,

This is one of those cases where the Lua documentation is perhaps not as clear as it could be. Unfortunately, case sensitive Lua, "True" does not equal "true" which it probably should. Try your code using lower case for "true" and "false". That works for me.

x=ScenEdit_SetMission('USA', 'b52 recon',{isactive=false})

Let me know if this fixes the problem.

-Wayne




mardesich -> RE: LUA question (12/29/2018 3:16:38 PM)

I still can't get it to work.
Thanks for your time and help.




stilesw -> RE: LUA question (12/29/2018 3:32:44 PM)

Hmmm. Well, just tested this Lua code and works works successfully.

local mission = ScenEdit_SetMission('Iraq','Chemical Attack - Tabuk (13:00 - 14:00)',{isactive=true})

So, could your mission name be an issue - exact spelling & upper/lower case? Try executing the code in the Lua console. If there is a problem then you should get an error message pointing to what it is.

If you like, either publicly or as a PM, you can upload the scenario as a "zip" file and I'll take a look at it.

-Wayne




mardesich -> RE: LUA question (1/4/2019 3:09:11 PM)

My file was corrupted. There were two names the same for two different units which were in two different sides. Working now!
Thanks for all your help.




mardesich -> RE: LUA question (1/7/2019 2:59:47 PM)

Can you tell me how to use the "condition" in the "Event page"?




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.90625