Assign new home base by LUA? (Full Version)

All Forums >> [New Releases from Matrix Games] >> Command: Modern Operations series >> Tech Support



Message


chrispman -> Assign new home base by LUA? (5/4/2017 10:52:37 PM)

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!






Rory Noonan -> RE: Assign new home base by LUA? (5/5/2017 4:20:53 AM)

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.




michaelm75au -> RE: Assign new home base by LUA? (5/5/2017 5:51:25 AM)

Lookup Command http://commandlua.github.io/beta/index.html#ScenEdit_HostUnitToParent
Function is ScenEdit_HostUnitToParent()




Rory Noonan -> RE: Assign new home base by LUA? (5/5/2017 8:39:22 AM)

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




chrispman -> RE: Assign new home base by LUA? (5/5/2017 8:44:08 AM)


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





chrispman -> RE: Assign new home base by LUA? (5/10/2017 9:16:07 PM)

I'm afraid that doesn't work for me, or I'm doing something wrong:



[image]local://upfiles/34452/815A0A6525D3429F89B131DA2650EEED.jpg[/image]




mikmykWS -> RE: Assign new home base by LUA? (5/11/2017 12:56:00 AM)

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







wgarlick -> RE: Assign new home base by LUA? (5/11/2017 2:28:10 AM)

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.




michaelm75au -> RE: Assign new home base by LUA? (5/11/2017 11:09:37 AM)

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




chrispman -> RE: Assign new home base by LUA? (5/12/2017 3:58:00 PM)


Thanks for looking into this!





Hestia -> RE: Assign new home base by LUA? (6/10/2017 10:58:45 AM)

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?




michaelm75au -> RE: Assign new home base by LUA? (6/10/2017 11:18:09 AM)

Correct.




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.671875