This is an old revision of the document!
Passive Components are advtrains nodes like Turnouts and basic signals.
A passive component has a state, which represents the state it is in. For example, a turnout can be either switched to the straight or the diverging branch, and a basic signal can be either red or green.
LuaATC interfaces with passive components using the getstate()
and setstate()
functions. Their state is represented as a string, as listed below.
All light signals that have a red and a green light can be interfaced. At the moment, these are the default red/green light signal and the tunnel wall/ceiling signals, all included in the advtrains
mod.
“green”
- Signal shows green light“red”
- Signal shows red lightExample:
-- check if the signal at (1,2,3) is green if getstate(POS(1,2,3)) == "green" then ... end
All default rail switches are interfaceable, independent of orientation.
“cr”
- The switch is set to the diverging (curve) branch.“st”
- The switch is set to the straight branch.Example:
-- set the switch at (2,3,4) to the diverging branch setstate(POS(2,3,4), "cr")
The Y-Turnout and 3-Way switch use a different set of state strings based on the pointing direction:
“l”
- The switch is set to the left branch.“s”
- The switch is set to the straight branch (only 3-way).“r”
- The switch is set to the right branch.The Mesecon switch can be switched using LuaAutomation. Note that this is not possible on levers, only the full-node 'Switch' block.
“on”
- the switch is switched on“off”
- the switch is switched off“on”
- it blinks“off”
- it does not blinkYou can assign names to passive components using the Passive Component Naming tool. These names must be globally unique in a world.
Once you set a name for any component, you can reference it by that name in the getstate()
and setstate()
functions, like this:
--(Imagine a signal that you have named "Stn_P1_out" at position (1,2,3) ) setstate("Stn_P1_out", "green") instead of setstate(POS(1,2,3), "green")
This way, you don't need to memorize positions.
Although not all signals usable by the interlocking system are LuaATC passive components, PC-Naming can also be used to name interlocking signals for route setting via the set_route()
functions.
IMPORTANT: The “Signal Name” set in the signalling formspec is completely independent and can NOT be used to look up the position, you need to explicitly use the PCNaming tool.