Merlin of Mines - Space Engineers

A set of useful scripts for aspiring Space Engineers!

View on GitHub

Sound Block Handler

This Block Handler handles Sound Blocks. With it you can play/stop, change the song, change the loop period, the volume, and the range.

Default Primitive Properties:

“Enabled” Property

Enables or Disables the given block

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

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

“Power” Property

Same as Enabled. Gets/Sets whether the speaker is currently enabled.

if "My Speaker" is powered
  Print "Speaker is enabled"

#Enable speaker
power on "My Speaker"

#Disable speaker
power off "My Speaker"

“Volume” Property

Gets/Sets the volume of the speaker. Values are between 0 - 1, with 1 = 100% volume.

Print "Speaker Volume: " + "My Siren" volume

#75% Volume
set "My Siren" volume to 0.75

“Radius” Property

Gets/Sets the radius the speaker plays sound within, in meters.

Print "Speaker Range: " + "My Speaker" radius

#50 meters
set "My Speaker" radius to 50

“Range” Property

Same as Radius. Gets/Sets the range the speaker plays sound within, in meters.

Print "Speaker Range: " + "My Speaker" range

#50 meters
set "My Speaker" range to 50

“Period” Property

Gets/Sets the loop period for the speaker, in seconds. Effectively this is how long the speaker will play before stopping, unless you stop it manually

Print "Loop Period: " + "My Speaker" period

#Play for 1 minute
set "My Speaker" period to 60

“Sound” Property

For Booleans, Gets/Sets whether the speaker is currently playing. Retrieving will return true if and only if the following conditions are met:

When setting, will either play or stop the music based on the boolean value.

For Strings, Gets/Sets the currently selected sound, regardless of whether it is currently playing or not. Setting the sound will not immediately cause the speaker to start playing. You’ll need to ask it to “play” (using Bool) after setting the sound.

When retrieving this property without indicating Bool or String, the currently selected song is returned.

#Check if playing
if "My Speaker" is playing
  Print "Rock on"

#Play currently selected sound.
play "My Speaker"

#Stop playing
tell "My Speaker" to stop playing

#Retrieve current sound
Print "Current Sound: " + "My Speaker" sound

#Check if currently selected song is the specified one, regardless if it is currently playing or not.
if "My Speaker" is playing "My Music"
  print "I love my playlist.."

#Set Speaker sound.  Does not cause speaker to play
set "My Speaker" sound to "SoundBlockLightsOn"

“Sounds” Property

Returns a list of currently available sounds which you can set the speaker to play using the Sound property.

Print "Available Sounds: " + "My Speaker" sounds

Here’s a fun little script to sample the available music. You can imagine extending this to create your own custom playlist to provide background music.

for each mySong in "Test Speaker" songs
  set the "Test Speaker" song to mySong
  play the "Test Speaker"
  set i to 0
  until i > 120
    print "Current Song: " + mySong
    i++