Little trick for air scenarios

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
Eboreg
Posts: 309
Joined: Wed Mar 13, 2019 10:35 pm

Little trick for air scenarios

Post by Eboreg »

Okay, say you're building a scenario with some aircraft in it and you want to a) Have instant action and b) Let the players choose which loadouts to carry.

Oh boy, Ready times are pretty long and you don't want the player to have to wait 3-6 hours to get the loadout he wants, what do you do? Well, there's a pretty simple answer in the form of Special Actions. Just create a new special action, set it to active and repeatable, and put this as the Lua Script:

Code: Select all

local carrierorairfield = ScenEdit_GetUnit({side="Your Side", unitname="Your AirBase"})
 for i = 1, #carrierorairfield.embarkedUnits.Aircraft do
     local currentaircraft = ScenEdit_GetUnit({guid=carrierorairfield.embarkedUnits.Aircraft[i]})
     ScenEdit_SetLoadout({UnitName=currentaircraft.name, LoadoutID=0, TimeToReady_Minutes=0})
 end

But wait, you don't want players to do this all the time! That would be blatant cheating! Well, enter Events. Set a Time Trigger to go off 1 second after the scenario start and create a Lua Script as the Action, namely:

Code: Select all

ScenEdit_SetSpecialAction({ActionNameOrId='Instant Aircraft Ready Special Event', IsActive=false})

And there you have it, a simple way to give the player choices while not making them have to wait just to get them!
Rory Noonan
Posts: 2418
Joined: Thu Dec 18, 2014 1:53 am
Location: Brooklyn, NY

RE: Little trick for air scenarios

Post by Rory Noonan »

Nice!
Image
spinnaker
Posts: 5
Joined: Sat Apr 15, 2017 7:07 pm

RE: Little trick for air scenarios

Post by spinnaker »

Thank you for this! was about to post asking about this type of script.
Post Reply

Return to “Lua Legion”