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 1

 
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 Air / Naval Operations >> Mods and Scenarios >> Lua in Command tutorial 1 Page: [1]
Login
Message << Older Topic   Newer Topic >>
Lua in Command tutorial 1 - 11/22/2014 2:59:12 PM   
Tomcat84

 

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

I've made a tutorial in closed beta showcasing some of the basic new Lua functionality that the next patch will bring to Command. Although the patch is not out yet (and as such you cannot do anything yet with the attached scenarios in your public build), I asked the Devs and they thought it might be nice to already publish it so you guys can get a sneak preview of some of the upcoming functionality and start thinking of ideas on its usage.

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

Note that there are two bugs in this video that are already fixed, one being that in a certain script the Inherit function only worked if typed in all caps INHERIT. That is since fixed.

The other is that AddSubmarine actually added a surface ship! Also already fixed.

You can find the video tutorial HERE


The scripts used in this tutorial are:

ScenEdit_AddShip('Blue', 'USS Kidd', 960, 'DEG', 'N38.50.15', 'E6.50.00')
Adds a Ship with Database 960 (a version of the Kidd class) to the Blue side as USS Kidd at the included location

ScenEdit_SetEMCON('Side', 'Blue', 'Radar=Active')
Changes the Blue Side's radar setting to Active side wide

ScenEdit_SetEMCON('Unit', 'USS Ticonderoga', 'Radar=Passive;Sonar=Active')
Changes the unit named USS Ticonderoga Emcon to radar Passive, sonar Active

ScenEdit_AssignUnitToMission('USS Kidd', 'Transit')
Assigns the unit named USS Kidd to the mission named Transit

ScenEdit_SetEMCON('Mission', 'Transit', 'Inherit;Radar=Active')
First clears the mission Transit Emcon setting to current side settings to get a fresh start, then modifies radar to Active

ScenEdit_SetSidePosture('Blue', 'Red', 'H')
Sets the Blue side posture towards Red as hostile i.e. Blue now considers Red hostile and will engage Red units. Red still thinks everything is just fine (i.e. sees blue as neutral)

ScenEdit_SetSidePosture('Friends', 'Blue', 'N')
Sets the Friends' posture towards Blue to neutral. So No change to what Blue thinks but Friends now think Blue are just neutral and not friends anymore. Blue loses information that it previously got from Friends.

ScenEdit_SetWeather(10, 5, 0.3, 2)
Changes the weather to average temperature 10 degrees C, rainfall rate 5 (out of 50), clouds 0.3 (out of 1.0) and sea state 2 (out of 9)

ScenEdit_AddFacility('Blue', 'Base', 1592, 69, 'DEG', 'N39.18.25', 'E8.40.45')
Adds a certain single unit airfield with orientation 069 degrees

ScenEdit_AddSubmarine('Blue', 'USS Dallas', 533, 'DEG', 'N38.45.54', 'E6.43.22')
Adds a submarine at location

ScenEdit_AddAircraft('Blue', 'Viper #1', 3833, 19355, 'DEG', 'N38.20.30', 'E5.31.00')
Adds an F-16 at location with specific loadout

ScenEdit_AssignUnitToMission('USS Kidd', 'none')
Unassigns the USS Kidd from any mission



You can also find some info on how the scripts work on Baloogan's site: http://wiki.baloogancampaign.com/index.php/CommandLua

I hope you enjoy this tutorial and find it useful, and appreciate the sneak peek. Meanwhile I am working on a part 2 that will not just show the functions, but show how to implement them in a fully functioning scenario and give you an idea of what you can usefully do with it to make a more interesting AI.

Other than that let it also be noted that more Lua improvements are in the works, either for the next patch or the one that will come after. When they do show up I plan to provide additional tutorials to cover it.

Lastly let me note again for now that the attached scenarios are NOT COMPATIBLE with your current public build. You'll have to wait :)

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, or to hit play and see in three minutes what happens.

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 .

Let me know what you think!





Attachment (1)

< Message edited by Tomcat84 -- 11/22/2014 10:33:56 PM >


_____________________________

My Scenarios and Tutorials for Command

(Scenarios focus on air-warfare :) )
Post #: 1
RE: Lua in Command tutorial 1 - 11/22/2014 3:23:48 PM   
Meroka37

 

Posts: 753
Joined: 7/31/2009
Status: offline
Thanks for the work.

_____________________________

'Better honor without ships, than ships without honor"

