Bashkire
Posts: 38
Joined: 2/23/2015 Status: offline
|
Hello chaps, I'm toying around with a piece of code to cause a stolen civilian aircraft to fly into the side of a warship to simulate a suicide attack,but for the life of me I can't see where this code is going wrong. The below code was given to me by Apache85, who's help has been invaluable so far: local NatoShip = ScenEdit_GetUnit({side='NATO',name='NatoShip'}) -- change as appropriate
local kamikazeAircraft = ScenEdit_GetUnit({side='Banzai',name='Sake #1'}) -- change as appropriate
local kamikazeCourse = {latitude=NatoShip.latitude, longitude=NatoShip.longitude}) --Desired speed only kicks in when you reach the waypoint, once you've got this segment working we can add more logic there
ScenEdit_SetUnit({guid=kamikazeAircraft.guid, course=kamikazeCourse}) Now I then edited it to my uses so it became the following: local Albion = ScenEdit_GetUnit({side='NATO',name='[L 14] HMS Albion [LPD]'});
local LoSlo = ScenEdit_GetUnit({side='Civilian Air (Hijacked)',name='Lo-Slo'});
local terminalCourse = ({latitude=Albion.latitude, longitude=Albion.longitude});
ScenEdit_SetUnit({guid=LoSlo.guid, course=terminalCourse}); The problem is that running the code in the Lua editor to test before I put it into an event returns the error: ERROR: Input string was not in a correct format. Doing some messing about and commenting out lines, I believe that the problem lies in the last line where Lo-Slo gets given his waypoint. The Command Lua repository (here) mentions about a waypoint table with lots of possible inputs, but all I really need at the moment is the course to follow the ship and I can worry about speeds and altitudes later. Can anyone see where this code is going wrong? EDIT: Just to keep people informed of progress, I now have this code which is seeming to work somewhat correctly, although I now need to loop it to continue updating the waypoint onto of the ship as it moves: local Albion = ScenEdit_GetUnit({side='NATO',name='[L 14] HMS Albion [LPD]'});
local LoSlo = ScenEdit_GetUnit({side='Civilian Air.',name='Lo-Slo'});
local terminalCourse = LoSlo.course;
terminalCourse[1].latitude = Albion.latitude;
terminalCourse[1].longitude = Albion.longitude;
ScenEdit_SetUnit({side='Civilian Air.',name='Lo-Slo', course=terminalCourse, manualSpeed=170.0, manualAltitude=80.0}); Does anyone know how to loop this thing? I'm not seeing any syntax of while() loops on the documentation I linked above.
< Message edited by Bashkire -- 7/11/2020 3:11:24 PM >
|