Code: Select all
ScenEdit_GetLoadout (loadoutinfo)Has anyone encountered a similar problem? Is there a work around or solution?
Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command
Code: Select all
ScenEdit_GetLoadout (loadoutinfo)Post by KnightHawk75 »
Code: Select all
-- Returns true on having loadout, false on nil or error, prints debug info
local function HasLoadout(u)
local ltext= 'empty';
local retval= false;
if u ~= nil then
print('unit: ' .. tostring(u.name));
Tool_EmulateNoConsole(true);
local l = ScenEdit_GetLoadout({UnitName=u.name,LoadoutID=0}); --request current assigned loadout
Tool_EmulateNoConsole(false);
if l ~=nil then
ltext= tostring(l.dbid);
retval= true;
else
ltext= 'No Loadout';
end
else
print('Invalid Unit');
end
print('LoadoutID: ' .. ltext);
ltext = nil;
return retval;
end
local unit1 = ScenEdit_GetUnit({name='Raptor99', guid='d20fea11-f966-4d7d-a0c5-9c8dafa02db0'}); --in the air with loadout
local unit2 = ScenEdit_GetUnit({name='TestAircraft #1'}); --at base with no loadout assigned
HasLoadout(unit1);
HasLoadout(unit2);