Skip to content

Commit 9f56c81

Browse files
committed
Document the train prototype
1 parent 566cc54 commit 9f56c81

2 files changed

Lines changed: 148 additions & 21 deletions

File tree

CHANGES.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# 0.16.18 (unreleased)
2+
3+
- Drop prototype of trains. See [this](./docs/features/rails.md) before you try to use it.
4+
- Tons of internal refactoring that might cause crashes which was necessary to make trains work
5+
16
# 0.16.17 (2025-11-04)
27

38
- Menu search: periodically refresh, eagerly refresh after inventory changes, and refresh after not finding a search result.

docs/features/rails.md

Lines changed: 143 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
## Keys
22

3-
Lock onto a track and start driving the virtual train: left bracket on a rail with a rail in hand
3+
### For The VirtualTrain
44

5+
Lock onto a track and start driving the virtual train: left bracket on a rail with a rail in hand
56

67
Move the virtual train forward: comma
78

@@ -23,27 +24,85 @@ Pop a bookmark from the bookmark stack: b
2324

2425
Undo the most recent move, deleting a rail if you placed one: backspace
2526

27+
### For the Schedule Editor
28+
29+
Set the first parameter of a schedule condition to a signal or item: m
30+
31+
Set the first parameter of a schedule condition to a typed value (number or station name): shift + m
32+
33+
Set the second parameter of a schedule condition to an item or signal: dot
34+
35+
Set the second parameter of a schedule condition to a typed value: shift + dot
36+
37+
Toggle the comparison operator for a schedule condition when applicable: ciomma and shift + comma
38+
39+
Delete a schedule condition: backspace on the condition
40+
41+
Delete a schedule stop: backspace on the stop
42+
43+
Add a new condition separated by or: slash, either on a condition or the initial "no conditions" item of a stop.
44+
45+
Add a new condition, separated by and: control + slash
2646

47+
Toggle the logical operator joining this condition to the previous one: n
48+
49+
Toggle the condition type: j
2750

2851
## Explanation
2952

30-
### Warning: here there be prototyping
53+
IMPORTANT: See https://wiki.factorio.com/Railway if you don't know how rails work. This is documentation of mod
54+
functionality, not of vanilla behavior.
55+
56+
### Warnings and Limitations
3157

3258
This is a prototype of the final trains code and the documentation you are reading is for playtesters.
3359

34-
In particular there are a ton of limitations and also tracks are free to place.
60+
The point is finding out if we like it, not finding all the bugs. Many are already known to me.
61+
62+
It is my belief that fixing the remaining bugs will not break your save, but we are not ready to make that promise. My
63+
promise right now is: if this does break your save, we can fix it but your save may have to remove all rail and train
64+
entities.
65+
66+
The biggest weirdness is that we don't yet go through the building APIs so your tracks are free to place, and let's just
67+
say that if you place over trees your train is going to be a bulldozer whenever it goes through there rather than
68+
erroring that you can't build. Technically tracks don't collide with trees, and we aren't invoking that logic, so you
69+
can very much have a track with a tree on it.
70+
71+
Note (at least) the following:
72+
73+
- Tracks are free to place
74+
- Not super tested.
75+
- Tracks will place over water right now
76+
- Bad verbalization around signal states and train states Primarily that they're silent unless explicitly checked.
77+
- You type stop names directly, no list.
78+
- No rail builder menu; if you want forks you need to use the virtual train (the point of the virtual train is that you
79+
can do it without, but it will come back)
80+
- No syntrax, yet.
81+
- No "automatic driving"/setting the active schedule record. Right now do that by removing all records, adding a record
82+
with wait condition passenger present or passenger not present depending on if you are in the train, and then
83+
rebuilding it. This is one of the higher priorities to fix.
84+
- "robots idle" is an exposed schedule condition which is always present but this is only used by mods that add
85+
equipment grids to trains.
86+
- We don't exactly require that you remove trees and rocks
87+
- No path warnings are gone. They have to come back in a new form, so that is tbd.
88+
- There will be shifts in the UI and schedule editor (especially tab and element orders)
89+
- No interrupts or wildcard interrupts yet.
90+
- No train station previews (1.1's version of this was also sort of breaky, not sure what we're doing yet)
91+
- Definitely lots of others.
3592

3693
## Overview of Track Reporting
3794

3895
Factorio's train system consists of 3 track shapes: straight (can be oriented 16 ways), and two kinds of curves (a and
39-
b, hidden behind the mod). Most of this is hidden from you. You can place straight rails in the 8 primary directions, but must continue building using the virtual train or syntrax, described below.
96+
b, hidden behind the mod). Most of this is hidden from you. You can place straight rails in the 8 primary directions,
97+
but must continue building using the virtual train or syntrax, described below.
4098

4199
Sometimes, you will observe more than one track on a tile. This can happen in two ways:
42100

43101
- If using shift + f to cycle, in which case the track may be spurious because some track pieces share tiles to connect
44102
- When moving, in which case you are on some form of crossing where two tracks overlap.
45103