(in reply to Tomcat84)
Post #: 2
RE: Lua in Command tutorial 1 - 11/22/2014 5:00:38 PM   
Randomizer

 

Posts: 1205
Joined: 6/28/2008
Status: online
I'll bite; what's a Lua?

-C

(in reply to Meroka37)
Post #: 3
RE: Lua in Command tutorial 1 - 11/22/2014 6:25:21 PM   
warshipbuilder


Posts: 769
Joined: 2/23/2013
From: C-eh-n-eh-d-eh
Status: offline
I think it is some kind of programming language.

_____________________________

warshipbuilder

Any ship can be a minesweeper, once.
Editor WitE2Pedia
ED/BTR Ressurection Project

(in reply to Randomizer)
Post #: 4
RE: Lua in Command tutorial 1 - 11/22/2014 6:37:45 PM   
Randomizer

 

Posts: 1205
Joined: 6/28/2008
Status: online
Ah, seen. Cannot say that I'm a huge fan of posting feature tutorials in advance of the update containing those features but thanks anyway.

-C

(in reply to warshipbuilder)
Post #: 5
RE: Lua in Command tutorial 1 - 11/22/2014 11:45:27 PM   
Vici Supreme


Posts: 541
Joined: 12/4/2013
From: Germany
Status: offline
Doesn't looks too complicated. Major thanks to you and the devs! (Especially for including the E-3G I spotted there )

Supreme

< Message edited by Supreme 2.0 -- 11/23/2014 12:45:59 AM >


_____________________________


(in reply to Randomizer)
Post #: 6
RE: Lua in Command tutorial 1 - 11/23/2014 12:33:32 AM   
nogravity

 

Posts: 26
Joined: 6/15/2012
Status: offline
I see a great potential to improve the AI. Units can now have different behavior based on the status of the game. For example, the AI side can starts off the game with 30% of aircraft in reserve. If their side is losing (number of air units loss reaches certain level), more reserve units can be re-assigned to defensive mission. Or if their side is winning, the reserve aircraft can be assigned to offensive missions.

That can create a very flexible and dynamic AI actions.

Thanks

(in reply to Vici Supreme)
Post #: 7
RE: Lua in Command tutorial 1 - 11/23/2014 1:32:14 AM   
Mgellis


Posts: 1883
Joined: 8/18/2007
Status: offline
This looks very cool. I am very eager to try out these new options. Any estimates on when the new patch/public beta will be released? A week? Two weeks?


(in reply to nogravity)
Post #: 8
RE: Lua in Command tutorial 1 - 11/23/2014 9:54:55 AM   
DeSade

 

Posts: 155
Joined: 3/1/2004
Status: offline
thank you, looks great :) I have few questions:

1. What is difference between ScenEdit_AddAircraft (ship, sub) and ScenEdit_AddUnit? Later looks more generalized with more options (heading, altitude)
2. I understand that scope of variables is local to action, so you cannot assign value in one event and use it in another, am I correct? But it could be done by ScenEdit_SetKeyValue/ScenEdit_GetKeyValue?
3. is it possible to access data regarding existing units/ref points, for example:
unit = ScenEdit_SetUnit({side="United States", name="USS Test"})
print(unit.lat,unit.lon)

anyway, i'm very impatient to try it myself :)

(in reply to Tomcat84)
Post #: 9
RE: Lua in Command tutorial 1 - 11/23/2014 10:10:10 AM   
Tomcat84

 

Posts: 1942
Joined: 7/10/2013
Status: offline
The options on baloogan's site not covered in my video were actually just added yesterday so I still have to figure those out myself haha. But yeah it looks like addunit will be a more general option that encompasses all types.

_____________________________

My Scenarios and Tutorials for Command

(Scenarios focus on air-warfare :) )

(in reply to DeSade)
Post #: 10
RE: Lua in Command tutorial 1 - 11/23/2014 2:09:11 PM   
JanMasters0n


Posts: 1111
Joined: 3/8/2006
From: Belgium
Status: offline
Along many other use, that will make template creation mucho easier, thanks a lot!

(in reply to Tomcat84)
Post #: 11
RE: Lua in Command tutorial 1 - 11/23/2014 2:13:11 PM   
mikmykWS

 

Posts: 11531
Joined: 3/22/2005
Status: offline

quote:

ORIGINAL: Mgellis

This looks very cool. I am very eager to try out these new options. Any estimates on when the new patch/public beta will be released? A week? Two weeks?




Early December most likely Mark. We dropped this on our publisher's poor production folks right in the middle of their busy season so need some time.
Thanks!

