Page 1 of 1

Setting unit course with SE_SetUnit

Posted: Thu Feb 09, 2023 11:55 am
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 :)

Re: Setting unit course with SE_SetUnit

Posted: Fri Feb 10, 2023 6:23 pm
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

Re: Setting unit course with SE_SetUnit

Posted: Mon Feb 13, 2023 12:07 am
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.