====== Passive Components ======
**Passive Components** are [[usage:nodes:start|advtrains nodes]] like [[usage:other:turnout]]s 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.
===== List of passive components =====
==== Signals ====
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 light
Example:
-- check if the signal at (1,2,3) is green
if getstate(POS(1,2,3)) == "green" then
...
end
==== Switches ====
All default rail switches are interfaceable, independent of orientation.
* ''"cr"'' - The switch is set to the diverging (**c**u**r**ve) branch.
* ''"st"'' - The switch is set to the **st**raight 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 **l**eft branch.
* ''"s"'' - The switch is set to the **s**traight branch (only 3-way).
* ''"r"'' - The switch is set to the **r**ight branch.
==== Mesecon Switch ====
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
==== Andrew's Cross ====
* ''"on"'' - it blinks
* ''"off"'' - it does not blink
===== Passive Component Naming =====
You can assign names to passive components using the [[usage:tools:start|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 Passive Component Naming tool.