Space Engineers

Space Engineers

126 ratings
SE - SAMv2 Configuration guide
By Magistrator
Configuration guide for using SAMv2 script for Space Engineers.
4
   
Award
Favorite
Favorited
Unfavorite
What is this?
SAMv2 - a script for Space Engineers

https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=1653875433

  • Have your ship autonomously and automatically fly between any multiple Connectors in the Star System, without having to worry about recording waypoints.
  • Turn your ships into autonomous navigation vessels. Without a need for a cockpit, just tell it where you want to go, and it goes, with or without you as a passenger.
  • Automate cargo runs with ease. In the plannet and in Between planets.
  • Worried about mountains and collisions? Worried about your Remote Controller getting stuck? Don't worry anymore.
Installation
Ships Require:
  • Remote Controller - Add one anywhere in the ship.
  • Camera - Ideally 3, one facing UP, FRONT & DOWN. Avoid that they are obstructed by other blocks in the ship.
  • Programmable block - Add one to your ship, add this script to it.
  • Connector - At least one.

Ships can Additionally have:
  • LCD Panel - At leat one. Add a wide second one for having a Syslog.
  • Antenna - Important as this allows the ship to learn about Connectors in other grids.
  • Cockpit - Used for the LCD Panels.
  • Batteries - If you want to make sure batteries are charged before navigating to the next dock.
  • Cargo Containers - If you want to make sure Cargo Containers are loaded or unloaded before navigating to the next dock.

Stations Require:
  • Programmable block - Add one to the grid.
  • Connector - At least one.
  • Antenna - Important as this allows the Station to advertise its connectors to other grids. However this block does not need to be tagged. Make sure it has enable broadcast set.
Tagging
SAMv2 supports two methods for tagging a block. SAM will first check Custom Data, and then the Block Name. It does not need to use both at the same time. Either one will work.
Only blocks on the same construct will be considered (connected by pistons or rotors, but not connectors).

Block name
This allows tagging the block using the block name. Example for an LCD Pannel:

Wide LCD Pannel [SAM LOG]

Custom Data
This allows the blocks to be tagged without polluting the block name, good for antennas. Example, add the following to the Custom Data of an LCD pannel:

SAM. SAM.Log

Notes for the use of Custom Data with other scripts
SAMv2 scans every line in Custom Data and checks if there is a SAM.something. If there is, it uses it. It leaves everything else untouched.
Usage
Tag all required blocks above with SAM. More specifically:
For Station Programmable blocks
  • add the tag "advertise". Example: [SAM ADVERTISE]
  • override the grid name (no spaces). Example: [SAM ADVERTISE Name=NewGridName]
For Station Connectors:
  • override the block name (no spaces). Example: [SAM Name=NewConnectorName]
For Ships Wide LCD Pannels:
  • add the tag "log" for seeing the Syslog. Example: [SAM LOG]

Continuous modes
Additionally, For Ships Programmable blocks use tag LIST or LOOP:
  • [SAM LIST] - Hops dock to dock in the list till the end.
  • [SAM LOOP] - Hops dock to dock in the list till the end then starts over.
  • [SAM] - Navigation needs to be manually started for every dock in the list.
  • [SAM LIST Wait=20] - Also works for LOOP, overrides the 10 second wait times between docks.

Charge and Cargo

IMPORTANT: SAMv2 *does not* by itself load, unload or charge anything. It needs an external system to do it. SAMv2 only monitors for full, empty, charged or uncharged blocks.

While in LIST or LOOP modes, it is possible to tell a dock to wait to cargo to be Loaded or Unloaded or Batteries to be Charged before moving to the next dock. This can be done with the "select" button in the NAV screen.

The respective Cargo Containers and or Batteries need to be tagged with [SAM].

Hydrogen tanks by default are "Charged", all they need is to have the [SAM] tag too. If there is a mix of Hydrogen tanks and Batteries tagged, then "Charge" will wait for all the batteries to be charged and all the tanks to be filled.

If you want to haul hydrogen, you can tag the Hydrogen tanks with [SAM CARGO] and it will be considered cargo instead.

