TrainCarts/Signs/Switcher

From BergerHealer Wiki
Revision as of 13:57, 25 July 2022 by Bergerkiller (talk | contribs)
Jump to navigation Jump to search
Other languages:

« Go back


Introduction

Switcher signs can read information from the train or cart above and toggle a lever and rails based on that. It also marks the switchable nodes of the path finding routing network. This makes this multi-purpose sign important for routing trains to their destinations, whether using path finding or otherwise.

Levers connected to the base block of the sign are toggled down when conditions match. When the sign is powered, the track above is also switched towards the statement-assigned direction when the condition matches. When the switcher sign is powered by redstone, or by using [+train], then it will switch the track based on the statements on the sign. This can cause trains to reverse on straight rail sections. If the sign is used primarily to toggle a lever when the statement conditions match, then [-train] should be used so this does not happen.

By default only powered switcher signs switch the track using path finding logic. This can be changed in Traincart's config.yml as part of legacy support, as in past versions this was not the case.

Syntax

First line: [-train] to toggle only the lever based on the conditions, [+train] or other modes for switching the track

Second line: switcher or tag

Third line: The statement for when to switch the track left (if no direction prefix is specified)

Fourth line: The statement for when to switch the track right (if no direction prefix is specified)


Signtemplate.png
[train]
switcher
t@mytag
r:default


For statements it can read cart tags, destination, passengers, items and several other states. It is also possible to sort the carts when using numeric values on the last two lines. This way you can make 1 train or cart go left out of every 3 trains or carts. The default statement is unique, in that it will only be true if no other statement on the sign is true, regardless of order. They are evaluated top to bottom.

Direction Prefixes

Statements can include a direction prefix to the left, such as l: or f:, to define where to send the train when the statement condition is true.

Statement Continuation

Statements continue on signs below, provided they are all prefixed by a direction. Otherwise they will be ignored by the switcher sign. If you are not switching the track and only want a lever to be toggled, then you can use any direction prefix here, such as f: - it will have no effect in that case. The Redstone powered switcher example down below uses this feature.

Statements

On the third and fourth lines you can put the statements to evaluate. You can insert a direction followed up by : and then the statement to set the direction to switch to. For example:

Signtemplate.png
[!train]
switcher
1:<trainsize>
r:i@wood


Will send all trains larger than 5 carts to the left, and trains with wood in storage minecarts to the right. It parses the statements from top to bottom, so wood-bearing trains larger than 5 carts are also sent to the left.

Switcher signs currently support wildcards only when matching to tags and player names (but not, for example, to train names).

Functions

As a detector

The switcher sign toggles a lever in addition to switching track. By using [-train] track switching can be disabled so that the switcher sign only toggles the lever. This can then be used to automatically detect changes in the train above, for example, when players enter the train.

Signtemplate.png
[-train]
switcher
passengers


Switching without train

To change the rails when triggered by redstone, without requiring a train to enter the rails first, both from and to directions can be specified. For example:

Signtemplate.png
[+train]
switcher
n-e:redstone
n-w:default


Will switch the rails north-east when powered by redstone, and north-west otherwise. This also works with TC-Coasters, by specifying the junction names ( 1-2:redstone )


Path finding

Signtemplate.png
[+train]
switcher

The switcher sign is also used during path finding. If a train or cart has a destination set, and no statements on the sign match (or no statements were set), it will toggle the rails to make the train go to the requested destination. If you need to force an alternative route or need to send 'passing through' trains around, add a statement on this sign to do so.


Sorter

If you need to sort carts onto multiple tracks, you can use an internal counter:

Signtemplate.png
[+train]
switcher
3
4


Right now it will send 3 trains to the left and then 4 trains to the right direction, after which the cycle repeats itself. You can put multiple switcher signs in line to equally divide the trains onto multiple tracks. This is shown in the video below:

https://www.youtube.com/watch?v=8KCfenk3Vi8


Splitting trains

A train can be split at an arbitrary cart using a [+cart] switcher. This will switch halfway the train sending each section of the train in a different direction. Instead of fixed number (1 cart left, 1 cart right) a percentage can be used (50%) which will split the train in half, regardless of train cart count.

Signtemplate.png
[+cart]
switcher
50%
50%


Examples

Redstone powered switcher

By using the redstone statements on the sign, you can completely control what direction to send the train to:

3-way redstone switcher