Difference between revisions of "TrainCarts/Signs/Switcher"

From BergerHealer Wiki
Jump to navigation Jump to search
 
(6 intermediate revisions by the same user not shown)
Line 8: Line 8:
  
 
<!--T:4-->
 
<!--T:4-->
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 [[TrainCarts/PathFinding|path finding]] routing network. This makes this multi-purpose sign important for routing trains to their destinations, whether using path finding or otherwise.
+
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 [[Special:MyLanguage/TrainCarts/PathFinding|path finding]] routing network. This makes this multi-purpose sign important for routing trains to their destinations, whether using path finding or otherwise.
  
 
<!--T:30-->
 
<!--T:30-->
Line 14: Line 14:
  
 
<!--T:31-->
 
<!--T:31-->
By default only powered switcher signs switch the track using [[TrainCarts/PathFinding|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.
+
By default only powered switcher signs switch the track using [[Special:MyLanguage/TrainCarts/PathFinding|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 == <!--T:5-->
 
== Syntax == <!--T:5-->
Line 42: Line 42:
 
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.
 
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 === <!--T:29-->
+
=== Statements === <!--T:11-->
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|Redstone powered switcher]] example down below uses this feature.
 
 
 
== Statements == <!--T:11-->
 
  
 
<!--T:12-->
 
<!--T:12-->
Line 61: Line 58:
 
Switcher signs currently support wildcards only when matching to tags and player names (but not, for example, to train names).
 
Switcher signs currently support wildcards only when matching to tags and player names (but not, for example, to train names).
  
== As a detector == <!--T:32-->
+
=== Statement Continuation === <!--T:29-->
 +
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|Redstone powered switcher]] example down below uses this feature.
 +
 
 +
== Functions == <!--T:32-->
 +
=== 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.
 
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.
  
Line 69: Line 70:
  
  
== Switching without train == <!--T:15-->
+
=== Switching without train === <!--T:15-->
  
 
<!--T:16-->
 
<!--T:16-->
Line 83: Line 84:
  
  
== Path finding == <!--T:18-->
+
=== Path finding === <!--T:18-->
  
 
</translate>
 
</translate>
Line 90: Line 91:
  
 
<!--T:19-->
 
<!--T:19-->
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.
+
The switcher sign is also used during [[Special:MyLanguage/TrainCarts/PathFinding|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 == <!--T:20-->
+
=== Sorter === <!--T:20-->
  
 
<!--T:21-->
 
<!--T:21-->
Line 99: Line 100:
  
 
</translate>
 
</translate>
{{sign|[!train]|switcher|3|4}}
+
{{sign|[+train]|switcher|3|4}}
 
<translate>
 
<translate>
  
Line 110: Line 111:
  
  
== Redstone powered switcher == <!--T:24-->
+
=== Splitting trains === <!--T:33-->
 +
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.
 +
{{sign|[+cart]|switcher|50%|50%}}
 +
 
 +
 
 +
== Examples == <!--T:24-->
 +
=== Redstone powered switcher ===
  
 
<!--T:25-->
 
<!--T:25-->
Line 116: Line 123:
  
 
<!--T:26-->
 
<!--T:26-->
[[File:TrainCarts Redstone Switcher.png|thumb|400px|left|3-way redstone switcher]]
+
[[File:TrainCarts Redstone Switcher.png|600px|3-way redstone switcher]]
 +
 
 +
 
 +
=== Automatic launching === <!--T:34-->
 +
By using a <code>[-train]</code> passengers switcher sign, the lever is automatically toggled down once a player enters the train. This signal activates an inverted station sign, causing the train to launch into the opposite side that is powered. In this setup this launches the train left once a player enters. A redstone repeater delay can be used to debounce this.
 +
 
 +
<!--T:35-->
 +
[[File:Tc_switcher_station.png|600px|Switcher sign lever powers the station to automatically launch the train]]
 +
 
 +
 
 +
=== Cart splitter === <!--T:36-->
 +
By using a <code>[+cart]</code> switcher sign using the counter syntax, a long train can be split into individual carts. Each cart is sent onto one of three tracks, equally. The extra sign below the cart switcher sign extends the number of switching rules. Statements: <code>l:1 r:1 f:1</code>
 +
 
 +
<!--T:37-->
 +
[[File:Tc_cart_switcher_sorter.png|600px|Cart switcher sign splits a train into individual carts onto three lanes]]
 +
 
 +
 
 
</translate>
 
</translate>

Latest revision as of 15:20, 23 September 2024

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.

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).

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.

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


Automatic launching

By using a [-train] passengers switcher sign, the lever is automatically toggled down once a player enters the train. This signal activates an inverted station sign, causing the train to launch into the opposite side that is powered. In this setup this launches the train left once a player enters. A redstone repeater delay can be used to debounce this.

Switcher sign lever powers the station to automatically launch the train


Cart splitter

By using a [+cart] switcher sign using the counter syntax, a long train can be split into individual carts. Each cart is sent onto one of three tracks, equally. The extra sign below the cart switcher sign extends the number of switching rules. Statements: l:1 r:1 f:1

Cart switcher sign splits a train into individual carts onto three lanes