MIke

_____________________________


(in reply to Mgellis)
Post #: 12
RE: Lua in Command tutorial 1 - 11/23/2014 3:34:28 PM   
Mgellis


Posts: 1883
Joined: 8/18/2007
Status: offline
quote:

ORIGINAL: mikmyk


Early December most likely Mark. We dropped this on our publisher's poor production folks right in the middle of their busy season so need some time.
Thanks!

MIke



Thanks, Mike. Just wanted to get a general idea of the timeline. I'm already brainstorming how to take advantage of the new scripting options.

I'm guessing that, since you can set up events with a percent probability, all of these scripted actions can be set up to only happen some of the time. For example, I could add a weather action where you get a really vicious storm, and it is triggered at a certain point of time, but there is only a 20% chance of it actually happening.

Looks like you can...

* Change the weather
* Change a side's posture
* Add a unit
* Assign a unit to a mission (which I guess will automatically delete it from any other mission)
* Change EMCON for a unit, mission, side, etc.

Any others? For example, can you modify other aspects of ROEs too or is that something coming in the future?

Thanks again to the developers for all your work on this. This game just keeps getting better and better.



< Message edited by Mgellis -- 11/23/2014 4:34:53 PM >

(in reply to mikmykWS)
Post #: 13
RE: Lua in Command tutorial 1 - 11/23/2014 5:41:06 PM   
Meroka37

 

Posts: 753
Joined: 7/31/2009
Status: offline
erased

< Message edited by Meroka37 -- 11/23/2014 6:41:55 PM >


_____________________________

'Better honor without ships, than ships without honor"

(in reply to Mgellis)
Post #: 14
RE: Lua in Command tutorial 1 - 11/23/2014 6:39:57 PM   
Mgellis


Posts: 1883
Joined: 8/18/2007
Status: offline

quote:

ORIGINAL: Mgellis

Looks like you can...

* Change the weather
* Change a side's posture
* Add a unit
* Assign a unit to a mission (which I guess will automatically delete it from any other mission)
* Change EMCON for a unit, mission, side, etc.



Among other things, this lets you model seizures a lot more easily...

* Trigger <-- remain within one mile of a smuggler, using reference points made relative to the smuggler's ship to define the area, for more than 30 minutes (this lets you model a boarding action)

* Action <-- change posture of side:smuggler1 to friendly (because your boarding party is now running things)

* Action <-- assign unit:smuggler1 to new mission (perhaps a support mission with one or two reference points that represent a holding area at a friendly port)

* Action <-- award points to side:USCG

Smuggler1, having been boarded, will now change its posture, so you know where it is at all times, and will be on its way to a friendly port where it will eventually be put up for auction

In the same way, one can design missions where one can chase off people violating territorial waters...if you get close enough for long enough, they drop whatever mission they were on (e.g., patrol:sea control) and are assigned to a new mission that takes them out of the area. You can even set up the scenario where you will get more points for finding a non-violent way to solve a problem than you get for just sinking people.

(in reply to Mgellis)
Post #: 15
RE: Lua in Command tutorial 1 - 11/23/2014 10:09:33 PM   
SpacePope

 

Posts: 4
Joined: 11/4/2014
Status: offline

quote:

ORIGINAL: Randomizer

I'll bite; what's a Lua?

-C

Lua's a scripting language that's embedded in a ton of applications. Obviously for CMANO, it would come with functions like the ones shown in the OP that let you create units with defined values, dictate the weather, etc.

(in reply to Randomizer)
Post #: 16
RE: Lua in Command tutorial 1 - 11/24/2014 9:54:32 AM   
ojms


Posts: 225
Joined: 9/16/2014
Status: offline
Is it possible to use this to modify a platform, such as add sensors to an aircraft/ship? Especially as an modifications to aircraft don't stay once they land and launch again.

Thanks.

(in reply to SpacePope)
Post #: 17
RE: Lua in Command tutorial 1 - 11/25/2014 7:01:43 PM   
Tomcat84

 

Posts: 1942
Joined: 7/10/2013
Status: offline

quote:

ORIGINAL: Supreme 2.0
(Especially for including the E-3G I spotted there )


Good eye

_____________________________

My Scenarios and Tutorials for Command

(Scenarios focus on air-warfare :) )

(in reply to Vici Supreme)
Post #: 18
RE: Lua in Command tutorial 1 - 12/9/2014 12:47:24 PM   
cf_dallas


Posts: 303
Joined: 4/13/2006
From: Grapevine, TX
Status: offline