It is also possible to define what Empty and Full means for Batteries, Tanks and Cargo Containers. The following Tag means to consider empty whenever the charge or fill is bellow 10%, and to consider full whenever the charge or fill is above 90% of the battery max charge, Cargo max volume or tank max volume:
[SAM Empty=10 Full=90]

Also for Batteries and Tanks, use the following tag to force the batteries to recharge and tanks to stockpile. Note that Hydrogen Tanks with the CARGO tag will stockpile automatically;
[SAM FORCE]
Ship commands
Issue the following commands to the Programmable Block:
  • PREV - Previous item.
  • NEXT - Next item.
  • SELECT
    • Select the existing item (for Configuration screen).
    • Changes wait mode (Charge,Load,Unload) (for Navigation screen).
  • SCREEN - Changes back and forth between Navigation and Configuration screens.
  • ADD ORBIT - Adds the GPS position in Orbit right above the ship.
  • ADD <GPS> - Adds the GPS position as an entry. Uses the GPS name as the entry name.
  • ADD [STANCE] <Name> - Adds the present ship position or connected dock as an entry.
    • If ship is connected to a dock it will add the new dock use <Name> to override the dock name;
    • <Name> is optional - adds a name;
    • STANCE is optional - when adding the current position it also adds the current orientation (ignored when adding a dock);
  • REMOVE - Removes entries added with the ADD command and old docks that have stopped being advertised (have a ? before them)
  • START - Starts navigation to the selected dock in the Navigation screen.
  • START PREV - Selects the previous dock in the Navigation screen and Starts navigation.
  • START NEXT - Selects the next dock in the Navigation screen and Starts navigation.
  • START (GPS Coordinate) - Starts navigation to the GPS coordinate copied from the GPS screen.
  • STOP - Immediately stops navigation.
  • TOGGLE - Toggle between START/STOP.
  • GO (Connector Name) - Will immediately start navigating to the Connector Name. The connector name must be the one given with the TAG Name.
  • CLEARSTORAGE - Clears storage, requires the program block to recompile.
  • CLEARLOG - Clears the Log.
Additional details
Text Pannels
Use the following TAGs:
  • [SAM] - Shows the selected screen (either NAV or CONF).
  • [SAM LOG] - Shows the log.
  • [SAM NAV] - Shows the NAV screen.
  • [SAM CONF] - Shows the configuration screen.
  • [SAM STAT] - A two line status useful for corner screens.
  • [SAM OVR] - Allows you to override the font size and style.

Thrusters
SAMv2 can be told to ignore thrusters:
[SAM IGNORE]

Programmable Block
Use the following attributes to override specific values:
  • [SAM Name:NewName] - Overrides the grid name.
  • [SAM MaxSpeed:95] - Maximum speed used in NAVIGATING and CONVERGING modes.
  • [SAM ConvergingSpeed:50] - Converging speed.
  • [SAM DockingSpeed:2.5] - Speed during the docking/undocking procedure (before/after connector).
  • [SAM TaxiingSpeed:10] - Speed during taxiing. Before docking, during path following.
  • [SAM ApproachingSpeed:50] - Approaching speed.
  • [SAM TaxiingPanelDistance:10] - When using Path-Docking, the distance from the panel.
  • [SAM TaxiingDistance:10] - How close will the ship get before starting the docking procedure.
  • [SAM DockDistance:5] - How close to the dock before starting the docking procedure.
  • [SAM UndockDistance:10] - How far a distance to take after undocking before starting navigation.
  • [SAM ApproachDistance:500] - Distance from the target at which Approaching navigation mode starts.
  • [SAM NODAMPENERS] - SAMv2 disables dampeners after docking in order to avoid thrusters from firing while docked (happens when docked to ships). This can be disabled with PB Tag NODAMPENERS;
  • [SAM IGNOREGRAVITY] - The ship will ignore gravity for alligning. This is usefull for rocket like ships that always face one direction regardless of gravity.

Note that during navigation the script will go through these modes:
UNDOCKING -> [TAXIING] -> [ NAVIGATING | CONVERGING ] -> APPROACHING-> [TAXIING] -> DOCKING
  • NAVIGATING -> Used when obstacles are detected in the path.
  • CONVERGING -> Used when no obstacles are detected in the path.
  • TAXIING-> Only during Path docking.

