Lua provides a vast number of new possibilities for scenario creators, letting you automate tasks. Today we’re going to discuss how you can use Lua in a real scenario, using my upcoming Operation Fei Lian as an example. We’ll discuss how to integrate Lua into your scenario development workflow, and also how to implement solutions to some common problems.

The Setting

The name Operation Fei Lian tells some of the story behind the scene. Fei Lian is the name for the Chinese god of wind – and in the scene, three winds are sweeping North Korea:

A literal wind, making the skies abnormally clear Yet another internal coup A Chinese attack in support of that coup

The PRC intends to help topple the Kim dynasty by military force, a task eased by the unusually clear skies over the country. However, there are some complicating factors: the North Korea’s nuclear weapons – a force that could potentially kill millions of Chinese. The PLAAF must destroy the DPRK’s strategic air and missile forces before they can be used to retaliate against the PRC.

This idea, originally by JanMasterson, really intrigued me, as it depicts events that aren’t usually seen in Command. Playing as the PLAAF is unusual, compounded by the complex relationships and timing inherent in a nuclear counterattack. Before 1.06, Command couldn’t simulate a randomized event chain like needs to happen here, but not modelling the missiles leaving their hangars, the nuclear integration time, etc, would leave the scenario rather lacking in detail. Lua was the solution.

Planning

Lua requires some forethought, like any other scenario. You need to figure out what needs to happen in your scene to implement it with Lua. The major component in Fei Lian was the North Korean nuclear retaliation pipeline – integrating a process including missiles, airplanes, trucks, and a palace.

In-game, the process works like this:

T+0: Realization of PRC hostility (attack/entry into NK airspace) T+20m: Conventional forces launch (KPAF mass scramble), special forces ready (IRBMs to launch locations) T+30m: Nuclear go: Trucks carrying NK nuclear weapons depart from Kim Jong Un’s palace to the aircraft and (randomized) missile launch site T+~1h: Nuclear weapons arrive at ballistic missile launch site, and begin integration. T+1h30m: Nuclear warhead integration complete, missile launch against Beijing T+1h45m: Nuclear bombs arrive at MiG-23 bases T+2h: MiG-23 with nuclear gravity bomb ready – air attack on Shenyang

This chain of events would be hard to do in Command in the pre-Lua days – especially the randomized nuclear missile selection process. To implement this sequence of events, you have to keep track of which units are where and when they start out, hard with the traditional mission editor, much easier with Lua.

The implementation of this system has these trouble spots that need Lua solutions:

Timing events in general (e.g. event A happens, then B happens 30m later)

Departure of nuclear missiles from hangars to launch sites

Missile selection for nuclear delivery

Nuclear integration (only one missile should be nuclear, not all of them)

Transportation (tunnels through mountains)

Implementation

The actual implementation of the solutions to these trouble spots is beyond the scope of this article, but they provide some insight as to what’s possible with Lua right now.

Timing is the big part – Lua allows you, via the Siberian Humvee method, to schedule events in the future. This lets Lua implement some interesting things, including simulating strategic OODA loops, but also how long it takes for a truck to get through a tunnel, for instance.

Another part of Fei Lian implemented with Lua is storing ground vehicles in hangars. In the past, you couldn’t put a truck in a hangar, as a limitation of the engine. However, Lua lets you simulate the truck being inside, by spawning it at the right time and only if the hangar hasn’t been damaged yet.

Lua lets you go even further, though. A problem in Fei Lian was that you, with the traditional event editor, could destroy the same TEL out of 9 to ensure that no nuclear weapon was launched, because the nuclear warhead’s destination has to be fixed. That’s no longer the case – Lua can store what’s arrived where, so that the nuclear delivery trucks can make an intelligent decision about which missile gets a special warhead.

I plan to describe how these features were implemented in a series of tutorials on my website commandlua.github.io, explaining the Lua features involved and how to apply them in Command so that you can add Lua to your toolbox. Lua allows you to extend Command’s scenario building capabilities manyfold, both when editing (as JanMasterson described on Friday) or in the scenes directly. If you want to play Fei Lian, take a look at it here.