This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
usage:atlatc:api [2020-01-24 10:31] orwell |
usage:atlatc:api [2022-07-03 10:10] 56independent [Digiline] Yum, seconds (more broken links for breakfast) |
||
---|---|---|---|
Line 43: | Line 43: | ||
Switches (turnouts), simple signals and mesecon switches are so-called " | Switches (turnouts), simple signals and mesecon switches are so-called " | ||
- | == getstate(pos) == | + | === getstate(pos) |
Gets the state of a passive component at position '' | Gets the state of a passive component at position '' | ||
- | == setstate(pos, | + | === setstate(pos, |
Sets the state of a passive component at position '' | Sets the state of a passive component at position '' | ||
- | == is_passive(pos) == | + | === is_passive(pos) |
Checks whether there is a passive component at position '' | Checks whether there is a passive component at position '' | ||
- | === Interrupts === | + | ==== Interrupts |
These functions allow to schedule interrupts, a.k.a events to be executed at a later time. They are not available in init code. | These functions allow to schedule interrupts, a.k.a events to be executed at a later time. They are not available in init code. | ||
Line 70: | Line 70: | ||
-- run 3: {A, | -- run 3: {A, | ||
</ | </ | ||
- | == interrupt(time, | + | === interrupt(time, |
Causes the LuaAutomation mod to trigger an '' | Causes the LuaAutomation mod to trigger an '' | ||
- | == interrupt_pos(pos, | + | Use of this function is discouraged, |
+ | |||
+ | === interrupt_safe(time, | ||
+ | |||
+ | //since version 2.3.0// | ||
+ | |||
+ | Like '' | ||
+ | |||
+ | ===interrupt_pos(pos, | ||
Triggers immediately an '' | Triggers immediately an '' | ||
- | === Railway Time === | + | === clear_interrupts() === |
+ | |||
+ | //since version 2.3.0// | ||
+ | |||
+ | Removes any pending interrupts (both of type ' | ||
+ | |||
+ | ==== Remote ATC ==== | ||
+ | |||
+ | //since version 2.3.0// | ||
+ | |||
+ | In addition to '' | ||
+ | |||
+ | === atc_send_to_train(train_id, | ||
+ | |||
+ | Sends the specified [[usage: | ||
+ | |||
+ | 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 ==== | ||
When '' | When '' | ||
- | For the available functions, see [[dev:lines:rwt]]. | + | For the available functions, see [[dev:proposals:rwt:rwt_api]]. |
< | < | ||
Line 90: | Line 118: | ||
</ | </ | ||
- | === Railway Time Scheduler === | + | ==== Railway Time Scheduler |
This is a separate schedule queue. In contrast to the interrupt system, which is the original and established way to schedule interrupts, it relies on the Railway Time system and therefore is only accessible when '' | This is a separate schedule queue. In contrast to the interrupt system, which is the original and established way to schedule interrupts, it relies on the Railway Time system and therefore is only accessible when '' | ||
Line 101: | Line 129: | ||
Clicking " | Clicking " | ||
- | == schedule(rwtime, | + | === schedule(rwtime, |
Triggers a '' | Triggers a '' | ||
The time value here is an absolute value. | The time value here is an absolute value. | ||
msg can be any data type and is accessible in '' | msg can be any data type and is accessible in '' | ||
+ | < | ||
+ | -- Example: schedule a " | ||
+ | local now = rwt.now() | ||
+ | local next_5minutes = rwt.next_rpt(now, | ||
+ | schedule(next_5minutes, | ||
+ | </ | ||
- | == schedule_in(rwtime, | + | === schedule_in(rwtime, |
Like schedule(), but the passed time is relative. | Like schedule(), but the passed time is relative. | ||
Line 115: | Line 149: | ||
</ | </ | ||
- | === Digiline === | + | ==== Digiline |
- | == digiline_send(channel, | + | === digiline_send(channel, |
- | Sends a [[usage:mods: | + | Sends a [[https:// |
This function is not available in init code. | This function is not available in init code. | ||
- | === Interlocking functions === | + | ==== Interlocking functions |
Interlocking functions are available when the '' | Interlocking functions are available when the '' | ||
- | == can_set_route(pos, | + | === can_set_route(pos, |
Checks whether it is possible to set the route designated by '' | Checks whether it is possible to set the route designated by '' | ||
Line 145: | Line 179: | ||
> LUA Error: ...: No route called B at (0,0,0) | > LUA Error: ...: No route called B at (0,0,0) | ||
- | == set_route(pos, | + | === set_route(pos, |
Requests the route designated by '' | Requests the route designated by '' | ||
Line 155: | Line 189: | ||
There is currently no way to emit an event when the signal becomes green. | There is currently no way to emit an event when the signal becomes green. | ||
- | == cancel_route(pos) == | + | === cancel_route(pos) |
Cancels the route that is set from the signal at position '' | Cancels the route that is set from the signal at position '' | ||
Line 163: | Line 197: | ||
If the route has already been canceled, nothing happens. | If the route has already been canceled, nothing happens. | ||
- | == get_aspect(pos) == | + | === get_aspect(pos) |
Gets the aspect of the signal at '' | Gets the aspect of the signal at '' | ||
Line 175: | Line 209: | ||
To control a train, this train must be positioned on the ATC rail. It does not matter which portion of the train is on the ATC rail, and whether the train is moving or not. ((An exception applies to events of type '' | To control a train, this train must be positioned on the ATC rail. It does not matter which portion of the train is on the ATC rail, and whether the train is moving or not. ((An exception applies to events of type '' | ||
- | === Functions === | + | ==== Functions |
- | == atc_send(cmd) == | + | === atc_send(cmd) |
Sends the specified [[usage: | Sends the specified [[usage: | ||
- | == atc_reset() == | + | === atc_reset() |
Resets the train' | Resets the train' | ||
- | == atc_set_text_outside(text) == | + | === atc_set_text_outside(text) |
Sets the text shown on the outside of the train and returns '' | Sets the text shown on the outside of the train and returns '' | ||
- | == atc_set_text_inside(text) == | + | === atc_set_text_inside(text) |
Sets the text shown inside the train and returns '' | Sets the text shown inside the train and returns '' | ||
- | == get_line() == | + | === atc_get_text_outside() / atc_get_text_inside() === |
+ | Gets the outside/ | ||
+ | |||
+ | === get_line() | ||
Returns the line property of the train, as a string. This string can be used to distinguish trains of different lines and route them properly. | Returns the line property of the train, as a string. This string can be used to distinguish trains of different lines and route them properly. | ||
Line 200: | Line 237: | ||
This is a bug. | This is a bug. | ||
- | == set_line(line) == | + | === set_line(line) |
- | Sets the line property of the train, as a string. On [[usage: | + | Sets the line property of the train, as a string. |
- | This property | + | On [[usage: |
- | If there is no train, | + | If there is no train, |
- | > 2019-01-01 15:00:00: WARNING[Server]: | + | === get_rc() |
- | + | ||
- | == get_rc() == | + | |
Returns the routing code of the train, as a string. This property is used by the interlocking system for Automatic Routesetting. | Returns the routing code of the train, as a string. This property is used by the interlocking system for Automatic Routesetting. | ||
- | If there is no train, | + | If there is no train, |
- | > 2019-01-01 15:00:00: WARNING[Server]: | + | === set_rc(rc) |
- | + | ||
- | == set_rc(rc) == | + | |
Sets the routing code of the train, as a string. This property is used by the interlocking system for Automatic Routesetting. | Sets the routing code of the train, as a string. This property is used by the interlocking system for Automatic Routesetting. | ||
- | If there is no train, | + | If there is no train, |
- | > 2019-01-01 15:00:00: WARNING[Server]: | + | === train_length() === |
+ | Returns the number of wagons in a train. | ||
- | == set_shunt() == | + | === set_shunt() |
Enables shunting mode for the currently passing train and returns '' | Enables shunting mode for the currently passing train and returns '' | ||
+ | |||
+ | Further details on the "Shunt Mode" are explained in the Interlocking section. ([[wiki: | ||
If there is no train, returns '' | If there is no train, returns '' | ||
- | == atc_set_ars_disable(value) == | + | === atc_set_ars_disable(value) === |
+ | |||
+ | //since version 2.3.0// | ||
Enables ('' | Enables ('' | ||
This function has essentially the same effect as the ATC command '' | This function has essentially the same effect as the ATC command '' | ||
- | **This function is experimental and currently available only in the '' | + | === atc_set_lzb_tsr(speed) === |
+ | |||
+ | //since version 2.3.0// | ||
- | == atc_set_lzb_tsr(speed) == | ||
Adds a Temporary Speed Restriction at the current rail, so that the train is passing the rail at the specified '' | Adds a Temporary Speed Restriction at the current rail, so that the train is passing the rail at the specified '' | ||
- | This function has essentially the same effect as a [[usage: | + | Calling this function |
+ | |||
+ | * This function is available only when the [[wiki: | ||
+ | * This function is only accessible during '' | ||
+ | |||
+ | === set_autocouple() === | ||
+ | |||
+ | Enables Autocouple mode. When the train hits another standing train, it couples to it and continues with its current ATC target speed in the same direction. | ||
+ | |||
+ | In contrast to the '' | ||
+ | |||
+ | //since version 2.4.0:// | ||
+ | |||
+ | The train that is initiating the coupling (that is, the train that is driving and whose mode is set to autocouple) is guaranteed to retain its Train ID. | ||
+ | |||
+ | === unset_autocouple() === | ||
- | **This function is experimental and currently available only in the '' | + | Disables |
- | * **This function is available only when the [[wiki: | + | |
- | === Fields === | + | ==== Fields |
- | == atc_id == | + | === atc_id |
The ID of the train passing the rail. '' | The ID of the train passing the rail. '' | ||
- | == atc_speed == | + | === atc_speed |
The current speed of the train passing the rail, in metres per second. '' | The current speed of the train passing the rail, in metres per second. '' | ||
- | == atc_arrow == | + | === atc_arrow |
Whether the train is driving in direction of the arrows on the ATC rail. '' | Whether the train is driving in direction of the arrows on the ATC rail. '' | ||