Space Engineers

Space Engineers

71 ratings
Isy's Ship Refueler Guide
By Isy and 1 collaborators
This is a full guide that will explain all the features of my Ship Refueler script.

You can find the script here: https://steamhost.cn/steamcommunity_com/sharedfiles/filedetails/?id=859401813
   
Award
Favorite
Favorited
Unfavorite
Basic Setup
The basic setup is very easy. You just need a programmable block with the script and that's it! Below you have a step by step description of what to do:
  • subscribe to my script in the workshop (see link in the title)
  • build a programmable block
  • open it in the terminal
  • press 'Edit'
  • in the new window, press 'Browse Workshop'
  • select my script 'Isy's Ship Refueler' and press 'Ok'
  • the code now appears in the window
  • press 'Check Code' and 'Ok' in the popup window
  • press 'Remember & Exit' and you're done

The script is now running with all its basic settings and your ship should be automatically managed when docking.

For a more visual, video guide, watch my (very outdated) youtube video:


Note: Game has to be in experimental mode and ingame scripts have to enabled in world options!
How to do that, I explained here:

Manage Batteries
By default, all batteries of the ship are monitored by the script. They are switched to auto mode if you undock your ship or to recharge when you are docked. Also, the batteries are balance charged so that batteries with the least amount of charge get filled with a higher priority if not enough power is available to fill them all at once.

Battery Whitelist
If you only want to monitor specific batteries, group them together and put the group name in the config seaction. Leave blank to monitor all.
// Example: string batteryGroupName = "My Vehicle Batteries"; string batteryGroupName = "";

Backup Battery
The script always keeps one battery in auto mode as a backup if you sit in the ship while being docked. This is necessary to avoid the script running out of power when undocking which could cause your ship to potentionally crash. If you however not sit in your ship while it's docked, the script will charge all batteries. To manage fully automated drones, it is highly recommended to always keep one backup battery.
bool keepOneBackupBattery = false;

Discharge when not docked
If this option is set to false, the batteries will be in auto mode (neither charge nor discharge). If set to true, they are set to discharge.
bool dischargeWhenUndocked = false;
Manage Tanks
If tank filling is enabled, the script will switch tanks to stockpile, when you are connected. That way the tanks will be filled very fast. Stockpile is deactivated when disconnecting.
bool fillTanks = true;

By default, the script uses all tanks on the grid and fills them, when docked. If you only want specific tanks to be managed, put them in a group and define the groupname here.
string tankGroupName = "";
Emergency Power
If your ship runs low on battery charge or the output gets overloaded, the script will enable the reactors and hydrogen engines to help out. If everything is normal again, the reactors will be disabled again. The activation can be adjusted in the config section:
bool enableEmergencyPower = true;

Used power producers
You can specify, which power producers should be used for emergency power.
bool useReactors = true; bool useHydrogenEngines = true;

Activation order
By default, the hydrogen engine will be turned on first and the reactors after that if still not enough power is available. Set this value to false, and the reactors will be used first.
bool activateHydrogenEngineFirst = true;

Activation scenarios
There are four different scenarios, when a emergency device can be activated: low battery charge, overload, damaged batteries and no batteries at all. You can enable or disable each scenario, you want the emergency devices to kick in:
bool activateOnLowBattery = true; bool activateOnOverload = true; bool activateOnDamagedBatteries = true; bool activateOnNoBatteries = true;

Tresholds
You can specify the tresholds for the emergency devices to kick in in percent:
double lowChargePercentageON = 10; double lowChargePercentageOFF = 15; double overloadPercentage = 90;
Used Connectors
By default, the script monitors all connectors of the ship for a connection. If you only want to monitor specific ones, create a group and put the group name in the brackets in the config section.
This is especially useful if you have a carrier or mother ship, where other ships with the ship refueler dock and you don't want them to try to charge from each other.
string connectorGroupName = "";
Special Connections
If you don't want to perform a specific action when docked to a connector, add the keyword to its name.

The keyword must be added to the other connector's name, NOT your ship's connector!

No refuel
This disables battery charging and tank filling (they are turned off).
string noRefuelKeyword = "[No Refuel]";

Ignore
This ignores a connection and leaves batteries and tanks the way they are.
string ignoreKeyword = "[Ignore]";

No recharge
This disables battery recharging (they are turned off).
string noRechargeKeyword = "[No Recharge]";

Discharge at connector
This discharges all batteries to a minimal value of dischargeLevel % charge (they are set to discharge).
string dischargeKeyword = "[Discharge]"; double dischargeLevel = 10;

No tank filling
This disables tank filling of all tanks of the ship (they are turned off)
string noTankFillKeyword = "[No Refill]";

No O2 filling
This disables O2 tank filling (they are turned off)
string noOxygenTankFillKeyword = "[No O2 Refill]";

No H2 filling
This disables H2 tank filling (they are turned off)
string noHydrogenTankFillKeyword = "[No H2 Refill]";
Timer Trigger On Event
This feature lets you trigger a timer block to execute additional actions on specific events. The timer will be executed with the action "Trigger Now" if its delay is set to exactly 1 second and "Start" if it is more than 1 second (1.x seconds or more)

Events can be:
  • "dock"
  • "undock"
  • a battery fill level like "25%"
  • a docking time in minutes:seconds like "5:30"
Every event needs a timer block name in the exact same order as the events. Calling the same timer block with multiple events requires it's name multiple times in the timers list!

