KnightHawk75
Posts: 1450
Joined: 11/15/2018 Status: offline
|
quote:
ORIGINAL: PastBehavin What is the correct LUA script to use to reassign an aircraft or group of Aircraft to a different base than they takeoff from? Trying the following format doesn't change the assigned base ScenEdit_SetUnit({unitname= "AIRCRAFT NAME", side= "Blue", base="Anderson"}) I've also replaced the base name with the 'guid' string to no avail. You can do it just as you are trying, my guess is you have typo\case-sensitivity issue or you have ambiguous names on side "Blue". As for using a guid for base=, that's a documentation error| or long-standing-bug atm. How to change a units base: If it's airborne. 2 ways: 1. Get the airbase in question, then assign that wrapper to the aircraft's unitwrapper .base property.
local myairport = SE_GetUnit({name='Red_AirBaseGroup2', guid='4FH7PU-0HM504GOL2OE2'});
local myunit = SE_GetUnit({name='Stinger #2', guid='4FH7PU-0HM504GKUQND7'})
print('original base guid:' .. tostring(myunit.base.guid) .. ' originalbase name: ' .. tostring(myunit.base.name))
myunit.base = myairport;
print('new base guid:' .. tostring(myunit.base.guid) .. ' new name: ' .. tostring(myunit.base.name))
2. Use SetUnit spelling out the correct unit to operate on and the case-sensitive base name.
--cleanest example
SE_SetUnit({guid='4FH7PU-0HM504GKUQND7',base="Red_AirBaseGroup2"});
-- next best, making SURE side and unitname match EXACTLY, and that you do not have ambiguous unit names.
-- What does that mean? It means two or more units on the same side with the same exact names
-- which can make lookup fails because it doesn't know which one you intended.
SE_SetUnit({side='Red',unitname='Stinger #2',base='Red_AirBaseGroup2'});
If you want to insert the unit into another base (because it's on the ground already), or even if it's actively flying do the following.
--SourceUnitGuid first, DestinationGuid second.
--The following inserts "Stinger #2" from above examples into Red_AirBaseGroup2 from above REGARDLESS of if it's in the air or not.
ScenEdit_HostUnitToParent({HostedUnitNameOrID = "4FH7PU-0HM504GKUQND7", SelectedHostNameOrID = "4FH7PU-0HM504GOL2OE2"});
What's the error you're getting? Is it descriptive or is it like object ref not set to value?
< Message edited by KnightHawk75 -- 12/15/2020 10:14:00 AM >
|