Setting unit course with SE_SetUnit

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
vonotha
Posts: 60
Joined: Thu Jan 19, 2023 2:28 am

Setting unit course with SE_SetUnit

Post by vonotha »

SE_SetUnit has a 'course' parameter.

The documentation (http://commandlua.github.io/assets/Func ... tUnit.html) states that it takes a long/lat table as input.

course = {} of multiple
  • latitude
    longitude

It was a little unclear to me what the course input looks like exactly. After some investigation in available scenario scripts, I've found the actual form of the course input table.

It looks like this:

Code: Select all

destination = {}

wp = {longitude=desired_longitude, 
Longitude=desired_longitude, 
latitude=desired_latitude, 
Latitude=desired_latitude}

table.insert(destination, wp)

upddated_unit = ScenEdit_SetUnit({side=unit_side, guid=unit.guid, course=destination})
Hope this will be helpful for someone :)

CMO v1.06 - Build 1328.18; Steam mode; Tacview and all modules except Falklands
KnightHawk75
Posts: 1850
Joined: Thu Nov 15, 2018 7:24 pm

Re: Setting unit course with SE_SetUnit

Post by KnightHawk75 »

"After some investigation in available scenario scripts"
Did you try just searching this forum first? /cause I know it's been posted here various times over the years.

This has actually changed a bit I think with Tiny/1300+, at least optionally when setting other params, as now all the other information seems to be contained in a WayPoint sub table within the base table entries, at it is when doing it direct swaps, or reading from the table data, the double appearance for lat and long is probably for some backward compat when doing basic setting vs getting.
ie

Code: Select all

local u = SE_GetUnit({guid=someunitguidhere});
local mycourse = {
[1] = { GUID = '4FH7PU-0HMO9P1T3UD61', TypeOf = 'ManualPlottedCourseWaypoint', latitude = 26.9830602617286, longitude = -90.3527594639496,
 WayPoint = {
 type = 'ManualPlottedCourseWaypoint', 
 name = 'my point', 
 description = 'my point', 
 guid = '4FH7PU-0HMO9P1T3UD61', 
 latitude = '26.9830602617286', 
 longitude = '-90.3527594639496', 
 altitude = '0', 
}} }
u.course = mycourse
vonotha
Posts: 60
Joined: Thu Jan 19, 2023 2:28 am

Re: Setting unit course with SE_SetUnit

Post by vonotha »

KnightHawk75 wrote: Fri Feb 10, 2023 6:23 pm "After some investigation in available scenario scripts"
Did you try just searching this forum first? /cause I know it's been posted here various times over the years.
Yes I did, but I wasn't able to find a solution on the forum.

The double format seems specific for the lat/long data only.

CMO v1.06 - Build 1328.18; Steam mode; Tacview and all modules except Falklands
Post Reply

Return to “Lua Legion”