Skip to content

Instantly share code, notes, and snippets.

@ignomen
Last active October 15, 2023 00:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ignomen/0f5ff086b87a57600a1d64e7b3549b3f to your computer and use it in GitHub Desktop.
Save ignomen/0f5ff086b87a57600a1d64e7b3549b3f to your computer and use it in GitHub Desktop.
POWER or: How I Learned to Stop Worrying and Love the Reactor

POWER or:

How I Learned to Stop Worrying and Love the Reactor

This is a beginner and intermediate guide to powering subs.
The information in this guide is up to date as of July 2021.
This guide is a work in progress. There will be sections that are incomplete.


BASIC GUIDE INTERMEDIATE GUIDE APPENDIX
1. Vocabulary 8. Battery buffers and load balancing 15. Links
2. The Very Basics 9. Signals and logic 16. Index
3. Overloading and undervolting 10. Relays! Relays! Relays!
4. Batteries 11. Altering the arsenal
5. Pumps, engines, fabricators, and generators 12. Example intermediate power grids
6. Basic wiring techniques 13. Hands-on with the reactor
7. Example basic power grids 14. Reactor controllers

BASIC GUIDE

The way power works in Barotrauma is very different from how power works in the real world. The BASIC GUIDE will provide you everything you need to know to get power in your sub working so you can comfortably cruise Cold Caverns as a capable captain.


1. Vocabulary

To start, I'll provide you some key vocabulary terms. Use this section as a reference. Some of the terms presented in this guide are my own, and I use them throughout the guide. Not all of the terms in the guide are shown here, but each is formatted as inline code to make scanning and understanding the guide a little easier. A full index is available at the end of the guide.

Without further ado:

  • power source - Power in Barotrauma comes (directly or indirectly) from a power source, typically a reactor.
  • power grid - The different elements that convey or use that power make up the power grid. There can be more than one power grid, each with more than one power source, and grids can be broken or otherwise modified in-game.
  • junction box - Junction boxes serve to extend the power grid beyond the reactor. They are chained together, one by one, and can diverge, or even loop (in certain circumstances). We’ll cover more on wiring practices later.
  • Load & Power - The power demand of the grid is called Load and the power that is being supplied is simply called Power. You can see this when you look at junction boxes or the reactor in game.
  • node - The individual items on the grid, be they junction boxes, machines, or other pieces, make up nodes. They all communicate with the power source via wire connection.
  • endpoint - Of nodes, those that need power to perform some job are endpoints. As the name suggests, endpoints occur at the ends of the power grid. Examples could include engines, lamps, or pumps among others.
  • relay - A special device for manually dividing grids and providing switching functionality to them. I mention them here as a warning! The guide will make occasional references to relays, but you should refrain from using them until they are covered in depth in the INTERMEDIATE GUIDE.

BACK TO TOP

2. The Very Basics

For the BASIC GUIDE, we'll assume our power source is a reactor. Our reactor has fuel, it is on, and it’s been set to automatic control. We'll cover reactors and fuel rods in detail in the INTERMEDIATE GUIDE.

Power does not flow in Barotrauma as would electricity in a real world electrical circuit. In fact, it doesn't flow at all.
So what does power do? It talks.

It may help you to see the grid as a telephone network:
The power source talks to every node in the grid. It wants to know how much power all of the endpoints need, and it also tells the nodes how much power it is giving the grid to satisfy that need. Nodes, then, also talk to the power source.

Power in Barotrauma is just an information exchange. It is a constant conversation between the nodes in the power grid.
When the grid is broken, perhaps because a wire is disconnected or a junction box goes down, everything after the break is no longer able to communicate with the power source, and ceases to be a part of the grid until the problem is remedied.


BACK TO TOP

3. Overloading and undervolting

  • overload - Junction boxes can be overloaded. Overloading occurs when there is significantly more Power than Load on the grid.

