Space Engineers

Space Engineers

Not enough ratings
Docking Action
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
3.433 KB
5 Nov, 2016 @ 9:40pm
17 Nov, 2017 @ 4:24pm
4 Change Notes ( view )

Subscribe to download
Docking Action

Description
2017-11-17 Update: No longer needs a timer block. If you had one before, I recommend you "disconnect" it from the prog block (remove all its actions) to reduce surprises.

Note 2016-12-29: Looks like they added an option for sensors to detect subgrids. I haven't tested it yet (because the game seems pretty buggy at the moment), but this script may no longer be needed.

Very simple script that lets you group a connector with other blocks and then have those blocks turn off/on when the connector is connected or disconnected.

In the past, we used to be able to use sensors to detect docked ships. But I believe this changed around the time connected grids essentially became merged (as an effort to stave off CLANG, I'm sure).

Note that if you're one of the few users of my Ship Manager script, this module is already included. Just set up the groups as described here. (And make sure it's actually enabled -- it's the DOCKING_ACTION_ENABLED switch near the top of the script.)

Setup
  1. Load into programmable block
  2. Set up block groups as described below.
Docking Action Groups

You can set up as many groups as you like (within reason, since it will attempt to process all of them in a single run).

Simply:
  • Select exactly one connector
  • Additionally select as many other blocks as you like (again, within reason :P). These should be blocks that have an actual "On/Off" button in the terminal. Interior lights are a good example.
  • Create a block group around the connector/blocks with the name: DockingAction<whatever>:<state>
The <whatever> can truly be whatever and will be used to distinguish different groups.

The <state> is either the word "on" or "off". Letter case doesn't matter.

When <state> is on, blocks grouped with the connector will be turned on when something connects. When the connector is disconnected, the grouped blocks are turned off.

When <state> is off, the opposite is true. So when the connector is connected, blocks are turned off, etc.

May or may not work with modded blocks. I've never tried.

Not sure what happens when you group a connector with blocks you can't normally turn on/off.

The code only runs every 3 seconds.

Examples

DockingAction1:off
DockingAction2:off
DockingAction3:off
DockingActionPort:On
DockingActionBlahBlah:ON

If you need to see a concrete example, the 8 docking connectors on my survival ship have an associated light that turns off when the docking connector is occupied.
10 Comments
That One R.O.B. 29 Aug, 2017 @ 10:23am 
This script is very close to something I'm looking for and was wondering if you could make something that would work. I am looking for a script that will open or close doors based on the status of a connector or merge block. Let me know if you can make a script that will work for this please.
ZerothAngel  [author] 27 Feb, 2017 @ 8:58am 
Oh, I misunderstood you. I thought you meant locking/unlocking landing gear based on the state of a connector.

But you mean turning other blocks on/off based on the state of landing gear (instead of a connector).

It may have been possible to read them the same in the past (they both have an "IsLocked" property), but that isn't really supported anymore on connectors (you have to use "Status" instead). So landing gear would need its own special case.
woostyboy 27 Feb, 2017 @ 7:40am 
Wondered if a landing gear lock is the same (in scripting terms) as a connector lock.
woostyboy 27 Feb, 2017 @ 7:39am 
OK thanks. There are other scripts that can create an action based on an event. I'm not a programmer but something like if landing gear lock = true, then arm warhead etc.
ZerothAngel  [author] 27 Feb, 2017 @ 7:26am 
I haven't tried, but probably not. The lock/unlock actions are different from the on/off actions that this script normally sends. Maybe a plain sensor block will work?
woostyboy 27 Feb, 2017 @ 6:44am 
Hey Zero
Do you know if this can be used with landing gear too?
Thanks.
CONS 6 Nov, 2016 @ 10:40am 
ohhh.... tough differently, great thanks!
ZerothAngel  [author] 6 Nov, 2016 @ 8:21am 
And, I think, you can mix them (by using the same connector in the different groups). Some lights turn on when something docks, others turn off...

So it should be quite flexible...
ZerothAngel  [author] 6 Nov, 2016 @ 8:19am 
I don't think I understand your request.

The script can handle "lights turn on when something docks" OR it can do "lights turn off when something docks"

It just depends on what you name the group.
CONS 6 Nov, 2016 @ 1:11am 
Hello zeroth, the script works pretty well, but I think that what almost everybody is looking around, w/o any chance to finding something working is a script that simply light on, some lights when the ship is connected too... Can you just add this option to your script? Should not be so complex since it's the inverse of what your script mostly do.