Page 1 of 1

Get home base of unit

Posted: Wed Aug 14, 2019 12:38 am
by Whicker
I thought this would be easy but I can't get the base of a unit using lua (trying to use it on an AC that does have a home base set).

if i print:
u.base

I get the info in the lua wrapper - not a value for the base but all the values for the different items - just the same as if I printed just u.

if I do: u.hostFacility
I get nil

If I print u.fields I see:
property_16 = '.base , LuaWrapper_ActiveUnit , True'

sort of the same for hostFacility, in the field list it shows:
property_49 = '.hostFacility , LuaWrapper_Facility , False'

If I just do print(u) it shows:
base = 'NS Blue Fields',

but u.base returns the same thing as just u - all the things - not just u.base.

RE: Get home base of unit

Posted: Wed Aug 14, 2019 12:40 am
by Whicker
I've tried it both on units in the air and units on the ground at the base, same results. ultimately I want to get the home base of a unit when it lands at its new base (chosen by the player).

RE: Get home base of unit

Posted: Wed Aug 14, 2019 5:40 pm
by Whicker
ah ha - u.base returns the base/group wrapper which looks like the unit wrapper except it is not - it is the wrapper for the base.

print(u.base.name) -- gives the actual base name