By default, overloading occurs at two times Power over Load. For example, if the grid demands 1000 KW of power but it’s receiving 2000 KW of power, every junction box on the grid will begin to overload. Overloading will rapidly damage junction boxes and may cause them to combust.
Common causes of overloading can include over-throttling a reactor, sudden and drastic deceleration, many pumps stopping at once, oxygen generator breakdown, and multiple fabricators completing their queues, among other things.

  • Power Consumption - Endpoints have a field for Power Consumption, which is the demand they impose on the grid. The power consumption of all the endpoints on a grid are added together to get the grid's Load.
  • undervolt - Endpoints can be undervolted. Undervolting occurs when the grid has less Power than Load.
  • Min Voltage - Endpoints have a field for minimum voltage, written as Min Voltage. By default, most have a minimum voltage of 0.5, meaning they expect Power to be at least fifty percent of Load. Pumps have a default minimum voltage of 0.3, so expect Power to be at least thirty percent of Load.

When the grid is undervolted, each endpoint compares the Power and Load of the grid to its minimum voltage. If minimum voltage is not met, the endpoint stops working. Each undervolted endpoint checks if there’s at least enough Power across the whole grid to meet its own minimum voltage requirement--the endpoints do not compete for Power; Power is a single shared value. Note that when undervolted an endpoint does not stop demanding power, as once the grid supplies enough power to meet the minimum voltage requirement, the endpoint will turn back on.

For example, assume we have three endpoints and each has a minimum voltage of 0.5, or fifty percent. Two endpoints demand 500 KWs each and the third demands 10 KW (for a total 1010 KW Load), but the grid only supplies 500 KW. The grid is undervolted, and 500 KW Power is less than fifty percent of 1010 KW Load. None of the endpoints would have sufficient power to operate. If the grid supplies 600 KW Power, the grid is still undervolted, but all three endpoints would have sufficient power because 600 KW is more than fifty percent of Load.
In another example, we have two endpoints. The first demands 1000 KW and has a minimum voltage of 0.2, or twenty percent. The second demands 1000 KW and has a minimum voltage of 0.5, or fifty percent. Load is therefore 2000 KW. When Power is at least 400 KW, the first endpoint will be powered, and at 1000 KW the second will be powered as well.


If that all seems like information overload, don't worry too much. The most important things to know are that your junction boxes will overload when they have too much power, and your machines will stop working when they don't have enough power. If either of these happen, you can revisit this section.


BACK TO TOP

4. Batteries

  • battery - The primary use of batteries is to store power for later use. There are other, more advanced uses of batteries that will be covered in the INTERMEDIATE GUIDE; the various signal pins, too, will be covered in that guide.

Batteries both demand power and supply it; in this sense they are endpoints and they are power sources. Batteries straddle the line between two power grids--a battery demands power from one grid, and it supplies power to a second grid.
The nodes on the supply grid do not communicate with and are not aware of the nodes on the demand grid, and vice versa. Only the battery is aware of both, but the battery communicates with both grids separately.

When you place a battery, you must take care to review its POWERCONTAINER properties. They are:

  • Max Out Put - The maximum amount of power the battery can output.
  • Capacity - The amount of power the battery can store at once.
  • Charge - How much power the battery starts the game with. The number you use here is a raw number, e.g. if your capacity is 2000, and you want the battery to start fifty percent full, you would input 1000 here.
  • Max Recharge Speed - How much power the battery can demand from its power source in order to replenish its capacity. If the Max Recharge Speed is lower than the Max Out Put, the battery will drain faster than it recharges; by default, this is the case.
  • Recharge Speed - The rate of recharge at which the battery will start the game. This is rounded to steps of ten, but like Charge, you input a raw number, e.g. if your Max Recharge Speed is 500, and you want the battery to start at fifty percent recharge rate, you would input 250 here.
  • Min Voltage & Power Consumption - These do not function for batteries. They can be ignored.

You can infer from the battery's properties that you can modify their capabilities wildly: You can make batteries with high storage capacity but low output; you can make batteries with high output but low capacity; you can do anything inbetween. You don't have to do anything at all if you think the default properties suit your needs.


