User Tools

Site Tools


usage:nodes:atc_rail

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 Both sides next revision
usage:nodes:atc_rail [2019-11-07 08:58]
orwell extend doc(part 1)
usage:nodes:atc_rail [2019-11-07 09:20]
orwell extend doc(part 2)
Line 142: Line 142:
  
 The time counter and queue handling these interrupts is synchronized to minetest's internal step time. It is written in a very simple fashion, and is NOT secured against "interrupt bombs". Be careful! The time counter and queue handling these interrupts is synchronized to minetest's internal step time. It is written in a very simple fashion, and is NOT secured against "interrupt bombs". Be careful!
- +<code> 
-  -- an example for an "interrupt bomb" +-- an example for an "interrupt bomb" 
-  if event.int then +if event.int then 
-    interrupt(1,"A"+  interrupt(1,"A"
-    interrupt(1,"B"+  interrupt(1,"B"
-  -- run 1: {A,B} +-- run 1: {A,B} 
-  -- run 2: {A,B,A,B} +-- run 2: {A,B,A,B} 
-  -- run 3: {A,B,A,B,A,B,A,B}... +-- run 3: {A,B,A,B,A,B,A,B}... 
 +</code>
 == interrupt(time, message) == == interrupt(time, message) ==
  
Line 158: Line 158:
  
 Triggers immediately an ''ext_int'' event on the active component at ''pos'' (can't be a string). ''message'' can be of any Lua data type. Triggers immediately an ''ext_int'' event on the active component at ''pos'' (can't be a string). ''message'' can be of any Lua data type.
 +
 +=== Railway Time ===
 +
 +When ''advtrains_line_automation'' is enabled, all Railway time functions are exposed as rwt.* and can safely be used in LuaATC code.
 +
 +For the available functions, see [[dev:lines:rwt]].
 +
 +<code>
 +--Example: print the time of the next full minute
 +local now = rwt.now()
 +local next_minute = rwt.next_rpt(now, "01;00", 0)
 +</code>
  
 === Railway Time Scheduler === === Railway Time Scheduler ===
Line 165: Line 177:
 There are two important considerations to this: There are two important considerations to this:
  
-1. 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. +  - 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. 
-2. The RWT scheduler has a built-in protection against "interrupt bombs". There is a limit on how many interrupts can be enqueued from a single LuaATC component. At the time of this writing, this limit is set to ''1''.+  The RWT scheduler has a built-in protection against "interrupt bombs". There is a limit on how many interrupts can be enqueued from a single LuaATC component. At the time of this writing, this limit is set to ''1''
 + 
 +Clicking "Save" on the code edit form clears all events currently scheduled in the RWT scheduler. It does NOT clear the interrupt scheduler events.
  
 == schedule(rwtime, msg) == == schedule(rwtime, msg) ==
Line 177: Line 191:
  
 Like schedule(), but the passed time is relative. Like schedule(), but the passed time is relative.
 +<code>
   -- Example: schedule a "depart" event in 1 minute   -- Example: schedule a "depart" event in 1 minute
   schedule_in("01;00", "depart")   schedule_in("01;00", "depart")
 +</code>
 === Digiline === === Digiline ===
  
Line 189: Line 203:
 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 ''[[usage:mods#advtrains_interlocking|advtrains_interlocking]]'' mod is enabled. Interlocking functions are available when the ''[[usage:mods#advtrains_interlocking|advtrains_interlocking]]'' mod is enabled.
  
-=== can_set_route(pos, route_name) ===+== can_set_route(pos, route_name) ==
  
 Checks whether it is possible to set the route designated by ''route_name'' from the signal at position ''pos''. Checks whether it is possible to set the route designated by ''route_name'' from the signal at position ''pos''.
Line 211: Line 225:
 > 2019-01-01 15:00:00: WARNING[Server]: [advtrains]LuaAutomation ATC interface rail at (0,0,0) : LUA Error: ...ds/advtrains/advtrains_luaautomation/environment.lua:185: No route called B at (0,0,0) > 2019-01-01 15:00:00: WARNING[Server]: [advtrains]LuaAutomation ATC interface rail at (0,0,0) : LUA Error: ...ds/advtrains/advtrains_luaautomation/environment.lua:185: No route called B at (0,0,0)
  
-=== set_route(pos, route_name) ===+== set_route(pos, route_name) ==
  
 Requests the route designated by ''route_name'' from the signal at position ''pos''. Has the same effect as clicking the "Set Route" in the formspec from the designated signal. Requests the route designated by ''route_name'' from the signal at position ''pos''. Has the same effect as clicking the "Set Route" in the formspec from the designated signal.
Line 219: Line 233:
 If the route can't be set, the signal remains red and waits for conflicting problems to be solved. Execution continues **immediately**. 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, route_name) ===+== cancel_route(pos, route_name) ==
  
 Cancels the route designated by ''route_name'' that is set from the signal at position ''pos''. Has the same effect as clicking the "Cancel Route" in the formspec from the designated signal. Cancels the route designated by ''route_name'' that is set from the signal at position ''pos''. Has the same effect as clicking the "Cancel Route" in the formspec from the designated signal.
Line 227: Line 241:
 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 ''pos''. The aspect format is described in the [[usage:nodes:signal#aspect_format|Signal]] page. Gets the aspect of the signal at ''pos''. The aspect format is described in the [[usage:nodes:signal#aspect_format|Signal]] page.
Line 243: Line 257:
 } }
 </code> </code>
- 
- 
  
 ===== Trivia ===== ===== Trivia =====
  
 The LuaAutomation ATC rail has the same texture as the [[usage:nodes:atc_controller|ATC controller rail]], but its functions are different. The LuaAutomation ATC rail has the same texture as the [[usage:nodes:atc_controller|ATC controller rail]], but its functions are different.
usage/nodes/atc_rail.txt · Last modified: 2023-12-12 02:41 by blockhead