setting a hostFacility property

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
User avatar
wqc12345
Posts: 176
Joined: Mon Dec 07, 2015 2:56 pm
Location: San Francisco, CA

setting a hostFacility property

Post by wqc12345 »

Ok, this took me a while.. but I finally was able to dump all properties of the Unit object.

Code: Select all

local a = ScenEdit_GetUnit({ side = 'USSR' , name = 'Roxy #1' })
 print(a.fields)
 for k,v in pairs(a.fields) do
 if string.find(k,'property_') ~= nil then
 local t = string.find(v," , ") -- location of first ,
 print("\r\n[object] = " .. string.sub(v,2,t-1) ) -- property name
 print( a[string.sub(v,2,t-1)] ) -- value of property
 end
 end

All I want to do is assign the BASE of the unit, there appears to be a properly called "hostFacility" but when I go to set this, nothing happens to the unit.

local a = ScenEdit_GetUnit({ side = 'USSR' , name = 'Roxy #1' })
ScenEdit_SetUnit({ side = 'USSR' , name = 'Roxy #1'}, {hostFacility='Nairobi Air Force Base (KDPA)'})

Tried tables, selectors, etc.. nothing.

Any ideas? I'm not even sure that's the right lua wrapper, but there is no other host or assignedBase property.

Thanks,
User avatar
michaelm75au
Posts: 12467
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: setting a hostFacility property

Post by michaelm75au »

To change base using the unit wrapper.
local u = ScenEdit_GetUnit({name='Looking #1', guid='207d76e0-e5be-4012-bbc8-93a142bb5b7b'})
print(u.base)
-- new base has to be a unit wrapper for some reason (I can't recall why)
u.base = ScenEdit_GetUnit({name='Tsu'})
print(u.base)
Michael
User avatar
michaelm75au
Posts: 12467
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: setting a hostFacility property

Post by michaelm75au »

unit.hostFacility from memory is the the facility holding the unit (such as a Hanger)
Michael
User avatar
michaelm75au
Posts: 12467
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

RE: setting a hostFacility property

Post by michaelm75au »

ScenEdit_SetUnit({ side = 'USSR' , name = 'Roxy #1', base = 'Nairobi Air Force Base (KDPA)'})

This should work also as long as the base can host the unit.
Michael
User avatar
wqc12345
Posts: 176
Joined: Mon Dec 07, 2015 2:56 pm
Location: San Francisco, CA

RE: setting a hostFacility property

Post by wqc12345 »

Thanks. That worked.

Post Reply

Return to “Lua Legion”