Space Engineers

Space Engineers

65 ratings
SE Macros manual
By Cruel Sun
Manual for the SE Macros in-game script
3
   
Award
Favorite
Favorited
Unfavorite
Introduction
This in-game script is a simple solution for simple algorithms. A good choice if you don't know C#.

All the code is stored in the CustomData of the Programmable block.

You can Run to start it from the beginning or set as parameter #Any Line to start from it.

Added in 1.50. Now it possible to use the Run parameter for short commands
For example, you can run it with parameter *light*:OnOff to switch all the lights
Also you can use // to send many of commands, like
Command one // Command two // ... // ...
Example: Rotor:V=R//Delay 12//Repeat
Will reverse the rotor block velocity every 2 seconds

Parameter Stop is stopping the current job.

Examples

Custom Data text
Reactor *:Off
Simple Run turns off all the reactors

MyDoors:Close
Closes all the doors of MyDoors group. Group name will be searched if no blocks has this name.

Piston A:V=5
Sets the velocity for all the piston named Piston A

Spotlight *:On Delay 18 Spotlight *:Off Delay 18 repeat
Toggle on/off for all the spotlights every 3 seconds (1 second is 6 ticks on Sim speed 1)

(Rotor?A<15)Rotor:V=1;Spotlight *:Color=255,0,0 (Rotor?A>345)Rotor:V=-1;Spotlight *:Color=0,255,0 repeat
Handles a rotor velocity by the rotor angle and changes the Spotlights color (R G B)
Usage - Commands
Usage

[Block Name]:[Command]
Block name - case sensitive, for all the blocks with this name.

[Block Name *]:[Command]
* - use as mask filter

[Block Name]:[Command]
Block name - if there is no block with this name, group names will be searched

[Block Name]:[Command][;[Block Name]:[Command]][;[Block Name]:[Command]][...]
By default the script works one line per tick (6 lines per second), so you can have many of command per tick

[Command]

Commnds are not case sensitive.

Any command works only with blocks of the appropriate type

Command table
Command
Action
Block type
An example