46-
We simplify each tile into a layout description. NOTE: forks are described but not listed in this doc because they're WIP, I'm making it better.
104+
We simplify each tile into a layout description. NOTE: forks are described but not listed in this doc because they're
105+
WIP, I'm making it better.
47106

48107
You may find:
49108

@@ -52,9 +111,11 @@ You may find:
52111
- Half-diagonal rails facing in any of the secondary eastern directions, for example east northeast
53112
- Various kinds of curves
54113

55-
The straight rails only ever face half of the compass because they are bidirectional. A horizontal east is also a horizontal west.
114+
The straight rails only ever face half of the compass because they are bidirectional. A horizontal east is also a
115+
horizontal west.
56116

57-
The mod helps out with curves by abstracting where possible. It will announce either a direction and a "left/right" specifier, or it will announce "x and y turn".
117+
The mod helps out with curves by abstracting where possible. It will announce either a direction and a "left/right"
118+
specifier, or it will announce "x and y turn".
58119

59120
Some examples:
60121

@@ -64,41 +125,68 @@ Some examples:
64125

65126
NOTE: in Factorio 2.0 a 90 degree curve is 4 turns as the shallowest corners are now only 22.5 degrees.
66127

67-
As you build more of a larger shape, the mod will recognize more of that larger shape and report it to you. For example, until the 4th place of a 90 degree turn is placed, it will describe the three smaller curves separately.
128+
As you build more of a larger shape, the mod will recognize more of that larger shape and report it to you. For
129+
example, until the 4th place of a 90 degree turn is placed, it will describe the three smaller curves separately. You
130+
can use this to help guide you as to whether or not you have built what you wanted.
131+
132+
For 90 degree turns off the cardinals we use the interesting fact that all turns have a "height" and assign the 4
133+
segments a bottom/lower half/upper half/top designation, going from southmost to northmost on the map.
68134

