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 in Command tutorial 2

 
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 in Command tutorial 2 Page: [1]
Login
Message << Older Topic   Newer Topic >>
Lua in Command tutorial 2 - 12/8/2014 7:04:50 PM   
Tomcat84

 

Posts: 1952
Joined: 7/10/2013
Status: offline
Hey all,

I've made another tutorial in closed beta showcasing some of the new Lua functionality that the 1.06 patch brings to Command. Compared to the first tutorial this one goes more in depth on practical usage of some of the new Lua functions and also shows a few non-Lua related tricks that you can use to build better scenarios.

The functionality mostly applies to scenario designers as it gives more tools to build an interesting AI opponent. So if you only play scenarios and dont build any you might find it less interesting, but still, you could get an idea of what you can face in future scenarios.



You can find the video tutorial HERE


Functionality showcased in this tutorial is as follows:

- Making a CAP change mission to become more aggressive once approached
- Having a 50% chance of an AWACS being added when the scen is loaded
- Removing radar information from fighters when the Fighter HQ is bombed (permanently or coming back online after X amount of minutes)
- Making tanks become detectable to the player side when crossing into an area
- Making those tanks retreat once they reach a certain amount of damage together
- Randomizing whether an SA-2 site is dumb with radar on or smart with radar off and a prosecution area at scen load
- Randomly adding either an SA-3, SA-6 or SA-8 at a location
- Randomly adding either an SA-3, SA-6 or SA-8 at a location with 40% chance for 3 or 6 and 20% for the 8
- Randomizing which CAPs a group of MiG-29s goes to
- Having the weather improve over time with slight amount of randomness
- Showing how to have a strike mission marshal somewhere first before
- Randomly selecting which target they go to.
- A few things with the EW radars
- Having SAMs go active once too many EW Radars are taken out
- Having SAMs go active when the SAM HQ is bombed
- Having SAMs go passive again when HQ backup is online after X minutes, UNLESS they were already active because EW radars were taken out


You can also find some info on how the scripts work on Baloogan's site:

http://wiki.baloogancampaign.com/index.php/CommandLua

as well as this great documentation by CKFinite:

http://commandlua.github.io/

I hope you enjoy this tutorial and find it useful.

Other than that let it also be noted that more Lua improvements are either included already in 1.06 or in the works for future patches, and this tutorial does not cover all of them.

Lastly let me note again for now that the attached scenarios are NOT COMPATIBLE with your current public build. You'll have to wait ever so briefly until 1.06 is released very soon! :)

But once you have it, you'll find there is one base scenario that the tutorial starts with, and one completed one that has everything setup and which you can reference in case something doesn't work, as well as a txt document with the scripts.

The video features time links to the parts that cover specific scripts in the description (hit show more) in case my excessive talking bores you and at the start in the video itself.

One important thing to note about the scripts as they are used in this tutorial is that if a unit dies and is then called upon in a script, there will be an error and any units after it in the script wont get their command. So if going exactly by this tutorial, try to think about whether a unit might die or not before the Lua event is executed.

One possible workaround example is posted by Baloogan here: http://forum.baloogancampaign.com/viewtopic.php?f=10&t=87

Attachment (1)

< Message edited by Tomcat84 -- 12/8/2014 8:35:51 PM >


_____________________________

My Scenarios and Tutorials for Command

(Scenarios focus on air-warfare :) )
Post #: 1
RE: Lua in Command tutorial 2 - 12/16/2014 5:40:38 PM   
GlassHoppa

 

Posts: 8
Joined: 12/16/2014
Status: offline
Tomcat:

Thank you very much for this tutorial, really going in-depth on what LUA can do for our scenarios. I thought that your using the "side points" and moving markers in and out of target areas were especially ingenious ways of triggering events.

Question - can you use persistent values with ScenEdit_SetKeyValue()/ ScenEdit_GetKeyValue() ? By persistent, I mean between events.... Event A fires, stores a value, once value gets big enough it triggers Event B.. Same way that you are using the side points.

Thanks again!

(in reply to Tomcat84)
Post #: 2
RE: Lua in Command tutorial 2 - 12/16/2014 11:20:00 PM   
Gunner98

 

Posts: 5508
Joined: 4/29/2005
From: The Great White North!
Status: offline
Tomcat:

Very helpful and very clear, many clever ideas planted. Thanks a bunch, now its just a matter of biding our time until we can unleash this new capabilities on unsuspecting players out there

B

(in reply to GlassHoppa)
Post #: 3
RE: Lua in Command tutorial 2 - 12/17/2014 5:27:47 PM   
ckfinite

 

Posts: 377
Joined: 7/20/2013
Status: offline
See: http://commandlua.github.io/#ScenEdit_SetKeyValue

The lua state also persists between events but is lost when the scenario is reloaded, whereas the key storer is not.

(in reply to GlassHoppa)
Post #: 4
RE: Lua in Command tutorial 2 - 12/17/2014 5:51:20 PM   
DeSade

 

Posts: 156
Joined: 3/1/2004
Status: offline

quote:

ORIGINAL: GlassHoppa

Question - can you use persistent values with ScenEdit_SetKeyValue()/ ScenEdit_GetKeyValue() ? By persistent, I mean between events.... Event A fires, stores a value, once value gets big enough it triggers Event B..



I would add to ckfinite answer that mentioned persistent values can be used by different events, but cant trigger event by themselves - at least not in current build imho

(in reply to GlassHoppa)
Post #: 5
RE: Lua in Command tutorial 2 - 12/17/2014 9:04:55 PM   
GlassHoppa

 

Posts: 8
Joined: 12/16/2014
Status: offline
Thank you ckfinite and DeSade (nice nick...)! Yeah, now that I have 1.06 loaded up it's pretty obvious that you cant use persistent values to trigger events. At least not directly, what I can see doing is nesting the PersistentKeyValue check within an action:

"if TRIGGER then ACTION"

where the ACTION is a luascript:

"If(PERSISTENTKEY>VALUE) then (DO SOMETHING)'.

Lots of experimentation ahead! Another question, perhaps answered before, do multiple triggers in an event have an "AND" relationship or an "OR" relationship?


(in reply to DeSade)
Post #: 6
RE: Lua in Command tutorial 2 - 12/17/2014 9:14:51 PM   
Tomcat84

 

Posts: 1952
Joined: 7/10/2013
Status: offline
for now multiple triggers always have an OR relation ship in the event editor. Request for more is known to the devs. If you can find common ground in one trigger then you can use and or and if stuff in the actual lua script.

_____________________________

My Scenarios and Tutorials for Command

(Scenarios focus on air-warfare :) )

(in reply to GlassHoppa)
Post #: 7
RE: Lua in Command tutorial 2 - 12/17/2014 9:31:26 PM   
GlassHoppa

 

Posts: 8
Joined: 12/16/2014
Status: offline
Thanks for the quick reply! Patience in all things, I'm very happy with 1.06 so far and can certainly wait for "AND", "XOR", etc

(in reply to Tomcat84)
Post #: 8
RE: Lua in Command tutorial 2 - 12/18/2014 10:19:54 PM   
snowburn


Posts: 188
Joined: 9/24/2013
From: Bovril, Argentina
Status: offline
is any way to get the GUID of the aircrafts/boats attached to a parent unit?
i need something like this (random proficiency for each a/c) :


arr_unit=get_uid_child_units('airbase1')
for index, unit_id in ipairs(arr_unit) do
ScenEdit_SetUnit ({unit_id, proficiency = math.random(0, 4) })
end

(in reply to GlassHoppa)
Post #: 9
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua in Command tutorial 2 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

1.125