Script to check unit presence in Cargo Airbase facility

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
ElGlobo
Posts: 27
Joined: Mon Nov 21, 2022 9:21 am

Script to check unit presence in Cargo Airbase facility

Post by ElGlobo »

Hi,

I would have liked to make a script that check if a list of units have been transferred into a cargo airbase, like the function /event that check units presence in a defined area zone.

The purpose is to make the player planning a cargo mission from base A where there are units and suitable airplanes, than when all his units have arrived at base B, an event check will allow the game to get further (time skip) and give new orders to the player.

Of course I could have set the units directly into base B at the gamestart, but for historical purpose I prefer the player to make that part of the initial setup by himself.

Since I bought the game, I know how to make simple lua scripts, but there aren't so much examples for more complex ones. I'm not a coder, even if I have some basics.

To start, after a look on the LUA tools I was thinking of something like that :

local A = ScenEdit_GetUnit({name='B Airbase', guid='xxxxxxx'})
print (A.cargo) (cargo is a table but I don't know how to write the code to check only the guid/name of units, as there are many un needed fields)

Running this show me the list on the units I've manually transferred to base B, but I don't know how to write the syntax and needed loops or code to ask LUA to check a list of specified units (a full list of the units that were in A base and have been transferred in base B above as a result). If all units have been succesfully transferred then activate a time skip function.
ScenEdit_SetTime({DateFormat= "DDMMYYYY", Date= "dd.mm.yyyy", Time= "hh.mm.ss"})

Thk by advance for any help
Post Reply

Return to “Lua Legion”