Page 1 of 1

"Red October caterpillar drive" using ScenEdit_SetUnit()

Posted: Fri Feb 17, 2023 11:56 pm
by lumiere
This script moves Red October (guid specified unit) based on current heading and separately configurated speed, while its throttle is full stop. So Red October could run very silently (16.2db); quieter than 5kts Los Angeles! (30.6db)

Code: Select all

-----Lua of "Lua1 - keyvalue"-----
-- store Red October's guid as "redoctober" key value
ScenEdit_SetKeyValue("redoctober","87YZY5-0HMOH4G245GJJ")
print(ScenEdit_GetKeyValue("redoctober") )

Code: Select all

-----Lua of "Lua2 - catapillar"-----
--get key value "redoctober"
local ro = tostring(ScenEdit_GetKeyValue("redoctober") )

local statusro = ScenEdit_GetUnit({guid=ro})
print(statusro)
local heading = statusro.heading
local maketurnsfor = 10 --set moving speed

-- get point based on heading and moving speed, and move sub there
local point = World_GetPointFromBearing({latitude=statusro.latitude, longitude=statusro.longitude, bearing=heading, distance=maketurnsfor/3600})
ScenEdit_SetUnit({side=statusro.side, name=statusro.name, latitude=point.latitude, longitude=point.longitude})
Sample scenario attached. Los Angels could not detect Red October until it comes to about 4nm.