Space Engineers

Space Engineers

335 ratings
SHART | Script Handling Activation of Remote Timers
6
2
2
2
2
   
Award
Favorite
Favorited
Unfavorite
File Size
Posted
Updated
737.377 KB
30 Mar, 2021 @ 3:57pm
19 Jan, 2022 @ 4:50pm
5 Change Notes ( view )

Subscribe to download
SHART | Script Handling Activation of Remote Timers

In 1 collection by Whiplash141
Whip's Scripts
22 items
Description

  Description
Howdy!

This script allows you to trigger timers on other ships/stations that also have this script using antennas. This script can also act as both a sender and receiver.


  Features
  • Triggers timers on other ships using antenna-based communication
  • A single script can be used send/receive timer trigger requests
  • Animated send/receive indicator

  • New! - Can tie multiple timers to a single SHART!


  Setup Instructions
  1. Place this script in a programmable block.
  2. Place a timer block.
  3. Place at least one regular antenna or laser antenna.
    • Laser antenna need to actually be linked to another laser antenna to work
  4. Open the Custom Data of the programmable block and set "Timer to trigger on receive" to the name of a timer block. This timer will get triggered when a SHART message is received.
    • You only need to do this if you want to be a receiver. Senders are not required to have a timer configured.
  5. Recompile the script once you are done configuring.

Note: You must recompile the script to process any setup changes.


  Usage Instructions
When the script is compiled for the first time, your script gets assigned a randomly generated (and likely silly) name tag called a UID (Unique Identifier). The UID is sort of like the "address" for a programmable block. The UID is what other SHART scripts will use to send messages to this particular programmable block through the antenna network.

If you do not like the automatic Unique ID generated for you, you can change it in the Custom Data, then recompile.

Subaddresses
In the custom data of SHART, you can now configure a list of "subaddresses" which allows you to trigger different timers with a single programmable block.

If a subaddress is specified for an incoming SHART message, the script will trigger the timer associated with that subaddress (if it exists). You do not need to use subaddresses if you do not want to.

In the custom data, subaddress entries must be on their own line and in the form:
|<subaddress>,<exact timer name>

Example
Receive timer subaddresses= |primary,Timer Block 1 |secondary,Timer Block 2 |tertiary,Timer Block 3

Note: Subaddress names are whitespace sensitive. If you add whitespace after the comma or leave trailing whitespace after the name, it will be treated as part of the name. The subadddress snippit: "|primary, Timer Block 1" will process the name as " Timer Block 1" not "Timer Block 1".

Sending
To be able to successfully send a request, you must be able to reach the desired SHART program via using laser antenna or regular antenna. Messages will be automagically routed through the antenna network to reach the desired SHART program.

Also, it is worth noting that only allied antennas can receive your messages.

The argument
trigger UniqueIdGoesHere
will send a trigger command to the SHART program with the specified Unique ID.

The argument
start UniqueIdGoesHere
will send a start command to the SHART program with the specified Unique ID.

The argument
stop UniqueIdGoesHere
will send a stop command to the SHART program with the specified Unique ID.

To send a SHART message to a particular UID, you simply append the subaddress to the end of the above arguments. For example:
trigger UniqueIdGoesHere SubAddress

Receiving
To receive a request, you need to have an antenna (laser or regular) on your ship to receive messages with. You do not need to broadcast to be able to receive messages, so you can have stealthy receiver antennas that just listen for remote requests.

You also need to have a valid timer assigned to this program. You can configure the name of the desired timer in the Custom Data of the SHART programmable block.

When SHART receives a "trigger", "start", or "stop" message, it will perform the corresponding action on the assigned timer. If a subaddress is specified, the timer associated with that subaddress will also be triggered accordingly.


  Arguments
Argument        
Description
trigger UID
Sends trigger command to a SHART program with the specified Unique ID (UID).
trigger UID SUBADDRESS
Sends trigger command to a SHART program with the specified Unique ID (UID) and triggers the timer associated with the subaddress (if valid).
start UID
Sends start command to a SHART program with the specified Unique ID (UID).
start UID SUBADDRESS
Sends start command to a SHART program with the specified Unique ID (UID) and starts the timer associated with the subaddress (if valid).
stop UID
Sends stop command to a SHART program with the specified Unique ID (UID).
stop UID SUBADDRESS
Sends stop command to a SHART program with the specified Unique ID (UID) and stops the timer associated with the subaddress (if valid).
rename
Creates a new randomized Unique Identifier for this SHART program.


  FAQ
