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}}});