Integrated in Command version 1.06, the Lua scripting language is a new “Event Action” type in the Scenario Editor’s established Event Engine allowing for altering elements of the running scenario. Baloogan, Tomcat and ckfinite have produced an excellent documentation explaining how to use Lua in Command scenarios. What I want to share with you here is my non-advanced user experience of using Lua language as a force multiplier to simplify repetitive work during the scenario design phase.

Using Lua allowed me to get time-consuming tasks done way faster, for example like placing units or reference points in a circle around a facility.

To obtain that result, I simply got on Baloogan Campaign Forum, in the RP Reference Point Drawing Toolkit thread, to copy the draw_circle_of_units function, adapted it to my case by looking up the ID of the unit I want to position around the facility in the ingame Database Viewer.

Here I want to place some Crotale short-range anti-air missile batteries, ID 62, so the function is now:

function draw_circle_of_units(a,b,t,txt) if txt == nil then txt = "" end t = t - 1 lat1 = a.latitude lon1 = a.longitude lat2 = b.latitude lon2 = b.longitude dlat = math.abs (lat2-lat1) dlon = math.abs (lon2-lon1) r = math.sqrt (dlat*dlat + dlon*dlon) for i=0,t-1 do th = 2 * math.pi * i / t rlat = lat1 + r * math.sin (th) rlon = lon1 + r * math.cos (th) ScenEdit_AddUnit({ side= 'PlayerSide' , type = 'Facility' , dbid = 62, name=txt, lat=rlat, lon=rlon, heading = th * 180.0 / 3.14159}) end end

I paste it in Command’s Lua Script Console and press Run button so it knows it.

Then I also adapt the statement provided by ckfinite to the number of such units and the name I want for them:

local unit = ScenEdit_GetUnit({name=”BA 133 Nancy-Ochey”,side=”France”})

draw_circle_of_units({latitude=unit.latitude, longitude=unit.longitude},{latitude=unit.latitude + .1, longitude=unit.longitude}, 6, “EDSA 9/50”)

Note that “BA 133 Nancy-Ochey” is the name of the facility around which the Crotale batteries will organised, and France is the side on which the facility is and “+ .1” mean that the radius will be about 11 km (more on that here).

Then, as you may guess, I paste that statement in the Lua Script Console and run it.

Voila! Simple, isn’t it?

Now, using the same technique, let’s look at another simple example: how to draw a circle of reference point around a facility.

Here I used the reference points to establish a No-Navigation Zones around neutral airports.

So, as above, I simply go get the function on Baloogan Campaign Forum, in the RP Reference Point Drawing Toolkit thread, draw_line here, directly paste it in he Lua Script Console and Run it so Command knows it.

Then I get the statement ckfinite provided and adapted it to:

local unit = ScenEdit_GetUnit({name=”Omara Airport”,side=”PakistanMil”})

draw_circle({latitude=unit.latitude, longitude=unit.longitude},{latitude=unit.latitude + .2357, longitude=unit.longitude}, 12, “”)

local unit = ScenEdit_GetUnit({name=”PAF Pasni”,side=”PakistanMil”})

draw_circle({latitude=unit.latitude, longitude=unit.longitude},{latitude=unit.latitude + .2357, longitude=unit.longitude}, 12, “”)

Here I wanted 12 Reference Points at a 26 km radius.

Dozens of Reference points in a matter of seconds, that’s what I call a true force multiplier!

As we have seen, the Lua language can help in various situations and using it is far from being demanding in term of knowledge, in my opinion it truly is for everyone to use.

What do you think?