69-
For 90 degree turns off the cardinals we use the interesting fact that all turns have a "height" and assign the 4 segments a bottom/lower half/upper half/top designation, going from southmost to northmost on the map.
135+
I recommend building a circle (m or dot 16 times from a straight rail's end) then going around the circle to see how it
136+
reports the 90 degree turns.
70137

138+
Unlike 1.1, there is no requirement that straight pieces be present anywhere. You can now do circles with only curved
139+
pieces. You can do long straight paths with s-bends going back and forth like a snake. I don't suggest either for a
140+
variety of reasons but you can, so can the sighted, and it's your game.
71141

72142
## Basic Rail Building: The Virtual Train
73143

74144
The sighted user of Factorio does not place most rails directly, and instead uses a rail planner, which lets them draw
75145
the path they want. You also do not place most rails directly, and use the virtual train, which lets you draw the path
76-
you want.
146+
you want. The primary difference is that you have to work out the path and the sighted do not, but the cause of the
147+
sighted style approach is that their paths are not "clean" and will curve whenever and however they feel like when the
148+
game decides it's best to go around the lake or zigzag through the cliffs or whatever. The mod instead opts for control
149+
and precision; even in vanilla advanced players eventually use grid-aligned blueprints and things instead of the rail
150+
planner, so it's not a huge loss.
77151

152+
To lay tracks, you use m, comma, dot, and slash as well as a few other keys. To get started, put a rail in your hand
153+
and build a straight rail. Then, with the rail still in your hand, click the rail. This connects the virtual train to
154+
it. To turn it off, empty your hand. To be clear, your character does not move during this process or anything like
155+
that.
78156

79-
To lay tracks, you use m, comma, dot, and slash as well as a few other keys. To get started, put a rail in your hand and build a straight rail. Then, with the rail still in your hand, click the rail. This connects the virtual train to it.
80-
To get out, empty your hand.
157+
The virtual train builds tracks as you drive it. You turn it left with m, move it forward with comma, and turn it right
158+
with dot. For example, a 90 degree left turn is pressing m 4 times.
81159

82-
The virtual train builds tracks as you drive it. You turn it left with m, move it forward with comma, and turn it right with dot. For example, a 90 degree left turn is pressing m 4 times.
160+
You will notice that the keys are a group of 3. To remember the controls, the train is comma and you're turning left
161+
with m because m is left of the train.
83162

84-
Sometimes, you need to turn around. To do so, you use alt + comma. This does not turn the train 180 degrees, however. All rail building must happen from a rail end, so you are instead grabbing the other end of the just placed rail. For example, a north to north northwest curve's ends are south and north northwest.
163+
Sometimes, you need to turn around. To do so, you use alt + comma. This does not turn the train 180 degrees, however.
164+
All rail building must happen from a rail end, so you are instead grabbing the other end of the just placed rail. For
165+
example, a north to north northwest curve's ends are south and north northwest.
85166

86167
It is necessary to place signals and it is necessary sometimes to place signals at the exact position relative to a
87168
rail's end so that you have an extra tile of space. Adding ctrl to m or dot places a signal on that side of the track.
88-
Using shift instead places a chain signal Explaining the rules of Factorio signals are beyond this document, but if you
89-
are following them, ctrl/shift + dot is always "going this way" and ctrl/shift + comma is "going against the flow".
169+
Using shift instead places a chain signal. Explaining the rules of Factorio signals are beyond this document, but if
170+
you are following them, ctrl/shift + dot is always "going this way" and ctrl/shift + comma is "going against the flow".
90171

91172
The virtual train moves over but does not replace perfectly matching tracks. For example, if you build the exact same
92173
structure from the exact same starting point twice, the second time succeeds but doesn't place anything. This solves a
93174
problem from the 1.1 version of the mod: you no longer need to mine up pieces to build track merges.
94175

95176
Building tracks can be tricky, so the virtual train offers a few more functions.
96177

97-
First, you can temporarily disable building by entering speculation mode. To do so,press slash. In this mode, the train moves as if it would build, but doesn't place anything. When you exit speculation, you are returned to the position and direction you entered it from. This lets you see what is at the target positions of rails, or for example check whether or not an s-bend would merge tracks properly.
178+
First, you can temporarily disable building by entering speculation mode. To do so,press slash. In this mode, the
179+
train moves as if it would build, but doesn't place anything. When you exit speculation, you are returned to the
180+
position and direction you entered it from. This lets you see what is at the target positions of rails, or for example
181+
check whether or not an s-bend would merge tracks properly.
98182

99-
If you make a mistake, you can press backspace. This undoes one move, and removes anything that move built including signals. It leaves other rails on the same tile alone.
183+
If you make a mistake, you can press backspace. This undoes one move, and removes anything that move built including
184+
signals. It leaves other rails on the same tile alone.
100185

101-
Finally, the virtual train changes the meaning of bookmarks and uses the bookmark keys. It maintains a historical list of states. When you set a bookmark, you are pushing a bookmark to the list of bookmarks for this speculation, which saves the history, direction, and position of the virtual train. When you then press b, you move to and clear the last bookmark.
186+
Finally, the virtual train changes the meaning of bookmarks and uses the bookmark keys. It maintains a historical list
187+
of states. When you set a bookmark, you are pushing a bookmark to the list of bookmarks for this speculation, which
188+
saves the history, direction, and position of the virtual train. When you then press b, you move to and clear the last
189+
bookmark. Programmers know this as a stack; shift+b pushes, b pops.
102190

103191
A concrete example may help. Here is how you build a 3-way fork:
104192

@@ -113,6 +201,40 @@ A concrete example may help. Here is how you build a 3-way fork:
113201
- Press shift + b again
114202
- Press comma 4 times to build the straight section
115203
- Press b, to get back and clear the bookmark
116-
- Add some signals: press shift dot (chain in) and control comma (regular out)
204+
- Add some signals: press shift dot (chain in) and control m (regular out)
205+
206+
Bookmarks may seem awkward, but the use is for more complex layouts. For example, this representation lets you build
207+
forks on the ends of other forks, or even type 4-way intersections (hint: each fork is part of another fork, and you can
208+
put a bookmark at each fork as you type it). If you don't follow the idea of a bookmark stack, I advise not using
209+
bookmarks at all here; anything that can be accomplished without the stack part can be accomplished fine by just not
210+
bothering.
211+
212+
## Schedules and Stations
213+
214+
There is a station UI. It works like any other UI and lets you set things like any other UI, and doesn't deserve more
215+
documentation.
216+
217+
Teaching how train schedules work is beyond the scope of mod documentation. See the wiki for that.
218+
219+
This covers the schedule editor. It's over one tab from the inventories of a locomotive attached to a train (no more
220+
"it must be at a station"). The schedule editor now exposes all 1.1 functionality. 2.0 interrupts are not yet
221+
implemented.
222+
223+
The controls are at the top of this document, but they borrow the controls of the decider combinator. M is parameter 1,
224+
comma is the operator, and dot is parameter two. What these are changes based on the schedule condition type, toggled
225+
with j. For example, "wait" only has one parameter and it is always a constant integer, so you set it with shift + m.
226+
Rather than shifting whether or not m and dot open text boxes, we instead require you to add shift if the parameter can
227+
only be set from a text box. In future that will basically just be numbers, but for today we do require you to enter
228+
stop names manually--there is no stop selector yet.
229+
230+
Just like with the decider n controls how the condition joins with the previous (and/or) and slash adds a new one and
231+
moves you to it (combined using or, add ctrl for and). The key that we add to this is j, to toggle through the
232+
condition types (wait, passenger present, cargo has a specific thing, etc).
233+
234+
The game does not care if stops are present when you add them to a schedule, so we will always support typing stop
235+
names. Indeed, for some 2.0 functionality typing the stop name is mandatory even for the sighted. For now, for
236+
simplicity and to get off the ground, you must type your stop names yourself.
117237

118-
Bookmarks may seem awkward, but the use is for more complex layouts. For example, this representation lets you build forks on the ends of other forks, or even type 4-way intersections (hint: each fork is part of another fork).
238+
Like with the decider combinator, the idea is that you view these controls like reading text or similar (j doesn't fit
239+
the analogy, but it needed one more key and b is too important). If we put braille on your keyboard with one "field"
240+
per key, it would "fit" on n m comma dot, and then slash adds to the "end" of the row as a whole.

0 commit comments

Comments
 (0)