Due to all the previous help I got a script to get all the facilities form one side
Code: Select all
-- Print ALL facilities:
gParel = {}
gParel.UnitFacilitySubType = {
[1001] = "None",
[2001] = "Runway",
[2002] = "Runway-Grade Taxiway",
[2003] = "Runway Access Point",
[3001] = "Building (Surface)",
[3002] = "Building (Reveted)",
[3003] = "Building (Bunker)",
[3004] = "Building (Underground)",
[3005] = "Structure (Open)",
[3006] = "Structure (Reveted)",
[4001] = "Underwater",
[5001] = "Mobile Vehicle(s)",
[5002] = "Mobile Personnel",
[6001] = "Aerostat Mooring",
[9001] = "Air Base",
}
gParel.UnitFacilityCategory = {
[0] = "None",
[1000] = "Infantry",
[2000] = "Armor",
[3000] = "Artillery Gun",
[4000] = "Artillery SSM",
[5000] = "AAA",
[6000] = "SAM",
[7000] = "Engineer",
[8000] = "Supply",
[9000] = "Surveillance",
[10000] = "Recon",
[11000] = "MechInfantry",
}
Code: Select all
function catNumToString(catTable, n)
n = tonumber(n);
if catTable[n] ~=nil then return catTable[n]; else return tostring(n); end
end
-- 2: Facility on side
local s = VP_GetSide({Side="NAVO"}) -- use sidename for other sides
local unitlist = s:unitsBy('Facility');
for _,v in ipairs(unitlist) do
local u = SE_GetUnit({guid=v.guid});
if u ~=nil then
print(catNumToString(gParel.UnitFacilitySubType,u.subtype) .. ';' .. catNumToString(gParel.UnitFacilityCategory,u.category) .. ';' .. tostring(u.classname) .. ';' .. tostring(u.dbid) .. ';' .. tostring(v.name));
else
print((v.name)..';'..tostring(v.guid)..';' .. ' Error obtaining unit details.');
end
u = nil;
end
Tried to replace: if u ~=nil then to if u ~= nil and u.category == 6000
Running this the console stays empty
Was wondering if someone sees what I'm doing wrong?
best regards GJ