Open, Close
Door Opening/Closing
Any type of door
MyDoor:Close
V=##, V=-, V=+, V=R
Set the velocity, (decrease, increase, reverse), Gravity acceleration for Gravity Generators
Pistons, Rotors (advanced too), Gravity Generators
Piston 2:V=3
H=## (float Meters), H=-, H=+, H=R
Set the rotor displacement, (decrease and increase by 5cm, reverse)
Rotors (advanced too)
*rotor*:h=-0.1 will set -10cm
Value
For pistons: sets the Upper and Lower limit and reverse if it's required
For Gyroscopes: sets Pitch,Yaw,Roll
Piston
Gyroscope
Piston *:MaxD=10
Gyroscope:Value=0.5,0,-0.3
(Use Gyroscope:Release to stop overriding)
Value+, Value-, Value+##, Value-##
For pistons: sets the Value by increasing or decreasing current value
Piston
Piston *:Value- (decrease by 1m)
Value-2.5 (decrease by 2.5m)
MaxD, MinD (MinD/MaxD=-,=+ to decrease and increase)
Value for the Upper and Lower limit of a Piston
Piston
Piston *:MaxD=10
Attach, Detach
To attach / detach block head
Piston, Rotor, Adtanced rotor
Piston 2:detach, Rotor*:detach
AutoLockOn,AutoLockOff
AutoLock value
Landing gear
Landing gear:AutoLockOn
Lock,Unlock
Lock/Unlock
Landing gear
Landing*:Unlock
LockOn,LockOff
Rotor lock value
Rotor
Advanced rotor:LockOff
UpLimit, LowLimit
Upper and lower limit
Rotor
Rotor:LowLimit=-90
A=##
Turns (slowly and carefuly) to the Angel
Rotor
Rotor 2:A=60
A=V
Turns the Rotor by grid velocity (like a Bugatti back wing)
Rotor
Back Rotor:A=V
Blink=##
Blink value
Lights
Spotlight 22:Blink=2
Color=R,G,B
Color value
Lights
Spotlights *:Color=100,150,200
ArrangeTo GPS..
Grid will be arranged to selected point (by selected block, and if there are the gyros)
Any types
Connector 2:ArrangeTo GPS:MyDock:1:2:3
ArrangeToSence [SensorBlock]
Grid will be arranged to active target of SensorBlock. Like tracking projector.
Any types
Spotlight:ArrangeToSence Sensor
ArrangeToPlanet
Grid will be arranged to the nearest planet
Any types
Down Thruster:ArrangeToPlanet
Connect, Disconnect
Lock/Unlock
Connector
Connector 3:Disconnect
Waypoint=GPS..
Turn autopilot to the selected point
Remote control
RemCom:Waypoint=GPS:Home:1:2:3
HudText
HudText value
Radio Antenna, Beacon
(EnemyDetected)Beacon:HudText=I see you maggot
Range
Sets a Radius or range
Laser Antenna, Radio Antenna, Beacon, Sound block, Light block
Say Stealth mode On
*Antenna*:Range=100; Beacon*:Range=100
ArrangeToStop
For non gravity. Turns your grid against velocity. Useful when you have only to one side directed thrusters (as a rocket) or you have a massive cruising engine and want to stop fast as you can.
All types
MyBlock:ArrangeToStop
ArrangeToEnemyBy
Targeting by a turret or sensor.
All types
Rocket Launcher:ArrangeToEnemyBy Interior Turret
Shoot
Simple one shoot
All type of guns
Rocket Launcher:Shoot
Thrust=##%
Thrust value in %
All types of thrusters
GroupToBack:Thrust=100
Play, Stop, Loop=##(seconds), Sound=SongName
Sound block commands.
Sound block
Sound block:Stop
Sound block:Sound=Alert 1
Sound block:Loop=1800(max value)
Sound block:Play
Text=$$
Scr#=$$
Value for TextPanel/Panel number (Text/Images content must be selected)
#time, #gps, #speed - you can use as regular exp.
Text Panel, Surface provider(blocks with LCDs)
*LCD*:Text=The End
Fighter Cockpit:Scr0=Hello
(IsDamaged)LCD Black Box:Text=Last Damage:\n#time\n#gps\n#speed
TextColor=R,G,B
BackGroundColor=R,G,B
Value for LCD TextPanel (Text/Images content must be selected)
LCD Text Panel
*LCD*:TextColor=255,0,150
*LCD*:BackGroundColor=25,0,0
Text=Damage
Scr#=Damage
Damaged block list
Text Panel, Surface provider
*LCD*:Text=Damage
Fighter Cockpit:Scr0=Damage
TextAdd=$$
Scr#Add=$$
Adds text to the end
Text Panel/Surface provider
*LCD*:TextAdd=New one
Industrial Cockpit:Scr1Add=Hello
TextInsert=$$
Scr#Insert=$$
Adds text to the beggining
Text Panel/Surface provider
*LCD*:TextInsert=New one
Industrial Cockpit:Scr1Insert=Hello
TextLine=$$
Line effect for text (there is a video preview)
Text Panel
*LCD*:TextLine=Welcome home
TextFrom=BlockName
Scr#From=BlockName
Writes info of a block
at now: SolarPanel, Battery, Thruster, Motor, Piston, TextPanel, Cargo, Landing Gear, Reactor, Door, Laser Antenna, Camera, Connector, Welder, Refinery other blocks turned on/off
LCD:TextFrom=Piston 2
Console Block:Scr0From=Battery
TextRead=$$
Typing effect for text (there is a video preview)
Text Panel
*LCD*:TextLine=Welcome home
Run, Run=$$
Runs the Programmable block with parameter
Programmable block
MyProgrammableAssistant:Run=Say Hello World
Start,Stop, Delay=##, Activate
Timer block support. Delay in seconds. Activate is Trigger now command.
Timer block
Timer*:Stop (Will stop all the Timers)
Start,Stop, Time=##, Detonate
Warhead block support. Time in seconds.
Warhead block
(Speed>90)Warhead*:Detonate (Mad joke)
GPS
Sends GPS coordinate of block to the block CustomData
All types
Connector*:GPS
Mode
- Battery : Charge mode = Auto/Recharge(or In)/Discharge(or Out)
- Hydrogen Tank : Stockpile value = In/Out
Battery
Hydrogen Tank
(Connector?Connected) Goto Docked
Battery*:Mode=Auto
Repeat

