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:events [2020-01-24 10:21] orwell Temp 2 |
usage:atlatc:events [2020-01-28 10:25] 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 operations, all 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 '' | ||
+ | |||
+ | During execution of LuaATC code, the '' | ||
<code lua> | <code lua> | ||
event = { | event = { | ||
Line 10: | Line 18: | ||
</ | </ | ||
- | You can check for a specific event type by using | + | Usually, programs will branch based on the type of event received. |
<code lua> | <code lua> | ||
if event.type == "< | if event.type == "< | ||
Line 22: | Line 30: | ||
end | end | ||
</ | </ | ||
+ | The former allows to check the event type like in mesecons luacontrollers, | ||
- | === int === | + | ===== Event Types ===== |
+ | |||
+ | ==== int ==== | ||
<code lua> | <code lua> | ||
event = { | event = { | ||
Line 32: | Line 43: | ||
} | } | ||
</ | </ | ||
- | Fired when an interrupt set by the '' | + | Fired when an interrupt set by the '' |
For backwards compatibility reasons, the message is also contained in the '' | For backwards compatibility reasons, the message is also contained in the '' | ||
- | === ext_int === | + | ==== ext_int |
<code lua> | <code lua> | ||
event = { | event = { | ||
Line 43: | Line 54: | ||
} | } | ||
</ | </ | ||
- | Fired when a node called '' | + | Fired when a node called '' |
- | === digiline === | + | ==== schedule ==== |
+ | <code lua> | ||
+ | event = { | ||
+ | type = " | ||
+ | schedule = true, | ||
+ | msg = < | ||
+ | } | ||
+ | </ | ||
+ | Fired when an interrupt set by the '' | ||
+ | |||
+ | ==== digiline | ||
<code lua> | <code lua> | ||
event = { | event = { | ||
Line 54: | Line 75: | ||
} | } | ||
</ | </ | ||
- | Fired when the rail receives a [[usage: | + | Fired when the component |
+ | ==== punch ==== | ||
+ | **Applicable for:** LuaATC Operation Panel | ||
+ | <code lua> | ||
+ | event = { | ||
+ | type = " | ||
+ | punch = true, | ||
+ | } | ||
+ | </ | ||
+ | Fired when a player punches the operation panel. | ||
- | === Events === | + | Note: Nodes other than the operation panel don't emit the '' |
- | The LuaATC rail currently supports the following events: | + | |
- | == train == | + | ==== train ==== |
+ | **Applicable for:** LuaATC Rail | ||
<code lua> | <code lua> | ||
event = { | event = { | ||
Line 71: | Line 101: | ||
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 = { |