Merlin of Mines - Space Engineers

A set of useful scripts for aspiring Space Engineers!

View on GitHub

Battery Block Handler

This block handler is all about batteries. Keep your ships powered and monitor battery levels so you’re never without power.

Default Primitive Properties:

Default Directional Properties

“Enabled” Property

Enables or Disables the given block

#Enable Block
enable "My Battery"
set "My Battery" to enabled
turn on "My Battery"

#Disable Block
disable "My Battery"
set "My Battery" to disabled
turn off "My Battery"

“Power” Property

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

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

#Turn off
turn off power to "My Battery"
power off "My Battery"

“Supply” Property

This property sets whether the battery is set to “Auto” (discharging) or “Recharge” (recharging).

#Check if batteries are recharging
if the "Ship Batteries" are recharging
  Print "Don't disconnect or you'll be sorry!"

#Recharge the batteries
tell the "Ship Batteries" to recharge

#Supply
tell the "Ship Batteries" to generate
tell the "Ship Batteries" to supply

#Stop recharging (same as supply)
stop recharging the "Ship Batteries"
tell the "Ship Batteries" to stop recharging

If you really want to set a battery to discharge (vs auto), you can do this with the “ChargeMode” dynamic property:

#Sets the battery to Discharge
set the "Test Battery" "ChargeMode" property to 2

“Auto” Property

Gets or Sets whether the battery is currently in “Auto” mode. If set to false, the battery mode is set to recharge.

#Check if batteries are on auto
if the "Ship Batteries" are on auto
  Print "Safe to take off!"

#Set the batteries to auto
set the "Ship Batteries" to auto

“Limit” Property

Gets the maximum amount of power that the given battery is able to store, in MW.

Print "Max Stored Power: " + the "Ship Batteries" limit

“Ratio” Property

Returns a value between 0 and 1 representing the ratio of stored power / max stored power.

#Since aggregations use sum by default, make sure to use avg.
#The sum of battery ratios doesn't make much sense.
Print "Charge Percentage: " + the avg "Ship Batteries" ratio

“Level” Property

Returns a value representing the current stored power in the battery, in MW.

#This property can be sumed since levels are totals
Print "Power Level: " + the "Ship Batteries" level

“Input” Property

Returns a value representing the current input power to the battery, in MW / s.

Print "Current Power Input: " + "Ship Batteries" input

“Input Limit” Property

Gets the maximum amount of power that the given battery can receive as input, in MW.

Print "Max Power Input: " + the "Ship Batteries" input limit

“Output” Property

Returns a value representing the current output power from the battery, in MW / s.

Print "Current Power Output: " + "Ship Batteries" output

“Output Limit” Property

Gets the maximum amount of power that the given battery is able to output, in MW.

Print "Max Power Output: " + the "Ship Batteries" output limit