Set Waypoint question

All discussions & material related to Command's Lua interface

Moderators: angster, RoryAndersonCDT, michaelm75au, MOD_Command

Post Reply
Parel803
Posts: 950
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

Set Waypoint question

Post by Parel803 »

Good afternoon,

A made lua text from an excel file and run it in the console. ZZ goes to it's postion, 2 other HVU's same and all other sides/players go to there screen position with heading and speed. To get them at game start on course speed I added the first Waypoint.
When I run it the first waypoint is not in the correct position (only for the first) when I run the console a second time they are on the correct position.
Not import I run it twice but would like to learn what I'm doing wrong here.

It looks a bit like this first WP is still from earlier?

best regards GJ

Code: Select all

-- Formation for I-MWC 
-- LEAD (ZZ) is known (IMWC1=Prinsendam), otherwise check: grouping file.
-- All three HVU's are on same side

local ZZ = ScenEdit_GetUnit ({name='PDAM (Prinsendam)', guid='35e3df8b-e5e8-44c1-9bdd-40a20c260337'});
local heading = 90;
local speed = 14;


local wpZZ = World_GetPointFromBearing( {latitude=ZZ.latitude,longitude=ZZ.longitude,BEARING=heading, DISTANCE=speed/2} )
local ZZ1 = ScenEdit_SetUnit({guid=ZZ.guid, heading=heading, speed=speed, manualSpeed=speed, latitude='S12.40.00', longitude='E149.40.10'})
local ZZ2 = ScenEdit_SetUnit({guid=ZZ.guid, Course = {[1] = { lat=wpZZ.latitude, TypeOf = 'ManualPlottedCourseWaypoint', lon=wpZZ.longitude}}})

local Group = ScenEdit_GetUnit ({name='Group 474', guid='P7ML9T-0HMKJSAH7J3ND'})
local wpGroup = World_GetPointFromBearing( {latitude=Group.latitude,longitude=Group.longitude,BEARING=heading, DISTANCE=speed/2} )
local newCourse = Group.course; Group.course = newCourse;
ScenEdit_SetUnit ({guid=Group.guid, heading=heading, speed=speed, manualSpeed=speed, Course = {[1] = { lat=wpGroup.latitude, TypeOf = 'ManualPlottedCourseWaypoint', lon=wpGroup.longitude}}});  -- Deze moet nog voor ScenA Group guid in GetUnit

-- Unit: Rotterdam
local brgRDAM = 0+0; local distRDAM = 2.5;
local RDAM = ScenEdit_GetUnit ({name='RDAM (Rotterdam) - L800', guid='5a6d1605-93eb-4d06-819a-e4a45e9ea4df'});
RDAM.formation = {type='fixed', bearing=brgRDAM, distance=distRDAM};
local ptRDAM = World_GetPointFromBearing({LATITUDE=ZZ.latitude,LONGITUDE=ZZ.longitude,BEARING=brgRDAM, DISTANCE=distRDAM});
local wpRDAM = World_GetPointFromBearing( {latitude=RDAM.latitude,longitude=RDAM.longitude,BEARING=heading, DISTANCE=speed/2} )
local newCourse = RDAM.course; RDAM.course = newCourse;
ScenEdit_SetUnit ({guid=RDAM.guid, heading=heading, speed=speed, manualSpeed=speed, latitude = ptRDAM.latitude, longitude = ptRDAM.longitude, Course = {[1] = { lat=wpRDAM.latitude, TypeOf = 'ManualPlottedCourseWaypoint', lon=wpRDAM.longitude}}});

local brgKAHA = 0+135; local distKAHA = 5;
local KAHA = ScenEdit_GetUnit ({name='TKHA (Te Kaha) - F77', guid='8c5a7687-ff05-41a2-891c-669f4e91664a'});
local ptKAHA = World_GetPointFromBearing({LATITUDE=ZZ.latitude,LONGITUDE=ZZ.longitude,BEARING=brgKAHA, DISTANCE=distKAHA});
local wpKAHA = World_GetPointFromBearing( {latitude=KAHA.latitude,longitude=KAHA.longitude,BEARING=heading, DISTANCE=speed/2} )
local newCourse = KAHA.course; KAHA.course = newCourse;
ScenEdit_SetUnit ({guid=KAHA.guid, heading=heading, speed=speed, manualSpeed=speed, latitude = ptKAHA.latitude, longitude = ptKAHA.longitude});
ScenEdit_SetUnit ({guid=KAHA.guid, Course = {[1] = { TypeOf = 'ManualPlottedCourseWaypoint', latitude=wpKAHA.latitude, longitude=wpKAHA.longitude}}});
 
deleted here some units, is in description of scen
Attachments
IMWC_UWIP_SE_CMO_ScenA_v1-LeftScr-temp.rar
test scen
(182.43 KiB) Downloaded 10 times
User avatar
michaelm75au
Posts: 12463
Joined: Sat May 05, 2001 8:00 am
Location: Melbourne, Australia

Re: Set Waypoint question

Post by michaelm75au »

When I load the scenario, the courses are already set.
If I clear them, and then run your script, both the unit and group get new courses. Which look like the original ones I deleted.

Am I missing something?
Michael
Parel803
Posts: 950
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

Re: Set Waypoint question

Post by Parel803 »

Micheal,
Thx for answering.

I'll check the scenario this weekend.

I did not delete the Waypoints just want to make new ones, so most likely I'm doing somthing wrong.
The script comes from an excel sheet which is filled in before the start of the game, the Screen & WP is based on the preps from others and I want to be more precise and quicker than move them in editor.

At my side it looks like the WP is set after the second time loaded of the text. It is not a big thing, I can load twice but was wondering why I had to do that.

thx again, best regards GJ
Parel803
Posts: 950
Joined: Thu Oct 10, 2019 3:39 pm
Location: Netherlands

Re: Set Waypoint question

Post by Parel803 »

Sorry,
uploaded scenario was after twice running.
Retry.
best regards
Attachments
IMWC_UWIP_SE_CMO_ScenA_v1-LeftScr.rar
(95.91 KiB) Downloaded 12 times
Post Reply

Return to “Lua Legion”