Example:
This will trigger "Timer 1" when docking, "Timer 2" when undocking and "Timer 3" when the battery level is at 25% string[] events = { "dock", "undock", "25%" }; string[] timers = { "Timer 1", "Timer 2", "Timer 3" };
Light Control
The script is able to turn on or off your ship's lights based on the light level. In order to use this feature, your ship needs a solar panel. The lights are turned on if the light level is below the set percentage of the max read output of the solar panel and off if they are above that level. To use this feature, turn on light control in the config section:
bool lightControl = false; int lightThreshold = 50;

By default, all solar panels of the ship are monitored. If you want to monitor specific solar panels, declare groups for them.
Example: string[] solarPanelNames = { "My Solar Panel Group", "Ship Solar Panels" };
string[] solarPanelGroups = { };

If you only want to toggle specific lights, you can group your lights together and put the group name in the config section, too:
string[] lightGroups = {"My Ship Lights"};
LCD Informations
The following topic explains, how to use LCD panels (regular and block LCDs) of my script. Whenever you add one of the following keywords to a block's name, the keyword gets transformed to the universal [IsyLCD] keyword. In the custom data, you can then set different options about the LCD as well as the screen, the information should be shown (on blocks like cockpits, programmable blocks and so on). The custom data will look like this:

@# KEYWORD

@# stands for the screen, the information is shown, where # is the screen identifier number from 0 to the max number of screens - 1. A programmable block for example has two screens: The main screen and the keyboard. Both can be used to show the script informations (screen 0 and screen 1). To change the screen, you want to show your informations, just edit the screen identifier number in the custom data.

It is also possible to display informations of different scripts in one block by using this syntax (MMaster's Automatic LCDs 2 uses the same syntax and all of my other scripts).

LCD Keywords
Main LCD
You can display all the main script informations like docking stats, battery stats and tank stats on the main LCD. Just add the following keyword to a LCD name:
ISR-main

Warning LCD
You can display all current warnings and problems on a dedicated LCD screen. Just add the following keyword to a LCD name:
ISR-warnings

Performance LCD
You can display the script performance (PB terminal output) on a dedicated LCD screen. Just add the following keyword to a LCD name:
ISR-performance

Default font/-size
Every LCD, that you just assigned, get's the 'Debug' font and a font size of 0.8 by default. After the initial setting, you can change it to whatever you like. The default values can be changed in the config:
// Default font ("Debug" or "Monospace") and fontsize for new LCDs string defaultFont = "Debug"; float defaultFontSize = 0.8f;
Terminal Statistics
The script can display informations in the names of the used blocks. The shown information is a percentage of the current output (solar panels and reactors) or the fill level (batteries and tanks). You can enable or disable single statistics or disable all using the master switch below.
bool enableTerminalStatistics = true; bool showBatteryStats = true; bool showTankStats = true; bool showReactorStats = true; bool showSolarStats = true;
Commandline Arguments
Nearly every feature of the script can be temporarily enabled or disabled without the need to edit the script. These commands are sent to the script by writing them in the programmable block's argument field and pressing run or by pulling the programmable block to any hotbar (cockpits, button panels and so on), selecting run and typing in the arguments in the popup window.

The syntax works like this:
variable on|off|toggle

For example:
enableEmergencyPower off
This will temporarily disable the use of emergency power devices (until the script is recompiled or the world is reloaded).

fillTanks toggle
This will toggle tank filling on or off based on it's current state (again: temporary until the script is recompiled or the world is reloaded).

Full list of all available variables
dischargeWhenUndocked keepOneBackupBattery fillTanks enableEmergencyPower useReactors useHydrogenEngines activateHydrogenEngineFirst activateOnLowBattery activateOnOverload activateOnDamagedBatteries activateOnNoBatteries lightControl enableTerminalStatistics showBatteryStats showTankStats showPowerDeviceStats showSolarStats
78 Comments
PMBELL 20 Jan, 2023 @ 8:52am 
Hi. I use a miner with a sorter that allows only stone to pass before the connector expels it.
I then want to use the same connector to dock and unload the rest of the ores inside, but cannot automatically reconfigure the sorter and have to do it by hand.
Could you please add the ability to reconfigure sorters (and turn on/off expelling from connector)?
This issue cannot be solved using a timer.
Katarina [WolfCraft Industries]  [author] 2 Mar, 2022 @ 1:39pm 
thats not really possible, take a look at Automatic LCDs 2 from MMaster, this script has exactly what you want
MrFox 2 Mar, 2022 @ 1:26pm 
We use this on a mining ship. Would it be possabel to add Cargo fill %?
Katarina [WolfCraft Industries]  [author] 28 Feb, 2022 @ 1:05pm 
@Woodzy there is support for cockpits, check section > LCD Informations....

@Liam i think it is not possible to select what battery is the backup one since it gets switched around so that all batteries can charge.
MrFox 28 Feb, 2022 @ 9:56am 
Support for cockpits?
Liam 2 Oct, 2021 @ 2:49pm 
Is there a way to select what battery is the backup? And if not could it be added?
dragonsphotoworks 6 May, 2021 @ 5:22pm 
Did i read correctly that the status of power can be displayed in a cockpit? If so that is exactly what I need :-)
Isy  [author] 9 Mar, 2021 @ 4:02am 
@Jamie: It's a bit too sensitive.. I currently working on that..

@Airomis: That's not the purpose of the this script.. It sets all batteries to recharge while being docked and sets them back to auto when you're undocked..
Airomis 7 Mar, 2021 @ 8:43am 
is there a way to tag what batteries are set to recharge and what 1 is set to always on?
Jamie 1 Nov, 2020 @ 3:12pm 
Hi first thanks for this script i have a slight issue though my ship says Warning Not enough power! Charging Aborted! My base has 3 large batteries all of them are at 99% charge is it possible to adjust something to allow the base batteries to be drawn down to say 70% before this stops charging my ships.