Is it possible in LUA to set a ship's formation in a group?

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
tmoilanen
Posts: 74
Joined: Wed Oct 19, 2011 4:28 pm

Is it possible in LUA to set a ship's formation in a group?

Post by tmoilanen »

Is there a command or method to set a ship's position in a Group Formation via LUA?
KnightHawk75
Posts: 1557
Joined: Thu Nov 15, 2018 7:24 pm

RE: Is it possible in LUA to set a ship's formation in a group?

Post by KnightHawk75 »

local u,g;
u=ScenEdit_GetUnit({guid="someUnitguid etc"}) --Get the unit you want to change.
print(u.formation) -- Investigate the formation property it'll return a table of entries such as.
{ type = 'Rotating', sprint = 'False', guid = '4FH7PU-0HM0AUDSQTDFN', distance = 9.19682998657227, longitude = -2.93132902832244, bearing = 114.63793182373, latitude = 1.02752213608356 }

-- change it via including only that which you want changed, I believe can include multiple:
u.formation = {type='fixed',sprint=true,distance=5.00}

print(u.formation); --or just look at the gui and should see it updated.
{ type = 'Fixed', sprint = 'True', guid = '4FH7PU-0HM0AUDSQTDFN', distance = 4.99689435958862, longitude = -2.93141674907149, bearing = 114.784034729004, latitude = 1.02732899309653 }

If you ever need to find the guid\unit that is the lead unit
g = ScenEdit_GetUnit({side='Blue',name='MyTestGroup'});
or
g = ScenEdit_GetUnit({guid='GuidofMyTestGroupIfyouAlreadyHaveIt'});

print(g.group.lead) --contains the guid of the current lead unit.

tmoilanen
Posts: 74
Joined: Wed Oct 19, 2011 4:28 pm

RE: Is it possible in LUA to set a ship's formation in a group?

Post by tmoilanen »

Excellent...thank you, sir!
Post Reply

Return to “Lua Legion”