Docked
Battery*:Mode=Out
Repeat
Commands - On Off OnOff
Turns on, off, toggle the block

Can be used with
  • Any types of blocks

Usage
MyBlock:On MyBlock:Off MyBlock:OnOff
Commands - Open Close
Door Opening/Closing

Can be used with
  • Any type of door

Usage
MyDoor:Open MyDoor:Close
Commands - Title
A text value for the block Title

Can be used with
  • TextPanel

Usage
MyTextPanel:Title = Right here
Usage - Directives
Directives works without the blocks.

[Directive][ Parameter]

Directive table
Directive
Action
An Example
Stop
Stops the script
Stop
Repeat
Runs the script from the begining
Repeat
Goto [Any text]
Goto $$//$$...
Script jumps to selected line. No restrictions. Can be conditional.
You can set Line 1//Line2// ... to get a random line
Goto Step 1
(Spotlight A?On)Goto Last step
Goto Step X//Step A//Exit
Say [Text]
Sends text to the PB details, works with #time, #gps, #speed
Say Hell World
ClearLog
Clears PB screen
ClearLog
Delay ##
Delay for ticks * TickRatio(1 second is 6 ticks)
Delay 60
(Delay for 10 seconds
TickRatio ##
How many of ticks will took one line, 1 by default. For example, if you set TickRatio 24, one line will took 4 seconds.
TickRatio 180
Light:On
Light:Off
Repeat
(30 sec on, 30 sec off)
Reboot
Device list update
Reboot
Dampeners On,Off
Dampeners, work for non static grids, and you need to built at least one thruster
Dampeners On
Brake On, Off, OnOff
(P key) works if you have a wheel
Brake On
Doctor On, Off
Damaged blocks will mark with ShowOnHUD
Doctor On
Delay 12
Repeat
CheckWheels
Adds all lost wheels to the grid
CheckWheels
StackCargo
Organize all items in all inventories
Delay 300
StackCargo
Repeat
Once per 5 min
GridName=$$
Set the Grid Name
GridName=Base X01
OptimizeTurrets
For all turrets: No idle move and Maximum Range
OptimizeTurrets

Standalone description for Unload command (from my Gravity Engine)
Instruction
Description
Unload
Unloads your Grid (if its connected)
Unload [mask] ([mask] ...)
Transfers only specified types of content. Works by the mask. You can use short and entire words. Also works well Unload Ore Ammo Rifle
Content is only transmitted in cargo containers. The Script don't put resources in refineries, assemblers, connectors and etc. as a ♥♥♥♥♥ thief in his pockets

More example words:
  • Types : Ammo Component Gun Ingot Ore Oxy Drill Welder Grinder Rifle Bottle
  • Components : BulletproofGlass Canvas Computer Construction Detector Display Explosives Girder GravityGenerator InteriorPlate LargeTube Medical MetalGrid Motor PowerCell RadioCommunication Reactor SmallTube SolarCell SteelPlate Superconductor Thrust
  • Ore and Ingot names : Cobalt Gold Iron Magnesium Nickel Platinum Silicon Silver Stone Uranium
    Use Ore/Cobalt for Ore and Ingot/Cobalt for Ingots. (Unload Ore/Uran)
  • Oxygen and Hydro : Oxy Gas
  • Guns and Tool names :
    Rifles: /AutomaticRifle Precise Rapid Ultimate
    GrinderItem Grinder2 Grinder3 Grinder4
    DrillItem Drill2 Drill3 Drill4
    WelderItem Welder2 Welder3 Welder4
Usage - Branching
Usage

([Block]?[Condition])[My line][;second..] or ([Condition])[My line][;second..]

An example
(Rotor?A 200 to 300)Spotlight *:On

Table of conditions

Condition
Action
An Example
On, Off
IsTurnedOn
(Solar panel?On)*LCD*:On
DetailsHas
Active when a block details text has some text
(Railgun?DetailsHas : 0 sec) Spotlight:On
activates when a gun is reloaded
Opened, Closed
IsDoorOpened
(Front door?Opened)Back door:Close
Locked, Unlocked
IsLandingGearLocked
(Landing Gear?Locked)Door:Open;Spotlight *:On
Connected, Disconnected
Connectors state
(MyConnector?Connected)Spotlight *:On
Repeat
A=,>,<,to
Rotors Angle
(Rotor?A<60)Spotlight:Color=255,0,0
Pressured, Unpressured
Vent status
(*Vent*?Unpressured)Door*:Close
SunPower<,SunPower>
Current output for a Salar Panels in %
(Solar*?SunPower<15)*light*:On
SunMaxPower<,SunMaxPower>
Current Maximum output for a Salar Panels in kW
(Solar*?SunMaxPower>3)*light*:On
StoredPower<,StoredPower>
Current stored power of battery in %
TickRatio 360
(MyBatteryGroup*?StoredPower<10)Hydro*Engine*:On
(MyBatteryGroup*?StoredPower>90)Hydro*Engine*:Off
Repeat
Script will check the battery stored power every 2 min
Output<,>
Current power output of battery in %
TickRatio 30
(Battery 2?Output<10)Large Reactor:Off
(Battery 2?Output>95)Large Reactor:On
Repeat
Speed<,>
Grid speed value
(Speed<10)BackLights:On
Altitude<,>
Current altitude on the planets value

(Altitude>5000)AirThrusters:Off
Gravity, NoGravity
Is gravity present
(NoGravity)Thruster one:ArrangeToStop
DistanceTo GPS <,>
A distance to GPS point value
(DistanceTo GPS:Earch:0:0:0 < 50000)Signals:On
EnemyDetected
Works if you have some turrets or sensors with Enemy Detection
(EnemyDetected)Signals:On;Sound*:On
DistanceToEnemy<##
The detection of enemies by all the sensors and turrets
(EnemyDetected)Goto Alarm
Spot*:Color=0,255,0
Repeat
Alarm
(DistanceToEnemy<200)Goto Red
Spot*:Color=255,255,0
Repeat
Red
Spot*:Color=255,0,0
Repeat
Active
for Cockpits - when is under control
for Sensor - if Sensor has target
for JumpDrive - If it Ready to jump
(Cockpit?Active)Goto Welcome
Cargo>##, Cargo<##
Current value of Cargo container in %
(MyCargo?Cargo>90)Drills:Off
Distance>##, Distance<##
For camera blocks
(Front Camera?Distance>90)Drills:Off
Up, Down, Left, Right, Forward, Backward, RollLeft, RollRight
For Ship Controller blocks
(*Seat?Up)Piston:Value+
IsDamaged
When the Grid has any damages
(IsDamaged)Goto Home
Repeat
Home
Remote Control:WayPoint= GPS:Home:9703.35:8482.14:-10911.7:
HackWarning
When the Grid has being hacked
(Hack Warning)Goto Warn
Repeat
Warn
Rotating Light:On
AlienBlocks
When the Grid has blocks of other owners
(Alien Blocks)Goto Warn
Repeat
Warn
Rotating Light:On
Gravity=#.#
Gravity<#.#
Gravity>#.#
Natural gravity value, rounding to one decimal place
(Gravity<0.45)HydrogenThrustersGroup:Off
Repeat
Value=#.#
Value<#.#
Value>#.#
Value for pistons(in meters) and thrusters(in %), rounding to one decimal place
(Thruster?Value>95) RedLights:On
Repeat

At now it's all. Any suggestions and corrections are welcome.
Script options
Is on the head of the Script

RayCastEnable
The enabling of the raycast function also activates all the blocks of the camera.

RayCastDistance
A maximum distance of the raycasting.

ShowDebugMessages
Showing the Debug Messages in the PB details

RealTimeProcess
By default the Script works with Update10 - 6 times per second
On true the Script will work 60 times per second - Update1
More examples
Semiautomatic docking
(Connector?Connected)Stop Connector:ArrangeTo GPS:Dock:560:456:879 Connector:Connect Repeat

Space Defence bot
Rocket Launcher:ArrangeToEnemyBy Gatling Turret Rocket Launcher:Shoot Repeat

Automatic Ore (for example) unloading
Connector:Connect (Connector?Connected) Goto -Unload Me- Repeat -Unload Me- Unload Ore Connector:Disconnect Say Unloading Complete

Simple run - Turn the grid off (like Sleep mode, for simspeed purposes), Run #On to turn on
*:Off;*Macro:On;Reac*:On Stop On *:On

TickRatio / HudText / Repeat


Cargo>##, Cargo<## / TextLine= / TextRead=


IsDamaged

Satellite example
(NoGravity) Goto Space (Speed<85) Hydrogen Thrusters*:thrust=100 (Speed>95) Hydrogen Thrusters*:thrust=0 Hydrogen Thrusters:ArrangeToPlanet Repeat Space Hydrogen Thrusters*:thrust=0 Small Control Seat: ArrangeToStop

AutoLight example
(Solar Panel 1?SunPower<5) Goto Lights:On Lights:Off Repeat Lights:On Repeat

Cockpit move indicator (WSAD QE C Spacebar keys)
(Industrial Cockpit?Forward) Goto FW (Industrial Cockpit?Backward) Goto BW (Industrial Cockpit?Up) Goto UP (Industrial Cockpit?Down) Goto DW (Industrial Cockpit?Left) Goto LF (Industrial Cockpit?Right) Goto RT Piston A:V=0 Piston B:V=0 Advanced Rotor:V=0 Repeat FW Piston A:V=3 Repeat BW Piston A:V=-3 Repeat LF Piston B:V=-3 Repeat RT Piston B:V=3 Repeat UP Advanced Rotor:V=5 Repeat DW Advanced Rotor:V=-5 Repeat
98 Comments
Taurum_45 19 Apr, 2023 @ 6:56am 
Thank you for info guys and your efford. I really appreciate that.
I hope that this feature will be someday in vanilla.
Cruel Sun  [author] 18 Apr, 2023 @ 12:46pm 
Shadow_knight Automation don't creates miracles
Shadowpheonix 18 Apr, 2023 @ 12:44pm 
Unfortunately, it is not possible through scripts. It requires support in Space Engineers that Keen does not provide, and thus the need for a plugin.
Taurum_45 18 Apr, 2023 @ 12:05pm 
Yes, but I thought that this script can do the same, through commands
Shadowpheonix 18 Apr, 2023 @ 8:39am 
@Shadow_Knight - I believe what you are looking for is...
https://github.com/austinvaness/CameraLCD
Unfortunately, the mod is no longer available on Steam (apparently Keen decided they didn't want "Plugin" mods in the Workshop).
Taurum_45 17 Apr, 2023 @ 11:00pm 
I don't know how say it in another way, but i mean something like security kamera on the other side of building or vehichle and wiev from camera is shown on LCD like on monitor
Cruel Sun  [author] 17 Apr, 2023 @ 2:44pm 
Shadow_knight question about updateble raycast info on LCD? or I don't get it.
Taurum_45 17 Apr, 2023 @ 12:41pm 
Is there way to use camera on LCD panels lake life feed transmision ?
Shade 30 Mar, 2023 @ 11:23am 
Oh, it has self-resolved now. I understood that set 361 / -361 makes Unlimited.
Shade 30 Mar, 2023 @ 6:39am 
Hello. A question about the command of UpLimit / LowLimit.
Can I set it "Unlimited"? Or is it supported only number of 0~360?