User Tools

Site Tools


Sidebar



Minetest Forum
Content Database
Git Repository
Bug Tracker
Website

usage:nodes:atc_controller

ATC controller

Unleash the full power of Advtrains by sending Automatic Train Control commands.

Note: this page has been written for Advtrains 2.1.0 and Minetest 5.1.0. Examples and practices described in this page don't take advantage of improvements introduced in later releases.

Properties

Mod: advtrains_train_track
Node name: advtrains:dtrack_atc_placer
Other names:

  • advtrains:dtrack_atc_st
  • advtrains:dtrack_atc_st_30
  • advtrains:dtrack_atc_st_45
  • advtrains:dtrack_atc_st_60

Craft recipe

This node has no craft recipe.

Extended description

  • When the rail is first built, this rail node does nothing. But once right-clicking (or double tapping on Android) the node, a formspec displays, allowing you to write an ATC command for any trains passing on.
  • When a train is driving on the rail, the command stored in the controller is sent and executed by the train.
  • Sending a new command discards the previous one.
  • In addition, applying brakes, trying to change speed or to open doors will discard the currently running command.
  • If the command is malformed or does not respect the syntax, a warning like this is emitted:
2019-01-01 15:00:00: WARNING[Server]: [advtrains]500000 ATC command parse error: Unknown command: malformed ATC 1
  • This node can be rotated by the Trackworker.
  • Only straight nodes are supported. You can't put this node on a curve or as a switch.

ATC command syntax

In ATC commands, spaces are ignored and can be inserted as needed.

Speed commands

S<speed>

Sets the target speed of driving train to <speed>. The train accelerates if slower than target speed, rolls down to a slower speed if faster, and does nothing if at the same speed.

<speed> can be either:

  • a number constituted only of digits. This represents the speed in metres per second (1 m/s = 3.6 km/h), or
  • the special value M, which represents the maximal speed of the train as defined by the entity definition passed to advtrains.register_wagon.

Execution of the ATC command continues immediately.

B<speed>

Brakes until the train speed reaches <speed>. The train applies brakes if slower than current speed, and does nothing if not.

<speed> should be a number constituted only of digits, representing a speed in metres per second.

Execution of the ATC command continues immediately.

BB

Activates the emergency brake. In this mode, the deceleration is higher than with standard brake (i.e. B0).

Execution of the ATC command continues immediately.

W

Pauses execution of the ATC command until S and B directives reached the desired speed.

Please use with caution. If the train is never able to reach the desired speed, this directive will probably break your ATC command.

R

Reverses movement direction of train. Has only effect while the train is standing.

Door commands

OL, OR

Open left or right doors. Whether doors are left or right are relative to ATC controller arrow direction. So if you try to drive in wrong direction (the “right” direction being when you placed the rail towards driving direction), the OL command will open right doors compared to driver perspective.

If you open left doors with OL, however, you will not be able to open right doors using OR, and vice-versa.

Execution of the ATC command continues immediately.

OC

Close doors previously opened by OL or OR.

K

Kicks all passengers (except drivers) out of the train. Door must be opened to do this. Useful at terminal stations.

Other Commands

Cpl

Temporarily switch the train to “Autocouple” mode and wait for coupling.

This command makes the train continue at its current speed until it hits another standing wagon or train. Then, it couples to this train and ATC command execution continues.

After coupling, the train retains its current target speed. If you do not include a B0 command after Cpl, the train will immediately start moving again.

Note to LuaATC users: When using this command, the train running the ATC command is guaranteed to retain its Train ID. The Train ID of the standing train that it is coupled to becomes invalid.

Note: This command is unique in that its command code is a 3-letter code. Future ATC extensions should also introduce multi-letter codes to avoid exhaustion of letter space for single-letter codes.

Conditional statements

Advtrains only supports the if conditional statement. Such statements are expressed as follows:

I<condition><code>;

where <condition> is one of the conditions described below, and <code> is a regular ATC command. Notice the semi-colon which is required, otherwise you get two warnings like this:

2019-01-01 15:00:00: WARNING[Server]: Undeclared global variable “id” accessed at /home/username/.minetest/mods/advtrains/advtrains/atc.lua:274
2019-01-01 15:00:00: WARNING[Server]: [advtrains]nil ATC command syntax error: I statement not closed: I+S2 1

If you want to add an else branch, you can use this variant:

I<condition><ifcode>E<elsecode>;

+, -

Tests whether the train is driving in the right direction. + becomes true when it drives in direction of arrow; otherwise it is false. - is the opposite of +.

<, <=, >, >=

Compares the current train speed to the given speed. That speed should be a number constituted only of digits, and in metres per second.

It is not currently possible to test directly the speed for equality or inequality.

Although there is no direct command, it is possible to use nested conditional commands to test for equality or inequality:

I<8
 Not equal to 8
E
 I>8
  Not equal to 8
 E
  Equal to 8
;;

Unfortunately the command

I+I<=8I>=8B0;;;

can't be parsed and the parser complains. For now you will have to not nest I+ commands inside I< commands.

Specific commands

A<enable_interlocking>

Either enables (A1) or disables (A0) interlocking on the train. When disabled, the train will not trigger automatic route setting on signals based on ARS.

This command is available only in the luaatc-extensions branch of Advtrains.

Examples

S, B

  • SM: accelerate to maximum speed
  • S2: set target speed to 2 (~ 8 km/h)
  • S0: roll to stand
  • B0: brake to stand
  • S0 B3 or B3 S0: brake to 3, then roll to stand.

W, R

  • S5 W: set target speed to 5 (~ 18 km/h), and wait for speed to be 5
  • B0 W R: brake to stand, wait for speed to be 0, and reverse direction of train
  • B0 W D10 SM: brake to stand, wait 10 seconds after the train stopped, and reverse direction of train

Cpl

  • S2 Cpl B0 W D2 R S4: Drives a locomotive towards a group of wagons, couple to them, wait 2 seconds and then pull the wagons in the opposite direction with speed 4.

OL, OR, OC

  • B0 W OL D10 OC D1 SM: example of train stopping at a standard station with doors opening on the left
  • B0 W OL R D20 OC D1 SM: example of train stopping at a terminus station, with returning in opposite direction

I, +/-, </<=/>/>=

  • I+S2;: if the train is going in the right direction, set target speed to 2
  • I+SMEB0;: if the train is going in the right direction, accelerate, otherwise stop
  • I<8S8;: if the train is slower than 8 (~ 30 km/h), set target speed to 8

Trivia

  • Although the node has three different modes (static, mesecon and digilines), only the static mode is supported. It is actually not possible to change directly the mode from the ATC controller.
  • The ATC controller rail has the same texture as the LuaAutomation ATC rail, but its functions are different.
usage/nodes/atc_controller.txt · Last modified: 2022-06-27 02:32 by blockhead