How many batteries your submarine needs is entirely up to you. You can make a submarine with no batteries, or a submarine with no reactor and just batteries. In the section on example power grids, I'll give a few examples of what you might do with batteries.
You can wire multiple batteries to one another, successively, with one battery's output going to the next battery's input. Doing so creates grids each time. You cannot "leap frog" from one battery's input to another battery's input; each battery must get its input from a junction box or relay. The same is true for the battery's output.

  • array - An array is a group of batteries, working in tandem, all receiving power from one grid and outputting to a second grid.

When batteries are properly wired, they work together. For instance, two batteries in a single array each with a Max Out Put of 1000 supplying a grid which has a Load of 2000 will both output 1000 Power for a total 2000, fulfilling the demand of the grid. Additionally, unlike reactors, the power output of batteries is instantaneous and does not need to ramp up or down. An array of batteries supplying power in concert can be a superior alternative to reactor power.

A special note here: Some of my fellow sub builders have told me that using more than four batteries in a single array can cause strange power problems. Others have told me eight batteries cause problems. I don't know the truth of it, but in practice you will uncommonly use more than four batteries in a single array anyway. Just something to keep in the back of your mind.


  • looping - One thing you should not do when wiring batteries is what sub builders call "looping". Looping occurs when you connect a demanding power grid to a supplying power grid bypassing a battery or batteries.

When you loop a battery, you are uniting two distinct power grids. In this situation when a battery demands power, it may in effect demand power from itself. This commonly results in power spikes and wasted power as the battery fulfills its own demand, thus creating a demand, so on, so forth. This can become much worse when there are multiple batteries or a reactor all on the looped grid. There are circumstances where it is permissible to loop a battery, but we'll talk more about that in the INTERMEDIATE GUIDE. For now, let's keep it simple: Don't loop. The section on example power grids will give examples of looped grids so you can see what to avoid.


  • supercapacitor - A supercapacitor is fundamentally a modified battery, intended to provide short bursts of high power to connected endpoints. Its default POWERCONTAINER properties reflect this.

Supercapacitors are necessary to power a submarine's weaponry and it is rare to see a supercapacitor used for any other purpose.
The same rules that apply to batteries also apply to supercapacitors. We'll go into more depth on their application, including wiring weaponry to them, in the sections on basic techniques and example power grids.


Too much to think about? Here's the gist: Batteries store power from the reactor. Use as many as you like, but take care not to loop them.


BACK TO TOP

5. Pumps, engines, fabricators, and generators

Before we jump into this section, make a quick note of this: The machines we discuss here have built-in lights. When reviewing properties, take note that they each have one or more sections called "LIGHTCOMPONENT". It can easily be confused with the similarly looking machine's component section, the name for which should be self-evident. The more time you spend in the editor, the less this trips you up. Additionally, all of these machines have a checkbox "Is On", which does exactly what you think it does; most start default off and will need the checkbox enabled. All of this will be reiterated in the section on basic wiring techniques.


  • pump - A machine (endpoint) with variable power consumption based on its speed, and subject to a special undervolting mechanic.

The Power Consumption field on a standard pump, default 300, reflects its maximum power demand when operating at one-hundred percent speed. Power consumption is proportional to the pump's speed--at fifty percent speed, a default pump would use 150 power.

Like any other endpoint, if the pump's minimum voltage is not met, the pump does not function. However, with pumps, when they are undervolted but otherwise meet their minimum voltage requirement, they operate at reduced speed. The speed reduction is proportional to the percentage by which they are undervolted. In other words, if a pump is ten percent undervolted, it will suffer a ten percent speed reduction penalty.

  • Max Flow - This is the amount of water the pump adds or removes from the hull when operating at maximum speed. Determining what your pump's Max Flow should be is outside the scope of this guide, but suffice it to say the "correct" value for your pump will probably be found through trial and error.

  • engine - A machine with variable power consumption based on its thrust output, and subject to a special undervolting mechanic.

By default, standard engines have a Power Consumption of 2000 at maximum thrust. Since they are variable consumers, combined with their high power consumption, this makes incorporating them into your power grid possibly the most significant challenge you will face as a new sub builder.