Can I customize the Unique ID of my program?
Yes. Simply change the Unique ID in the Custom Data of the programmable block to what you want, then recompile.

Can I send messages to multiple different SHART programs?
Yes. Since you are addressing the SHART programs by name, nothing is stopping you from sending commands to multiple SHART programs. You'd simply just run several different start, stop, or trigger commands.

Does my Unique ID need to be "unique"?
Not really, and nothing bad will happen if you share a UID with another SHART; just all SHARTs sharing the same UID will be triggered when a message is addressed to that UID.

Can a particular SHART trigger different timer blocks on receive?
Yes, see the documentation of SUBADDRESS above!


  Author's Notes
This is an absurdly simple script, and it is by no means the first of its kind, but I had a lot of fun writing it and coming up with the backronym.

This script started as a fun experiment with a random name generator. I didn't have a useful application, so I wrote the rest of the script to give it a purpose lol.

I personally use this script as a "garage door opener" that my fighters can use to open hangar doors on my carriers, but I'm sure y'all will come up with more interesting applications.

This script was also a testing ground for my SE Sprite Builder[gitlab.com] that I've been working on. I designed all the sprites in that app, then used the code exporter to easily generate boilerplate code that I use for the fancy graphics. It was significantly easier to design sprites this way as opposed to drawing it out on paper lol.

- Whiplash141
Popular Discussions View All (2)
7
20 Jan @ 10:32am
PINNED: Help and Questions (SHART)
Whiplash141
121 Comments
ZEALOT 12 Apr, 2024 @ 7:55am 
BEHOLD THE SHART
Whiplash141  [author] 9 Apr, 2024 @ 4:56pm 
@Terrance Hood:
CRAZY
John Helldiver 9 Apr, 2024 @ 2:51pm 
Call me crazy, but the acronym "SHART" is probably not the best choice.

Just sayin'
JoeHan 29 Mar, 2024 @ 2:45pm 
Hi Whiplash - great job at first! ;)

I initially had some trouble understanding/defining subaddressing.
After a while of guessing, I understood it - so here's a little explanation for dummies like me! ;D
How to handle the parameters> primary,Timer Block 1

name to call from remote real name of the addressed block
fe1, Timer Block fe1


Receive timer subaddresses=
|fe1,Timer Block fe1
|fe2,Timer Block fe2

If the receivers name is forexample this will be called from remote as
"trigger foreexample fe1" or "trigger foreexample fe2"

The subadresses will not work for only one defined subadress and its also unnecessary.
Only one line in the receive timer subaddresses section wont work.
Yadokanium 14 Feb, 2024 @ 7:02pm 
Hello Whiplash141
No, I'm connecting with a connector, not a merge.
↓Video of when the problem occurred
https://d.kuku.lu/ctefm7w2y
↓Video of normal operation
https://d.kuku.lu/pg7gb5rum
Whiplash141  [author] 14 Feb, 2024 @ 8:20am 
Are you using merges on your main ship to connect the drones?
Yadokanium 14 Feb, 2024 @ 1:32am 
Hello
I built a ship that can carry two drones that automatically return and dock. I am using this script to send a return signal to the drone that sent it, but only one of the two drones did not return even after I sent the signal. Both drones use the same UID, and if I directly recompiled the script for the drone that didn't return, it would work, but without recompiling, it wouldn't work no matter what I tried. Is there any solution?

(supplement)
This event occurs the first time the world is loaded.
Whiplash141  [author] 31 Dec, 2023 @ 8:21am 
Ahh that will do it :)
Stollie 31 Dec, 2023 @ 3:35am 
I think I figured out what happened before as well, checking the PB on my carrier, it says when I do "trigger Drone 2" its sending it to "Drone" sub address "2", the UID on my Drone is "Drone 2". If I change it to "Drone2" instead no issues.

Which according to the above is expected behaviour so user error :D
Stollie 31 Dec, 2023 @ 1:51am 
Hey Whiplash,

Thanks for your help before.

Would it be possible to have this script not require a recompile to recognize the custom data changes?

I am using another script I wrote for setting up a new carrier drone (trying to make it as automated as possible) and in that script I'm parsing the custom data of my SHART PB to update with the correct information, however, it still requires the user to go in and hit the recompile button which could be easily missed during setup of a new drone and as far as I know there is no way to trigger a recompile of another PB block.