Connectors
Some modded connectors have their local space reversed from the vanilla connectors. For these use the TAG REV:
  • [SAM REV] - Reverses modded copnnectors;

If you have a ship with many connectors where you use some for other ships to dock, you can define a connector that the main ship will always use for docking.
  • [SAM MAIN] - Ship will always dock with this connector. Will not advertise this connector if the ship is also an advertiser.

Cockpits
Use the following TAGs:
  • [SAM PANEL0: ] - Shows the default screen in Panel0.
  • [SAM PANEL0: PANEL2:LOG] - Shows the default screen in Panel0 and the LOG in Panel2.
  • [SAM PANEL0: PANEL2:LOG OVR] - Same as above and allows Overriding text format like in text panels.
  • [SAM PANEL1:CONF ] - Shows the CONF screen in Panel1.

Timer Notifications
Notifications can be sent to timer blocks when certain actions are accomplished. Only timers in the same construct are triggered. Tag your timers with:
  • [SAM DOCKED] - Starts the timer when the ship docks.
  • [SAM UNDOCKED] - Starts the timer when the ship undocks.
  • [SAM NAVIGATED] - Starts the timer when the ship finishes navigation (regardless of docking).
  • [SAM STARTED] - Starts the timer when the ship starts navigation.
Path docking
You can use LCD screens with an attribute named "Name" with the same value as the one your Dock has. The LCDs are sorted by distance to the Dock, and the ship will follow them all the way. This can be used to avoid colisions or when your dock is inside some building. See the video for more details.

Remote commands
It is possible to send commands to configure and run all SAMv2 ship provided they are connected via an antenna. See the video for an example:

More examples

The following command sends the ShipName to ConnectorNameA in GridNameA to charge its batteries and load its cargo, then go to ConnectoB to unload its cargo:
SAMv2 cmd# run ShipName {Charge&Load}[GridNameA]ConnectorNameA {Unload}ConnectorNameB

Same as above except the navigation is not started:
SAMv2 cmd# run conf ShipName {Charge&Load}[GridNameA]ConnectorNameA {Unload}ConnectorNameB

This starts the navigation:
SAMv2 cmd# start ShipName

Possible commands
  • step - adds the configured docks and enables navigation to only go to the next dock;
  • run - adds the configured docks and enables navigation to go to all the docks till the end of the list, then stop;
  • loop - adds the configured docks and loop navigates forever;
  • step conf - only configures the docks and the mode, does not start;
  • run conf - only configures the docks and the mode, does not start;
  • loop conf - only configures the docks and the mode, does not start;
  • start - starts navigation with the existing configuration;
  • stop - stops navigation;

Possible actions
  • Charge
  • Charge&Load
  • Charge&Unload
  • Load
  • Unload

Possible navigation string formats
  • {Action}[GridName]ConnectorName
  • {Action}ConnectorName
  • ConnectorName
  • {Action}GPS:Name:...
  • GPS:Name:...
Only use the GridName to disambiguate from different bases with same ConnectorName.

Command to multiple ships
Use a Semicolon ";" examples:

Start navigation on ShipName1, ShipName2 and ShipName3:
SAMv2 cmd# start ShipName1; ShipName2; ShipName3

Start looped navigation on ShipName1, ShipName2 and ShipName3. Each one having their own docks.
SAMv2 cmd# loop ShipName1 ConnectorA ConnectorB; ShipName2 ConnectorC ConnectorD; ShipName3 ConnectorE ConnectorF


When something does not work
  • Do you own all blocks in the grid? You should.
  • Does your ship have enough power/hydrogen? It must.
  • Does your ship have enough Thrust power in every direction? Including UP. It must.
  • Do your Antennas have enough range to cover each other and are they enabled to broadcast? They should.
  • Are all your blocks in the same construct? (adjacent to rotors or pistons but not connectors).

Things are still wrong? I suck at coding. Leave a comment with a link to the game file, perhaps I can help.
269 Comments
TechCoder 23 Jun @ 4:48am 
From a quick search of "Helm" on my Discord https://discordapp.com/channels/871428395257458728/1102665502750408794

