Difference between revisions of "TrainCarts/Signs/Switcher/zh-cn"

From BergerHealer Wiki
Jump to navigation Jump to search
(Created page with "=== 方向前缀 === 语句左侧可包含方向前缀,例如 ''l:'' 或 ''f:'',用于当语句条件为 true 时定义火车发往的方向。")
(Created page with "在第三行和第四行,你可以设置要判定的语句。你可以插入方向,后跟 ''':''',然后设置要切换...")
Line 32: Line 32:
 
=== 语句 ===
 
=== 语句 ===
  
<div lang="en" dir="ltr" class="mw-content-ltr">
+
在第三行和第四行,你可以设置要判定的语句。你可以插入[[Special:MyLanguage/TrainCarts/Signs/Direction|方向]],后跟 ''':''',然后设置要切换的方向的语句。例如:
On the third and fourth lines you can put the statements to evaluate. You can insert a [[Special:MyLanguage/TrainCarts/Signs/Direction|direction]] followed up by ''':''' and then the statement to set the direction to switch to. For example:
 
</div>
 
  
 
{{sign|[!train]|switcher|1:<trainsize>|r:i@wood}}
 
{{sign|[!train]|switcher|1:<trainsize>|r:i@wood}}

Revision as of 11:06, 2 September 2024

Other languages:
English • ‎中文(中国大陆)‎

« 返回


介绍

转辙器控制牌(以下简称道岔)可以读取上方列车或矿车的信息,并据此切换拉杆和铁轨。它还标记了路径查找路由网络的可切换节点。这使得道岔对于讲列车路由到目的地来说非常重要,无论是使用路径查找还是其他方式。

当条件匹配时,连接到道岔基础方块的拉杆会被切换为向下。当道岔激活,且条件匹配时,上方的铁轨也会切换到语句指定的方向。当道岔被红石激活,或使用 [+train] 时,道岔将根据语句切换铁轨。这可能会导致列车在直行轨道部分上倒车。如果道岔主要用于在语句条件匹配时切换拉杆,则应使用 [-train] 以避免发生这种情况。

默认情况下,只有充能的道岔才能根据路径查找逻辑来切换铁轨。这可以在 TC 的 config.yml 中作为旧版本支持的一部分进行修改,因为在过去的版本中情况并非如此。

语法

第一行:[-train] 只根据条件来切换拉杆,[+train] 或其他模式会切换铁轨。

第二行: switchertag

第三行:何时向左切换轨道的语句(如果没有定义方向前缀)

第四行:何时向右切换轨道的语句(如果没有定义方向前缀)


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


对于语句,它可以读取矿车的标签、目的地、乘客、物品和其他几个状态。在最后两行使用数值时,也可以对矿车进行排序。按照这个逻辑你可以实现每3列车/矿车就有1列车/矿车发往不同的方向,default 语句是唯一的,因为只有当道岔上的其他语句都为 false 时,它才会为 true,无论顺序如何。它们从上到下进行判定。

方向前缀

语句左侧可包含方向前缀,例如 l:f:,用于当语句条件为 true 时定义火车发往的方向。

语句

在第三行和第四行,你可以设置要判定的语句。你可以插入方向,后跟 :,然后设置要切换的方向的语句。例如:

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:


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