User Tools

Site Tools


usage:atlatc:events

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:events [2020-01-24 10:21]
orwell Temp 2
usage:atlatc:events [2020-01-28 10:18]
orwell
Line 1: Line 1:
-==== Events ====+====== Events ======
  
-In a LuaAutomation ATC controller, an event has the following format:+LuaATC is event-based. All code is run in an asynchronous manner. There are no blocking operationsall API functions return immediately. 
 + 
 +They are not executed in parallel. You do not need to take precautions for thread-safety. Execution of LuaATC code is never interrupted externally. 
 + 
 +Every time an event occurs that affects a LuaATC component, the whole code contained in the component is executed. It is the responsibility of the code to branch execution based on the event type. 
 + 
 +===== The ''event'' table ===== 
 + 
 +During execution of LuaATC code, the ''event'' table contains information on the event that triggered the execution:
 <code lua> <code lua>
 event = { event = {
Line 10: Line 18:
 </code> </code>
  
-You can check for a specific event type by using+Usually, programs will branch based on the type of event received. You can check for a specific event type by using either
 <code lua> <code lua>
 if event.type == "<wanted>" then if event.type == "<wanted>" then
Line 22: Line 30:
 end end
 </code> </code>
 +The former allows to check the event type like in mesecons luacontrollers, while the latter is more lua-ish and most commonly used.
  
-=== int ===+===== Event Types ===== 
 + 
 +==== int ====
 <code lua> <code lua>
 event = { event = {
Line 32: Line 43:
 } }
 </code> </code>
-Fired when an interrupt set by the ''[[#interrupt_time_message|interrupt]]'' function runs out. ''<message>'' is the message passed to the function.  +Fired when an interrupt set by the ''[[usage:atlatc:api#interrupt_time_message|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. For backwards compatibility reasons, the message is also contained in the ''event.message'' field.
  
-=== ext_int ===+==== ext_int ====
 <code lua> <code lua>
 event = { event = {
Line 43: Line 54:
 } }
 </code> </code>
-Fired when a node called ''[[#interrupt_pos_pos_message|interrupt_pos]]'' on this node's position. ''<message>'' is the message passed to the function.+Fired when a node called ''[[usage:atlatc:api#interrupt_pos_pos_message|interrupt_pos]]'' on this node's position. ''<message>'' is the message passed to the function.
  
-=== digiline ===+==== digiline ====
 <code lua> <code lua>
 event = { event = {
Line 54: Line 65:
 } }
 </code> </code>
-Fired when the rail receives a [[usage:mods:digiline|Digiline]] message. +Fired when the component receives a [[usage:mods:digiline|Digiline]] message.
- +
- +
-=== Events === +
-The LuaATC rail currently supports the following events:+
  
-== train ==+==== train ==== 
 +**Applicable for:** LuaATC Rail
 <code lua> <code lua>
 event = { event = {
Line 71: Line 79:
 If the world contains trains from an older Advtrains version, the string may be longer and contain a dot (''.''). If the world contains trains from an older Advtrains version, the string may be longer and contain a dot (''.'').
  
-== approach ==+==== approach ==== 
 +**Applicable for:** LuaATC Rail
 <code lua> <code lua>
 event = { event = {
usage/atlatc/events.txt · Last modified: 2023-10-29 16:30 by orwell