User Tools

Site Tools


usage:atlatc:api

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
usage:atlatc:api [2020-12-25 19:01]
orwell example for schedule
usage:atlatc:api [2021-03-02 20:15]
orwell commit 6135f8a2
Line 73: Line 73:
  
 Causes the LuaAutomation mod to trigger an ''int'' [[usage:atlatc:events|event]] (the Advtrains equivalent of [[usage:mods:mesecons|Mesecons]]' ''interrupt'') on this component after the given ''time'', in seconds, with the specified ''message''. ''message'' can be of any Lua data type. Causes the LuaAutomation mod to trigger an ''int'' [[usage:atlatc:events|event]] (the Advtrains equivalent of [[usage:mods:mesecons|Mesecons]]' ''interrupt'') on this component after the given ''time'', in seconds, with the specified ''message''. ''message'' can be of any Lua data type.
 +
 +Use of this function is discouraged, as "fork bombs" can easily be built. Please use ''interrupt_safe()'' or make sure to ''clear_interrupts()'' in appropriate places.
 +
 +=== interrupt_safe(time, message) ===
 +
 +//since version 3.0//
 +
 +Like ''interrupt()'', but does not add an interrupt and returns false when an interrupt (of any type) is already present for this component. Returns true when interrupt was successfully added.
  
 ===interrupt_pos(pos, message) === ===interrupt_pos(pos, message) ===
  
 Triggers immediately an ''ext_int'' [[usage:atlatc:events|event]] on the active component at ''pos''. ''message'' can be of any Lua data type. Triggers immediately an ''ext_int'' [[usage:atlatc:events|event]] on the active component at ''pos''. ''message'' can be of any Lua data type.
 +
 +=== clear_interrupts() ===
 +
 +//since version 3.0//
 +
 +Removes any pending interrupts (both of type 'int' and 'ext_int') set on this node.
 +
 +==== Remote ATC ====
 +
 +//since version 3.0//
 +
 +In addition to ''atc_send()'' described below, LuaATC provides the possibility to send ATC commands to any train in the world knowing its train ID, by means of the following function.
 +
 +=== atc_send_to_train(train_id, command) ===
 +
 +Sends the specified [[usage:nodes:atc_controller#atc_command_syntax|ATC command]] to the train specified by its 6-digit train ID and returns ''true''. If there is no train with such an ID, returns ''false'' and does nothing.
 +
 +The ATC command is instantly applied to the train in question, regardless of where it is and what it is doing. It also cancels any active ATC command of the train.
 +
 +Calling this function from an ATC rail is independent of any train that stands on the rail and does not affect it (except of course when train_id happens to be the ID of the train on the rail).
  
 ==== Railway Time ==== ==== Railway Time ====
usage/atlatc/api.txt · Last modified: 2023-07-05 17:48 by maverick2797