Merlin of Mines - Space Engineers

A set of useful scripts for aspiring Space Engineers!

View on GitHub

Camera Block Handler

This block handler enables you to programatically scan and detect entities from a camera.

This block handler makes significant use of the Camera Block’s Custom Data, so take heed in case you have another script/mod that needs Camera Custom Data.

Default Primitive Properties:

“Enabled” Property

Enables or Disables the given block

#Enable Block
enable "My Camera"
set "My Camera" to enabled

#Disable Block
disable "My Camera"
set "My Camera" to disabled

“Power” Property

Turns on or off power to the block. Effectively the same as the Enabled property.

#Turn on
turn on power to "My Camera"
power on "My Camera"

#Turn off
turn off "My Camera"
power off "My Camera"

“Range” Property

This property Get/Sets the range, in meters, for which the camera will scan when looking for entities. Since cameras do not have a property to store this value, setting this property will add a custom property to the Camera’s CustomData for this value.

Print "Camera Range: " + "My Camera" range

set "My Camera" range to 2000

“Trigger” Property

This property returns when the camera detects an entity. After an entity is detected you can use the “Target” and “Target Velocity” properties to get information about the detected entity. The triggered property obeys the “Range” property when attempting to detect entities. In other words, it will automatically wait until it can scan the requested distance.

Once an entity is detected, the entity’s coordinates and velocity are stored as Custom Data in the Camera.

If you set this property to true, it enables raycast on the camera.

#When is used so that the camera continually scans the requested range
set "My Camera" range to 2000
when "My Camera" is triggered
  Print "Detected an Entity!"
  Print "Target Coords: " + "My Camera" target
  Print "Target Velocity: " + "My Camera" target velocity

#Enable Raycast
tell "My Camera" to detect

“Target” Property

Returns the target coordinates, in World Coordinates, of the last detected entity. If no entity has been detected, returns 0:0:0.

when "My Camera" is triggered
  Print "Target Coords: " + "My Camera" target

“Target Velocity” Property

Returns the target velocity, oriented in World Coordinates, of the last detected entity. If no entity has been detected, returns 0:0:0.

when "My Camera" is triggered
  Print "Target Velocity: " + "My Camera" target velocity