Page 1 of 1

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

Posted: Sun Jun 07, 2020 10:34 am
by tmoilanen
Is there a command or method to set a ship's position in a Group Formation via LUA?

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

Posted: Sun Jun 07, 2020 12:50 pm
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.


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

Posted: Mon Jun 08, 2020 11:45 am
by tmoilanen
Excellent...thank you, sir!