This first part sets up some constants. The gb and gw are just guids for the paired aircraft carriers in your scenario. They are used to define an array. Feel free to modify that part to suit your scenario.
Code: Select all
 -- This script determines which CVN is currently in the active phase of its deck cycle.
 gb = 'GWKW9V-0HMC21A9CO9FE'   -- USS George W. Bush
 gw ='GWKW9V-0HMC21A9COA5M'  -- USS George Washington
 cvns = {gb, gw}
 
 reserveLoadout = 3
 oneDeckCycle = 12 * 60 -- 12 hours
 When this script is paired with a ScenarioLoad triggered event, the following code will randomly choose a carrier from the above array.
Code: Select all
 -- coin flip choose which of the two cvns gets to be active.  The other will have the aircraft placed in a "reserve." state
 math.randomseed (os.time ())
 if (math.random() < 0.5) then
      cvnI = 1
 else 
      cvnI = 2
 end
 
 inActiveCvnGuid = cvns[cvnI]
 
 inActiveCvn = ScenEdit_GetUnit( { guid = inActiveCvnGuid  } )
 inActiveAircraft = inActiveCvn.assignedUnits.Aircraft
 This loops over the aircraft in on the selected inActiveCvn and sets them to a reserve loadout with a ready time of 12 hours.
Code: Select all
 for acIdx, acId in ipairs( inActiveAircraft )
 do
     ScenEdit_SetLoadout({UnitName=acId , LoadoutID=reserveLoadout, IgnoreMagazines=true, TimeToReady_Minutes=oneDeckCycle }) 
 end
 
 You should be able to paste all of the above code in order in a single LuaScript action without trouble.
 
					 
					