"If I put [SAM PANEL0: ] in the name, the script will change it to: [SAM Panel0=]
[13:44]
It works if its in the name. If I put SAM.Panel0= in the CD, it does not work."

If you aren't on my Discord (and you want to know about SAM, you should be!) - you are invited!
https://discord.gg/HWWKkHk5H9
Fake 22 Jun @ 10:07am 
are all screens supported? I am trying to put SAM log on the Helm Button Panel block and doesnt seem to be supported
Jackie_noff 20 Jun @ 4:14pm 
Will do, thanks!
TechCoder 20 Jun @ 5:22am 
"HOP"...... - I personally never used it (remembering that I didn't write the software, though I am maintaining it) - never found a compelling reason to. The only person that I know that used it (other than you) had constant complaints about crashing/problems (sounds like a pattern??).

As I understand its function, it was to be a non-docking point - potentially useful for bypassing an enemy base, etc. (and I don't play with heavy enemies, so maybe that's why I don't use it), though it uses the same timers/distances that all the docking points use, so it really doesn't save anything (and it does seem to be frustrating for those trying).

My first suggestion is to NOT use HOP.

Second one is that you get on my Discord (MUCH more room for messaging, easier to search back posts, etc.)

Third one is that you look into the new SAM HELPER script where you can configure all setting for EACH docking point (full details on my Discord)
Jackie_noff 20 Jun @ 12:09am 
Hi TechCoder, I hope you’ll forgive my scornful comment I left the other day. It was in fact user error and I took my frustration out on you. I think my mistake came from the misuse of “Hop”. I was expecting my ship to get closer to the GPS coord before changing course to the sequential coord, but it did it early crashing into the departed station. Is there a preset for how close the program will get to the “hop” coord before continuing to the next? I think I was slightly less than 1km away before the redirection.
TechCoder 19 Jun @ 1:41am 
Certainly it was not the script that caused anything - though a ship that is not designed to be flown by an autopilot CAN (and in extreme cases WILL) CRASH due to lack of proper design (think 'top gun' design - they don't use an autopilot!
and, be sure to read "When something does not work" just above - mostly about the thrust in EVERY direction ("you mean, if my ship is crashing maybe there's not enough STOPPING power"? - yeah, duh......)
TechCoder 21 May @ 5:36am 
There's a LOT of discussion on Discord about orientation of ships - https://discordapp.com/channels/871428395257458728/1099358544601563136/1312808571658047509 is a specific thread discussing how to use Build Vision to orient the connectors.

The better answer would be for Keen to LABEL the connectors (like they very nicely did for Projectors in the last update) so you could install them consistently.

There is one idea we have discussed about doing this with software, but it is not typically a good idea to add more 'bulk' without a valid reason - and since this issue has a solid workaround (build your ships with connectors in the correct direction), it isn't likely we'll add that to the near-PB limit code.
R34S0N4BL3 21 May @ 12:41am 
any way to force my ship to dock in a certain orientation when I'm connecting to a larger ship? Stance doesn't seem to work
TechCoder 5 May @ 2:15pm 
KiiLLa - You are going to love SAM, like we all do... :)
To directly address your questions:
* the Connectors have a 'top' that you need to align properly - not as simple as I'd like to see, nor as simple to explain here. We have an extensive step-by-step discussion on my Discord.
* Yes, and no.... - this sort of 'application' _can_ be done, but it takes some steps (too much to discuss in the short text area we get in Steam.... :(

Yes, both questions point to "join my Discord" (see the link a few posts below) - we have an active community and discussions about upcoming features {and a new version of SAM coming out soon})

Oh, that also reminds me - you need to be on MY version of SAM (these instructions work for basic setup though I've fixed some bugs and kept it updated since the original author stopped supporting it in 2020) - https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=2892105352
KiiLLa 5 May @ 11:54am 
I finally got myself to configuring SAM for the first time. This is awesome.

I do have a couple of questions, that I can't seem to google-up (might be a me problem, but hey...):
* Can I configure a specific docking orientation on a connector? My ship came in at a 90 degree angle.
* Can I configure SAM to wait for hangar doors to open when approaching a dock?