Matrix Games Forums

Forums  Register  Login  Photo Gallery  Member List  Search  Calendars  FAQ 

My Profile  Inbox  Address Book  My Subscription  My Forums  Log Out

Assign new home base by LUA?

 
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 >> Tech Support >> Assign new home base by LUA? Page: [1]
Login
Message << Older Topic   Newer Topic >>
Assign new home base by LUA? - 5/4/2017 10:52:37 PM   
chrispman

 

Posts: 117
Joined: 3/28/2010
Status: offline
Hi,

I was sure I read somewhere that it is possible to assign a home base to an aircraft by LUA.

But the documenation says that it's readonly:
quote:


Unit
Represents a active unit.
...
base Unit The unit's assigned base. [READONLY]
...

So I can't change the home base in mid-flight, correct?

Thanks for your help!


Post #: 1
RE: Assign new home base by LUA? - 5/5/2017 4:20:53 AM   
Rory Noonan

 

Posts: 2816
Joined: 12/18/2014
From: Brooklyn, NY
Status: offline
There is a way, I can't remember offhand and I'm not at my computer. Have a look at the Civ_AirTrafficNight script in Seven Days in October.

I'll post up the code here in 8 hours or so, provided IRL doesn't get in the way.

(in reply to chrispman)
Post #: 2
RE: Assign new home base by LUA? - 5/5/2017 5:51:25 AM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
Lookup Command http://commandlua.github.io/beta/index.html#ScenEdit_HostUnitToParent
Function is ScenEdit_HostUnitToParent()

_____________________________

Michael

(in reply to Rory Noonan)
Post #: 3
RE: Assign new home base by LUA? - 5/5/2017 8:39:22 AM   
Rory Noonan

 

Posts: 2816
Joined: 12/18/2014
From: Brooklyn, NY
Status: offline
This works:

quote:


ScenEdit_SetUnit({guid=x.guid,base=destination.name,rtb=true})


Replace destination.name with the name of your desired new base, and delete or change the rtb value as appropriate.

HostUnitToParent will instantly teleport the units to the desired new base, the code above will simply change the homebase

(in reply to michaelm75au)
Post #: 4
RE: Assign new home base by LUA? - 5/5/2017 8:44:08 AM   
chrispman

 

Posts: 117
Joined: 3/28/2010
Status: offline

Thanks guys, I will have a go over the weekend hopefully.


(in reply to Rory Noonan)
Post #: 5
RE: Assign new home base by LUA? - 5/10/2017 9:16:07 PM   
chrispman

 

Posts: 117
Joined: 3/28/2010
Status: offline
I'm afraid that doesn't work for me, or I'm doing something wrong:






Attachment (1)

(in reply to chrispman)
Post #: 6
RE: Assign new home base by LUA? - 5/11/2017 12:56:00 AM   
mikmykWS

 

Posts: 11524
Joined: 3/22/2005
Status: offline
Ok will need to look further into this.

The base value is read only and host unit function does it but also teleports it home.

Mike





_____________________________


(in reply to chrispman)
Post #: 7
RE: Assign new home base by LUA? - 5/11/2017 2:28:10 AM   
wgarlick

 

Posts: 1
Joined: 12/4/2016
Status: offline
For my Doolittle Raid scenario, I had to delete the carrier via event then all the B25 planes automatically changed to a base in China as their new home base. May not be ideal if you have multiple bases.

(in reply to mikmykWS)
Post #: 8
RE: Assign new home base by LUA? - 5/11/2017 11:09:37 AM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
Mmmm. Always thought you could re-base a unit. I think all the times this was used, was around basing new units, rather than re-basing existing ones.
Shouldn't be too difficult to do so..probably add an option in the HostUnitToParent() to just change the base and not move, or jump as it does now. I think the default behavior will be as it is now with option to just change it.

Changed around....Simpler solution

The property .base will be able to be set to the unit object of the new base. Plus if set to 'nil', it will choose the closest base that can host it. e.g.
local unit = ScenEdit_GetUnit({name='SS 583 Harushio', guid='3a5f2a57-36e2-48f6-9352-00b819789a18'})
unit.base = ScenEdit_GetUnit({name='Naval Station Yokosuka', guid='db7d4c0c-31e8-4563-8d43-9f2b467cf977'})
unit.base = nil


< Message edited by michaelm -- 5/11/2017 1:12:51 PM >


_____________________________

Michael

(in reply to wgarlick)
Post #: 9
RE: Assign new home base by LUA? - 5/12/2017 3:58:00 PM   
chrispman

 

Posts: 117
Joined: 3/28/2010
Status: offline

Thanks for looking into this!


(in reply to michaelm75au)
Post #: 10
RE: Assign new home base by LUA? - 6/10/2017 10:58:45 AM   
Hestia


Posts: 22
Joined: 2/28/2017
Status: offline
Sorry for bothering you, Michael. I'm new to Lua and I'm still trying to get familiarized with the syntax and parameters.
I'm trying to accomplish the same thing with a ship, but the solution you wrote for commanderchrisp's scenario does not make any sense to me.
Can you elaborate a little on how the script should look like?

Thank you!

LE: oops! just noticed someone has the same issue and opened another thread. So, if I understand correctly, the ability so set a new base for a unit through Lua is a feature for the future, right?

< Message edited by Hestia -- 6/10/2017 11:05:51 AM >

(in reply to michaelm75au)
Post #: 11
RE: Assign new home base by LUA? - 6/10/2017 11:18:09 AM   
michaelm75au


Posts: 13500
Joined: 5/5/2001
From: Melbourne, Australia
Status: offline
Correct.

_____________________________

Michael

(in reply to Hestia)
Post #: 12
Page:   [1]
All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Tech Support >> Assign new home base by LUA? 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.250