LIDAR#

Warning

Deprecated. The LIDAR service will be removed in a future release. Use SpaceCenter.raycast_distance() instead.

Provides functionality to interact with the LiDAR mod.

LiDAR Replacement#

A LiDAR casts a fan of rays from its part. SpaceCenter.raycast_distance() casts one ray. This example casts 8 rays below the root part of the active vessel:

local krpc = require 'krpc'
local List = require 'pl.List'
local conn = krpc.connect('Raycast Example')
local sc = conn.space_center
local part = sc.active_vessel.parts.root
local frame = part.reference_frame

-- A fan of 8 rays below the part, 10 degrees apart
local origin = List{0, 0, 0}
for i = 0, 7 do
  local angle = math.rad(10 * i - 35)
  local direction = List{math.sin(angle), -math.cos(angle), 0}
  print(sc.raycast_distance(origin, direction, frame))
end