This is an old revision of the document!
In a LuaAutomation ATC controller, an event has the following format:
event = { type = "<type>", <type> = true, -- additional content }
You can check for a specific event type by using
if event.type == "<wanted>" then -- ... do stuff end
or
if event.<wanted> == true then -- ... do stuff end
event = { type = "int", int = true, msg = <message>, message = <message>, -- For backwards compatibility only! }
Fired when an interrupt set by the interrupt
function runs out. <message>
is the message passed to the function.
For backwards compatibility reasons, the message is also contained in the event.message
field.
event = { type = "ext_int", ext_int = true, message = <message>, }
Fired when a node called interrupt_pos
on this node's position. <message>
is the message passed to the function.
event = { type = "digiline", digiline = true, channel = <channel>, msg = <message>, }
Fired when the rail receives a Digiline message.
The LuaATC rail currently supports the following events:
event = { type = "train", train = true, id = <train_id>, }
Fired when a train enters the rail. The field id
is the unique ID of the train, which is a 6-digit random numerical string.
If the world contains trains from an older Advtrains version, the string may be longer and contain a dot (.
).
event = { type = "approach", approach = true, id = <train_id>, }
Fired when a train approaches the rail. This event may be generated multiple times for the same train.
luaatc-extensions
branch of Advtrains.
The approach callback mechanism is a new feature that allows LuaAutomation ATC rails to hook into the approach callback system, which is used by the Point Speed Restriction Rails (from advtrains_interlocking
) or by Station/Stop Rails (by advtrains_line_automation
). Since it is relatively a recent feature, it needs to be explicitly enabled.
At the time of writing (2019-12-18), this feature is available only in luaatc-extensions
branch of Advtrains. To use this branch, clone the Git repo in the Minetest mods directory and then git checkout luaatc-extensions
on the mod directory.
To enable the feature, define the following global variable in the local environment of the ATC rail:
-- To enable approach callback only in arrow direction __approach_callback_mode = 1 -- To enable approach callback in both directions __approach_callback_mode = 2
The event approach
will then be generated when a train approaches (which could happen anytime).
You'll have to consider the following when setting up approach callbacks:
atc_set_lzb_tsr
, you'll have to call it on every run of the approach callback.atc_send
and atc_set_text_outside
may be used. On subsequent interrupts however, this reference will no longer be available until the train enters the track.interrupt()
. Here are things that are safe to run from an approach callback: