Page 1 of 1

Listing aircraft at an airbase?

Posted: Fri Jul 11, 2025 11:18 pm
by Craigkn
I am working on a logistics model and I need to know which aircraft are at (or assigned) to a specific airbase, to properly route munitions where they need to go. The one "OOB" answer I saw points to a dead link from 2018.

I dont care if they are at the base, or just assigned to the base, but I want to create a list. I can brute force this in ugly ways but I was hoping there was something programatic that I can do.

My one brute force idea is use an event trigger (via remain x time trigger), save its name/guid to a 'based at' global table. Query the table for my logistics scripts. This works, but if the unit is destroyed, I then need a means to remove it from the "based at" table (which I can do via event triggers - unit destroyed = remove from table. This would also require one version of the script per airbase. I think this would work, but it feels ugly.

Hoping there is a more elegant way.

edit:

This might work (tweaking the action of course), I'll try this when I am able. Source from 2019:https://forums.matrixgames.com/viewtopi ... e#p4459960

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

Re: Listing aircraft at an airbase?

Posted: Sat Jul 12, 2025 1:06 am
by Craigkn
Boom. It works. This sample script just prints out the aircraft info, showing it iterate through the aircraft in the base:

Code: Select all

local carrierorairfield = ScenEdit_GetUnit({side="NATO", unitname="NAS Keflavik"})
 for i = 1, #carrierorairfield.embarkedUnits.Aircraft do
     local currentaircraft = ScenEdit_GetUnit({guid=carrierorairfield.embarkedUnits.Aircraft[i]})
     print(currentaircraft)
 end

Re: Listing aircraft at an airbase?

Posted: Sat Jul 12, 2025 1:30 am
by Craigkn
so weird. when I try to currentaircraft.class, it returns "null", but when I call table values like name, altitude, etc - it returns the actual value. Name works, and - in an ugly way - I can use that to derive the specific type of aircraft.

Why wont currentaircraft.class print?

Code: Select all

local carrierorairfield = ScenEdit_GetUnit({side="NATO", unitname="NAS Keflavik"})
 for i = 1, #carrierorairfield.embarkedUnits.Aircraft do
     local currentaircraft = ScenEdit_GetUnit({guid=carrierorairfield.embarkedUnits.Aircraft[i]})
     print(currentaircraft.name)

 end

Re: Listing aircraft at an airbase?

Posted: Sat Jul 12, 2025 1:35 am
by Craigkn
SOLVED. Despite what is displayed, the class value is held under "classname"

This code works as intended, displaying the class of the unit:

Code: Select all

local carrierorairfield = ScenEdit_GetUnit({side="NATO", unitname="NAS Keflavik"})
 for i = 1, #carrierorairfield.embarkedUnits.Aircraft do
     local currentaircraft = ScenEdit_GetUnit({guid=carrierorairfield.embarkedUnits.Aircraft[i]})
     print(currentaircraft.classname)

 end