Page 1 of 1

Set Unit Formation via LUA

Posted: Sun Jul 07, 2024 2:52 pm
by tmoilanen
Good morning - is there a way to set a units position within a formation with LUA?

I've tried the command below and it doesn't work. I don't see anything in the LUA documentation, other than the formation wrapper.

Any help would be appreciated.


Code: Select all

 local myside = 'VMF'
local myname = 'udaloy'
local mygroup = '7.43 OE'

ScenEdit_SetUnit({side=myside,unitname=myname,{type='Fixed',bearing=0,distance=1}})

local u = ScenEdit_GetUnit({side=myside,name='udaloy'})
print(u.formation)

{ guid = 'CX08W2-0HN4UEDH4RO9Q', bearing = 58.5990600585938, type = 'Rotating', distance = 223.577117919922, latitude = 72.511048649907, sprint = 'False', longitude = 13.5457108161504 }

Re: Set Unit Formation via LUA

Posted: Sun Jul 07, 2024 5:09 pm
by lumiere
This code worked for me at attached test. Note formation wrapper is directly modified with unit.formation instead of ScenEdit_SetUnit( {..formation=....} )
local myside = 'VMF'
local myname = 'udaloy'
local mygroup = '7.43 OE'

local unit = ScenEdit_GetUnit({side=myside,unitname=myname})
unit.formation = {type=1,sprint=false, bearing=0,distance=1}
Also note that if you speficiy transpose = true, unit jumps to the new stations immediately.
https://commandlua.github.io/assets/Tab ... _Formation

Re: Set Unit Formation via LUA

Posted: Sun Jul 07, 2024 11:59 pm
by tmoilanen
Thank you, sir!