Get home base of unit

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
Whicker
Posts: 665
Joined: Tue Jun 19, 2018 9:54 pm

Get home base of unit

Post 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.
Whicker
Posts: 665
Joined: Tue Jun 19, 2018 9:54 pm

RE: Get home base of unit

Post 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).
Whicker
Posts: 665
Joined: Tue Jun 19, 2018 9:54 pm

RE: Get home base of unit

Post 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
Post Reply

Return to “Lua Legion”