The engine's variable power consumption comes in the form of its thrust output--kind of like its speed setting. The larger the thrust vector you input into the engine, the more power it consumes. Like the pump, this consumption is proportional: A vector of fifty would induce the engine to consume fifty percent power, by default 1000. The direction of the thrust vector does not matter; a positive one-hundred vector (forward at full thrust) suddenly inverted to negative one-hundred vector (reverse at full thrust) would not alter the power consumption.
Rapid acceleration or deceleration, however, would result in significant fluctuations in Load. If you've ever experienced power brownouts or blackouts while piloting a submarine, it's likely this was the cause, as the reactor cannot react quickly enough to the power fluctuations.

The INTERMEDIATE GUIDE will discuss techniques for managing engine Load fluctuations. For your basic power grid, you'll wire the engine directly to a junction box in order to become accustomed to how it works. When you've decided you can't tolerate it anymore, you'll wire the engine to a battery. When this isn't enough for you, you'll be ready for the INTERMEDIATE GUIDE.

Like the pump, when the engine is undervolted but otherwise meets minimum voltage, it operates at a reduced efficacy. For the engine in such a scenario, maximum potential thrust is reduced proportionally. It is easier to explain the reduction method by way of example: A ten percent drop in voltage below minimum would allow the engine to operate normally until it reached a thrust vector of ninety, at which point it would cap out, and you would not be able to increase the thrust vector beyond ninety.

  • Max Force - This is the force the engine produces at a full vector, either positive or negative, provided it is fully powered. Determining what your engine's Max Force should be is outside this guide's scope, but like the pump's Max Flow, will probably be found through trial and error.

It's a lot to learn. It's too much, in fact. Know simply that pumps and engines eat more power the harder you push them. Underpowered they will do less work. These next two are a lot easier.


  • fabricator - A machine with constant power consumption when in use, but subject to a special undervolting mechanic.

For the sake of simplicity, I'm referring to fabricators, defabricators, and medical fabricators alike as simply "fabricators". Principally, they are the same. Fabricators have a constant power consumption when they are being used, which is otherwise zero (the built-in lights are considered separately).

  • Defabrication Speed - Defabricators have a field to modify the speed at which they deconstruct. I always leave this default, but if you really want to mess with it, be my guest.

When fabricators of all types experience undervolting but otherwise meet minimum voltage, they operate at reduced speed in precisely the same way that pumps do. You will notice that a fabricator which is undervolted and does not meet minimum voltage will attempt to perform its operation anyway, but the progress bar will never change on the pending item. When minimum voltage is met, the operation resumes.


  • generator - A machine with constant power consumption, but subject to a special undervolting mechanic.

Oxygen generators are the most straightforward of the quartet. Their power consumption --a uniform 1000 among all three generators-- does not fluctuate, and oxygen generators always stay on.

  • Generated Amount - Each generator has a field for the amount of oxygen they generate. Determining this value is outside this guide's scope, but for a smaller submarine, you probably don't need to modify it.

When generators experience undervolting but otherwise meet minimum voltage, they operate at reduced efficacy, producing proportionally less oxygen.


To summarize, the harder you push the pumps and engines, the more power they drain. Underpowered, they do less work. Fabricators only consume power when in use, and both fabricators and generators do less work when underpowered.


6. Basic wiring techniques


BACK TO TOP

16. Index

Term Section(s) Term Section(s)
array 4. node 1.
battery 4. overload 3.
Capacity 4. Power 1.
Charge 4. Power Consumption 3., 4.
Defabrication Speed 5. power grid 1.
endpoint 1. power source 1.
engine 5. pump 5.
fabricator 5. Recharge Speed 4.
Generated Amount 5. relay 1.
generator 5. supercapacitor 4.
junction box 1. undervolt 3.
Load 1.
looping 4.
Max Flow 5.
Max Force 5.
Max Out Put 4.
Max Recharge Speed 4.
Min Voltage 3., 4.

BACK TO TOP

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment