Set Unit Formation via LUA

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

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

Set Unit Formation via LUA

Post 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 }
User avatar
lumiere
Posts: 272
Joined: Tue Mar 19, 2019 10:38 am

Re: Set Unit Formation via LUA

Post 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
Attachments
TSS01_Sonartest.zip
(31.44 KiB) Downloaded 18 times
"How Do You Stay Calm With A 7,000 Ton Nuclear Predator Listening For Your Heartbeat?"
tmoilanen
Posts: 111
Joined: Wed Oct 19, 2011 4:28 pm

Re: Set Unit Formation via LUA

Post by tmoilanen »

Thank you, sir!
Post Reply

Return to “Lua Legion”