This shows you the differences between two versions of the page.
Next revision | Previous revision Next revision Both sides next revision | ||
usage:nodes:atc_rail [2019-07-02 12:55] 82.67.173.193 created |
usage:nodes:atc_rail [2019-11-07 09:20] orwell extend doc(part 2) |
||
---|---|---|---|
Line 10: | Line 10: | ||
===== Properties ===== | ===== Properties ===== | ||
- | Mod: '' | + | Mod: '' |
Node name: '' | Node name: '' | ||
Other names: | Other names: | ||
Line 108: | Line 108: | ||
* a string, the name of a [[# | * a string, the name of a [[# | ||
- | === POS(x, y, z) === | + | == POS(x, y, z) == |
A shorthand function to designate a Minetest position vector like '' | A shorthand function to designate a Minetest position vector like '' | ||
- | === getstate(pos) | + | === Interacting with switches and other passive components |
- | Gets the state of a passive | + | Switches (turnouts), simple signals and mesecon switches are so-called "passive |
+ | Switch: | ||
+ | " | ||
+ | " | ||
+ | Signal: (simple signals, wall signals) | ||
+ | " | ||
+ | " | ||
+ | Mesecon Switch, Andrew' | ||
+ | " | ||
+ | " | ||
- | === setstate(pos, new_state) === | + | == getstate(pos) == |
- | Sets the state of a passive component at position '' | + | Gets the state of a passive component at position '' |
- | === is_passive(pos) | + | == setstate(pos, |
+ | |||
+ | Sets the state of a passive component at position '' | ||
+ | |||
+ | == is_passive(pos) == | ||
Checks whether there is a passive component at position '' | Checks whether there is a passive component at position '' | ||
- | === interrupt(time, | + | === Interrupts |
- | Causes the LuaAutomation mod to trigger an '' | + | These functions allow to schedule interrupts, a.k.a events to be executed at a later time. They are not available in init code. |
- | This function | + | The time counter and queue handling these interrupts |
+ | <code> | ||
+ | -- an example for an " | ||
+ | if event.int then | ||
+ | interrupt(1," | ||
+ | interrupt(1," | ||
+ | -- run 1: {A,B} | ||
+ | -- run 2: {A,B,A,B} | ||
+ | -- run 3: {A, | ||
+ | </ | ||
+ | == interrupt(time, | ||
- | === interrupt_pos(pos, | + | Causes the LuaAutomation mod to trigger an '' |
+ | |||
+ | == interrupt_pos(pos, | ||
Triggers immediately an '' | Triggers immediately an '' | ||
- | **Use with care! This may lead to expotential growth of interrupts.** | + | === Railway Time === |
- | === digiline_send(channel, | + | When '' |
+ | |||
+ | For the available functions, see [[dev: | ||
+ | |||
+ | < | ||
+ | --Example: print the time of the next full minute | ||
+ | local now = rwt.now() | ||
+ | local next_minute = rwt.next_rpt(now, | ||
+ | </ | ||
+ | |||
+ | === 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 '' | ||
+ | |||
+ | There are two important considerations to this: | ||
+ | |||
+ | - While the interrupt system is always synchronized to minetest step time, the RWT scheduler follows the RWT time flow. In particular, this means that you must be able to handle "time jumps" that occur when RWT is set up to adapt to real time. | ||
+ | - The RWT scheduler has a built-in protection against " | ||
+ | |||
+ | Clicking " | ||
+ | |||
+ | == schedule(rwtime, | ||
+ | |||
+ | Triggers a '' | ||
+ | The time value here is an absolute value. | ||
+ | msg can be any data type and is accessible in '' | ||
+ | |||
+ | == schedule_in(rwtime, | ||
+ | |||
+ | Like schedule(), but the passed time is relative. | ||
+ | < | ||
+ | -- Example: schedule a " | ||
+ | schedule_in(" | ||
+ | </ | ||
+ | === Digiline === | ||
+ | |||
+ | == digiline_send(channel, | ||
Sends a [[usage: | Sends a [[usage: | ||
This function is not available in init code. | This function is not available in init code. | ||
+ | |||
+ | === Interlocking functions === | ||
+ | |||
+ | Interlocking functions are available when the '' | ||
+ | |||
+ | == can_set_route(pos, | ||
+ | |||
+ | Checks whether it is possible to set the route designated by '' | ||
+ | |||
+ | It emits a warning and halts execution of Lua code in the following cases: | ||
+ | |||
+ | * the node at specified position is not a signal: | ||
+ | |||
+ | > 2019-01-01 15:00:00: WARNING[Server]: | ||
+ | |||
+ | * '' | ||
+ | |||
+ | > 2019-01-01 15:00:00: WARNING[Server]: | ||
+ | |||
+ | * the specified route does not exist: | ||
+ | |||
+ | > 2019-01-01 15:00:00: WARNING[Server]: | ||
+ | |||
+ | == set_route(pos, | ||
+ | |||
+ | Requests the route designated by '' | ||
+ | |||
+ | Same warnings apply as for '' | ||
+ | |||
+ | If the route can't be set, the signal remains red and waits for conflicting problems to be solved. Execution continues **immediately**. | ||
+ | |||
+ | == cancel_route(pos, | ||
+ | |||
+ | Cancels the route designated by '' | ||
+ | |||
+ | Same warnings apply as for '' | ||
+ | |||
+ | If the route has already been canceled, nothing happens. | ||
+ | |||
+ | == get_aspect(pos) == | ||
+ | |||
+ | Gets the aspect of the signal at '' | ||
+ | |||
+ | Same warnings apply as for '' | ||
+ | |||
+ | ==== Events ==== | ||
+ | |||
+ | In a LuaAutomation ATC controller, an event has the following format: | ||
+ | <code lua> | ||
+ | event = { | ||
+ | type = "< | ||
+ | < | ||
+ | -- additional content | ||
+ | } | ||
+ | </ | ||
===== Trivia ===== | ===== Trivia ===== | ||
The LuaAutomation ATC rail has the same texture as the [[usage: | The LuaAutomation ATC rail has the same texture as the [[usage: |