Merlin of Mines - Space Engineers

A set of useful scripts for aspiring Space Engineers!

View on GitHub

Assembler Block Handler

This block handler controls Assemblers. It lets you select assembly, disassembly, or cooperative mode. Most importantly, this Block Handler allows you to create and destroy items in your script.

For more information on what items you can create or destroy, see Items & Blueprints

“Enabled” Property

Enables or Disables the given block

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

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

“Power” Property

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

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

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

“Supply” Property

Not to be confused with Create/Destroy properties, this property sets whether the assembler is in Assembling or Disassembling mode. To actually create or destroy items, use the Create & Destroy properties.

set the "Base Assembler" to assembling
tell the "Base Assembler" to assemble

“Complete” Property

Returns false if there are any items in the queue. Clears the queue if updating with a false boolean value. Set Complete to false to clear the queue. Setting it to true does nothing. The inverse keywords “clear”, “wipe”, and “erase” also clear the queue.

#Check if the assembler is finished
if the "Base Assembler" is finished
  Print "Finished creating stuff!"

#All of the below will clear the assembler queue
clear the "Base Assembler"
tell the "Base Assembler" not to finish

#Does nothing
tell the "Base Assembler" to finish

“Build” Property

Returns true if there are any items in the queue. Clears the queue if updating with a false boolean value.

#Check if the assembler is building
if the "Base Assembler" is building
  Print "Still creating stuff!"

#All of the below will clear the assembler queue
tell the "Base Assembler" to stop building

#Does nothing
tell the "Base Assembler" to build

“Auto” Property

This property gets or sets whether the assembler is in cooperate mode or not. Cooperating assemblers will take items from a non-cooperating assembler and build them automatically.

tell "My Assembler" to cooperate

if "My Assembler" is cooperating
  Print "They tell me what to build, and I build it."

Here’s a script to set the first assembler as the main assembler and the rest as cooperative.

set myAssemblers to "My Assemblers"
tell $myAssemblers[0] not to cooperate
if count of $myAssemblers > 1
  tell $myAssemblers[1..count of $myAssemblers - 1] to cooperate

“Create” Property

This property enables you to automatically queue up items to be built on the given assembler(s). This property requires a String attribute representing the items(s) to create. If the items to create represent more than 1 resolved blueprint, the assembler will produce the indicated amount of each item.

If the given selector has more than 1 assembler, the requested items are sent to each assembler, not distributed across them.

When retrieving the property value, the result is a boolean representing whether the assembler is creating the given item(s). If any of the requested items are being built, it will return true.

The check uses the total queued amount across all matching blueprints and requires Assembly mode. It returns true when that total meets the requested amount (1 by default). Use the Amount property to retrieve the numeric total.

#Check if the assembler is creating steel plate
if "My Assembler" is creating "steel plate"
  Print "Still creating steel plate"

When you use this property to create an item, it automatically switches the Assembler mode to “Assembly”. Also, when creating items, you can specify the amount that you would like to create.

#Create 1 steel plate
tell "My Assembler" to create "steel plate"

#Create 10 steel plate
tell "My Assembler" to create 10 "steel plate"

#Create 1 steel plate and 1 interior plate
tell "My Assembler" to create "steel plate, interior plate"

#Create 10 steel plate and 10 interior plate
tell "My Assembler" to create 10 "steel plate, interior plate"

“Destroy” Property

This property enables you to automatically queue up items to be destroyed on the given assembler(s). This property requires a String attribute representing the items(s) to destroy. If the items to destroy represent more than 1 resolved blueprint, the assembler will destroy the indicated amount of each item.

If the given selector has more than 1 assembler, the requested items are sent to each assembler, not distributed across them.

When retrieving the property value, the result is a boolean representing whether the assembler is destroying the given item(s). If any of the requested items are being destroyed, it will return true.

The check uses the total queued amount across all matching blueprints and requires Disassembly mode. It returns true when that total meets the requested amount (1 by default). Use the Amount property to retrieve the numeric total.

#Check if the assembler is destroying steel plate
if "My Assembler" is destroying "steel plate"
  Print "Still destroying steel plate"

When you use this property to destroy an item, it automatically switches the Assembler mode to “Disassembly”. Also, when destroying items, you can specify the amount that you would like to destroy.

#Destroy 1 steel plate
tell "My Assembler" to destroy "steel plate"

#Destroy 10 steel plate
tell "My Assembler" to destroy 10 "steel plate"

#Destroy 1 steel plate and 1 interior plate
tell "My Assembler" to destroy "steel plate, interior plate"

#Destroy 10 steel plate and 10 interior plate
tell "My Assembler" to destroy 10 "steel plate, interior plate"

“Amount” Property

This property is similar to create/destroy, but the read value is a numeric. This allows you to get the amount of item(s) being produced.

Note that this property does not look for the amount of items in the Assembler’s Inventory. It is the amount of items in the Assembler’s Production Queue. To get the amount of item’s in the Assembler’s inventory, you will need to use the Inventory Handler

This property adds the requested amount to the queue; it does not replace an existing queued amount or automatically switch the Assembler mode.

#Check if the assembler is creating/destroying at least 10 steel plate
if "My Assembler" "steel plate" amount > 10
  Print "Still creating steel plate"

#Create/Destroy 1 steel plate
set "My Assembler" "steel plate" amount to 1

#Create/Destroy 10 steel plate
set "My Assembler" "steel plate" amount to 10

#Create/Destroy 1 steel plate and 1 interior plate
set "My Assembler" "steel plate, interior plate" amount to 1

#Create/Destroy 10 steel plate and 10 interior plate
set "My Assembler" "steel plate, interior plate" amount to 10

“Types” Property

Gets a list of BlueprintIds currently being produced by the given assembler. This is mostly used to get custom item BlueprintIds used to create custom items, so that you can create those items yourself.

The returned list will be a list of the BlueprintIds for all items in the assembler production queue, with duplicates removed.

set myProducingTypes to "My Assembler" types

print "Producing Types:\n" + myProducingTypes joined "\n"

Examples

Here’s a script to automatically recycle basic tools. Combine this with a sorter for weapons/tools set to drain and you’ve automated recycling!

#Setup
set recycleAssembler to "Recycling Assembler"

async doRecycle "steel plate"

:doRecycle itemName
#Dynamic variable for the amount left to recycle
bind recycleAmount to the $recycleAssembler inventory itemName amount

#Recycle the amount iteratively until we're done
until recycleAmount is 0
  tell $recycleAssembler to recycle recycleAmount itemName
  until recycleAmount is 0 or $recycleAssembler itemName amount is 0
    set my display to "Amount to Recycle: " + recycleAmount

#Once we're done, update the display and stop the Assembler
set my display to "Nothing to Recycle"
stop $recycleAssembler
replay

Production status

running (read-only Boolean) requires both a working block and active production. Disabled or unpowered blocks report false, even if the game retains its previous production flag. progress / ratio (read-only Numeric) reads current job progress, not overall queue completion. The existing recipe-qualified producing keyword is unchanged. Food Processor extends this handler; Survival Kits also remain accessible as assemblers.