Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Reassign aircraft to different base then takeoff

 
View related threads: (in this forum | in all forums)

Logged in as: Guest
Users viewing this topic: none
  Printable Version
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> Reassign aircraft to different base then takeoff Page: [1]
Login
Message << Older Topic   Newer Topic >>
Reassign aircraft to different base then takeoff - 12/13/2020 2:20:49 PM   
PastBehavin

 

Posts: 25
Joined: 1/29/2020
From: Cincinnati, OH
Status: offline
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.
Post #: 1
RE: Reassign aircraft to different base then takeoff - 12/13/2020 5:00:06 PM   
boogabooga

 

Posts: 457
Joined: 7/18/2018
Status: offline
I believe that the base needs to be input as a "Unit" type, not a string, so you need to nest another "{}" with the relevant characteristics.

Try:

ScenEdit_SetUnit({unitname= "AIRCRAFT NAME", side= "Blue", base= {unitname="Anderson", side= "Blue"} })


< Message edited by boogabooga -- 12/13/2020 5:01:57 PM >

(in reply to PastBehavin)
Post #: 2
RE: Reassign aircraft to different base then takeoff - 12/13/2020 7:32:30 PM   
PastBehavin

 

Posts: 25
Joined: 1/29/2020
From: Cincinnati, OH
Status: offline
Thanks, that makes some sense and will try it

(in reply to boogabooga)
Post #: 3
RE: Reassign aircraft to different base then takeoff - 12/15/2020 9:46:23 AM   
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 >

(in reply to PastBehavin)
Post #: 4
RE: Reassign aircraft to different base then takeoff - 12/15/2020 10:03:27 AM   
PastBehavin

 

Posts: 25
Joined: 1/29/2020
From: Cincinnati, OH
Status: offline
Knighthawk75
Thanks so much for the very thorough answer and especially the ability tp reassign while airborne. I stiill have a ways to go on the learning curve and this is extremely helpful
Regards
Bill

(in reply to KnightHawk75)
Post #: 5
RE: Reassign aircraft to different base then takeoff - 12/15/2020 12:12:02 PM   
KnightHawk75

 

Posts: 1450
Joined: 11/15/2018
Status: offline

quote:

ORIGINAL: PastBehavin

Knighthawk75
Thanks so much for the very thorough answer and especially the ability tp reassign while airborne. I stiill have a ways to go on the learning curve and this is extremely helpful
Regards
Bill

Cool, did you get it working or are you still having an problem with the name\side method?

If you're getting a non-descriptive error like "object not set to instance of object" vs an actual human sort of error, that's usually when the name is wrong but the side is right, for whatever reason it throws a null argument exception at the end of checking\comparing against all unit names when it's not found, I think they got a line of code in there somewhere that probably assumes the lookup found the unit, but when it doesn't it bombs.

BTW the reason I mention preferring {guid="xxxxxx"} where you can, besides avoiding the naming conflict issue, it's faster since the name lookup runs through every object in the game looking for name match before the side match, and also checks if the 'name' matches a 'guid' (which is kinda of nice) but it's potentially 2x the number of compare operations, not a big deal when dealing with a couple hundred units, but when you have 4k it can make a difference. Anyway hopefully you got it sorted - mainly just posting this for future reference for others.

(in reply to PastBehavin)
Post #: 6
RE: Reassign aircraft to different base then takeoff - 12/15/2020 12:26:08 PM   
PastBehavin

 

Posts: 25
Joined: 1/29/2020
From: Cincinnati, OH
Status: offline
Yes, I did get it sorted out, thanks for the help!. Also your comment on utilizing the guid # vs. name makes sense but not something I ever would have thought of. Speeding up the game is always important.

(in reply to KnightHawk75)
Post #: 7
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Mods and Scenarios >> Lua Legion >> Reassign aircraft to different base then takeoff Page: [1]
Jump to:





New Messages No New Messages
Hot Topic w/ New Messages Hot Topic w/o New Messages
Locked w/ New Messages Locked w/o New Messages
 Post New Thread
 Reply to Message
 Post New Poll
 Submit Vote
 Delete My Own Post
 Delete My Own Thread
 Rate Posts


Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI

1.141