"Red October caterpillar drive" using ScenEdit_SetUnit()

All discussions & material related to Command's Lua interface

Moderators: RoryAndersonCDT, michaelm75au, angster, MOD_Command

Post Reply
User avatar
lumiere
Posts: 287
Joined: Tue Mar 19, 2019 10:38 am

"Red October caterpillar drive" using ScenEdit_SetUnit()

Post 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.
Attachments
THFRO.zip
(12.27 KiB) Downloaded 14 times
"How Do You Stay Calm With A 7,000 Ton Nuclear Predator Listening For Your Heartbeat?"
My Lua garbages (Github)
Post Reply

Return to “Lua Legion”