Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

LUA question

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> LUA question Page: [1]
Login
Message << Older Topic   Newer Topic >>
LUA question - 12/23/2018 5:51:51 PM   
mardesich

 

Posts: 62
Joined: 11/18/2002
From: United States
Status: offline
Would some one give me an example of "Activation a Mission" using LUA?
Thanks
Post #: 1
RE: LUA question - 12/23/2018 6:34:18 PM   
stilesw


Posts: 1497
Joined: 6/26/2014
From: Hansville, WA, USA
Status: offline
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


(in reply to mardesich)
Post #: 2
RE: LUA question - 12/23/2018 7:40:26 PM   
mardesich

 

Posts: 62
Joined: 11/18/2002
From: United States
Status: offline
Thanks
I didn't know about the term " isactive"[

(in reply to stilesw)
Post #: 3
RE: LUA question - 12/23/2018 8:09:27 PM   
mardesich

 

Posts: 62
Joined: 11/18/2002
From: United States
Status: offline
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.


(in reply to mardesich)
Post #: 4
RE: LUA question - 12/23/2018 8:34:00 PM   
stilesw


Posts: 1497
Joined: 6/26/2014
From: Hansville, WA, USA
Status: offline
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


(in reply to mardesich)
Post #: 5
RE: LUA question - 12/28/2018 4:46:11 PM   
mardesich

 

Posts: 62
Joined: 11/18/2002
From: United States
Status: offline
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.

(in reply to stilesw)
Post #: 6
RE: LUA question - 12/28/2018 4:59:38 PM   
stilesw


Posts: 1497
Joined: 6/26/2014
From: Hansville, WA, USA
Status: offline
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

(in reply to mardesich)
Post #: 7
RE: LUA question - 12/29/2018 3:16:38 PM   
mardesich

 

Posts: 62
Joined: 11/18/2002
From: United States
Status: offline
I still can't get it to work.
Thanks for your time and help.

(in reply to stilesw)
Post #: 8
RE: LUA question - 12/29/2018 3:32:44 PM   
stilesw


Posts: 1497
Joined: 6/26/2014
From: Hansville, WA, USA
Status: offline
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

(in reply to mardesich)
Post #: 9
RE: LUA question - 1/4/2019 3:09:11 PM   
mardesich

 

Posts: 62
Joined: 11/18/2002
From: United States
Status: offline
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.

(in reply to stilesw)
Post #: 10
RE: LUA question - 1/7/2019 2:59:47 PM   
mardesich

 

Posts: 62
Joined: 11/18/2002
From: United States
Status: offline
Can you tell me how to use the "condition" in the "Event page"?

(in reply to mardesich)
Post #: 11
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> LUA question Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

0.672