quote:

ORIGINAL: Mgellis

Among other things, this lets you model seizures a lot more easily...

* Trigger <-- remain within one mile of a smuggler, using reference points made relative to the smuggler's ship to define the area, for more than 30 minutes (this lets you model a boarding action)

* Action <-- change posture of side:smuggler1 to friendly (because your boarding party is now running things)

* Action <-- assign unit:smuggler1 to new mission (perhaps a support mission with one or two reference points that represent a holding area at a friendly port)

* Action <-- award points to side:USCG

Smuggler1, having been boarded, will now change its posture, so you know where it is at all times, and will be on its way to a friendly port where it will eventually be put up for auction

In the same way, one can design missions where one can chase off people violating territorial waters...if you get close enough for long enough, they drop whatever mission they were on (e.g., patrol:sea control) and are assigned to a new mission that takes them out of the area. You can even set up the scenario where you will get more points for finding a non-violent way to solve a problem than you get for just sinking people.



I love the scenarios you cook up, and the creative ways you always use the tools the devs are giving us. Keep up the awesome work.


_____________________________

Formerly cwemyss

(in reply to Mgellis)
Post #: 19
RE: Lua in Command tutorial 1 - 12/27/2014 1:05:52 AM   
Maromak


Posts: 997
Joined: 12/26/2007
From: Australia
Status: offline
Thanks TC. Very helpful.

_____________________________

Certa Cito

(in reply to cf_dallas)
Post #: 20
RE: Lua in Command tutorial 1 - 12/28/2014 12:02:46 AM   
Primarchx


Posts: 2943
Joined: 1/20/2013
Status: online
Any options for joining a unit to a group using Lua? How about units switching sides? Thanks!

< Message edited by Primarchx -- 12/28/2014 1:03:41 AM >

(in reply to Maromak)
Post #: 21
RE: Lua in Command tutorial 1 - 12/29/2014 10:41:21 AM   
Tomcat84

 

Posts: 1942
Joined: 7/10/2013
Status: offline
Glad you guys found it useful!

Both good ideas Primarchx! Possibly for the future? I know unit switching sides has already been requested.

_____________________________

My Scenarios and Tutorials for Command

(Scenarios focus on air-warfare :) )

(in reply to Primarchx)
Post #: 22
RE: Lua in Command tutorial 1 - 12/29/2014 1:56:18 PM   
Primarchx


Posts: 2943
Joined: 1/20/2013
Status: online
The idea I had was to use the unit joining a group to do dynamic resupply for ground elements, like air defense. Let's say you have logistics trucks with SAMs driving to your ADA sites each night. When they arrive they join the ADA site group, reload missiles, unjoin the group and return to their origin. I can do this manually now, of course.

Switching sides would be good for capturing ground facilities like airbases, and of course capturing pirate vessels, et al.

(in reply to Tomcat84)
Post #: 23
RE: Lua in Command tutorial 1 - 12/30/2014 10:36:43 AM   
thewood1

 

Posts: 4011
Joined: 11/27/2005
Status: offline
Not sure if it does everything for you, but you could switch sides by deleting the unit on one side and then immediately adding a duplicate on the other side. Then you can use other logic to award points for capture.

(in reply to Primarchx)
Post #: 24
RE: Lua in Command tutorial 1 - 12/31/2014 5:19:38 AM   
Primarchx


Posts: 2943
Joined: 1/20/2013
Status: online
With the Lua change posture scripts you can sort of capture an airbase now. The best way I've found is to make 'capturable' airbases a separate side that are allied with the OpFor. When you 'capture' the base, it becomes allied with you. Of course any enemy aircraft stationed there are still there - unflyable as far as I can tell but using ramp and hangar space. You also have to have a way of getting ordnance for your aircraft there, which can be done by teleporting in the appropriate munitions bunkers and (manually) grouping them with the new airbase ... which is another reason to have a Lua script that can create/add to groups!

(in reply to thewood1)
Post #: 25
RE: Lua in Command tutorial 1 - 3/8/2015 12:57:19 AM   
tjhkkr


Posts: 2345
Joined: 6/3/2010
Status: offline
Thank you very much for this! I have been playing with the editor, but this solidifies a lot.

_____________________________

Remember that the evil which is now in the world will become yet more powerful, and that it is not evil which conquers evil, but only love -- Olga Romanov.

(in reply to Primarchx)
Post #: 26
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Air / Naval Operations >> Mods and Scenarios >> Lua in Command tutorial 1 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.137