Help with Lua commands

Take command of air and naval assets from post-WW2 to the near future in tactical and operational scale, complete with historical and hypothetical scenarios and an integrated scenario editor.

Moderator: MOD_Command

Post Reply
AlexinCT
Posts: 88
Joined: Sat Oct 31, 2015 8:27 pm

Help with Lua commands

Post by AlexinCT »

I am working on a scenario where after bombing an air facility and landing troops the landing force takes what is left over. I noticed that the lua script command now supports a SetUnitSide option, but when I use this on the air facility it ungroups the facility and then switches the side of the individual units, but then fails to regroup it leaving the facility kind of useless. Also, while I solved adding new air units to the facility by simply adding them in flight and having them land there, I am not coming up with a way to change the facility's weapon load out either. Is what I am trying something that should be done by running a script? And what would such a script look like?
mikmykWS
Posts: 7185
Joined: Tue Mar 22, 2005 4:34 pm

RE: Help with Lua commands

Post by mikmykWS »

Perfect question for the new command support site

http://qa.commandmodernairnavaloperations.com
Kushan04
Posts: 912
Joined: Tue Jun 28, 2005 9:27 pm
Location: USA
Contact:

RE: Help with Lua commands

Post by Kushan04 »

The units ungrouing when changing sides via lua is a known issues. Its currently not possible to add or remove weapons to a base or ship via lua.

What I would do is have a single unit air base, along with your multi unit base (but have it ungrouped). The multi unit air base would be there to serve as targets only. All aircraft and weapons would be based at the single unit. When enough of the multi unit stuff (bunkers, tarmacs, runways, etc) have been destroyed you could have a script that removes the single unit air base. Then have another script, that when a friendly ground unit enters the area (or remains within an area for a set period of time) around the multi unit area, then move a different single unit air base, that you've had sitting on a neutral side in Siberia or somewhere else outside your ops area, which would have the correct ammo loads you want. This air base could also have any aircraft you want based there and they would get automatically moved in as well.

Its no where near perfect and obviously wouldn't simulate base degradation as things where destroyed but it is a possible work around.
User avatar
Primarchx
Posts: 1954
Joined: Sun Jan 20, 2013 9:29 pm

RE: Help with Lua commands

Post by Primarchx »

FWIW, I'd like to see a method of Lua-generated creation/add/remove of units to groups at some point.
Yokes
Posts: 298
Joined: Tue Mar 13, 2007 9:27 pm

RE: Help with Lua commands

Post by Yokes »

ORIGINAL: AlexinCT

I am working on a scenario where after bombing an air facility and landing troops the landing force takes what is left over. I noticed that the lua script command now supports a SetUnitSide option, but when I use this on the air facility it ungroups the facility and then switches the side of the individual units, but then fails to regroup it leaving the facility kind of useless. Also, while I solved adding new air units to the facility by simply adding them in flight and having them land there, I am not coming up with a way to change the facility's weapon load out either. Is what I am trying something that should be done by running a script? And what would such a script look like?

You can get around this by giving each unit in the airbase a unique name (I just add a number at the end) and writing your script to have each individual unit change sides. Makes for a long script but it works. I did this in the scenario "Facing the Bear".

Yokes
AlexinCT
Posts: 88
Joined: Sat Oct 31, 2015 8:27 pm

RE: Help with Lua commands

Post by AlexinCT »

You can get around this by giving each unit in the airbase a unique name (I just add a number at the end) and writing your script to have each individual unit change sides. Makes for a long script but it works. I did this in the scenario "Facing the Bear".

Won't the script fail if one of the units was destroyed and skip all following switches or commands, or has that been changed? It sounds like this solution, if a unit that is destroyed causes a script to fail, requires me to create a script for the units that cant be destroyed, and then single scripts for each unit that can, then trigger the lot of them. Granted this still leaves me unable to add weapons for the aircraft I want to stage to the facility after it is captured, even if I add new ammo facilities for that, but the ones that fly in with their full loadout I guess can do a single sortie. Let me try this out.
Post Reply

Return to “Command: Modern Operations series”