User Tools

Site Tools


usage:atlatc:api

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:api [2020-02-23 09:10]
orwell
usage:atlatc:api [2021-02-17 23:38]
orwell add api of commit 5232c22f
Line 73: Line 73:
  
 Causes the LuaAutomation mod to trigger an ''int'' [[usage:atlatc:events|event]] (the Advtrains equivalent of [[usage:mods:mesecons|Mesecons]]' ''interrupt'') on this component after the given ''time'', in seconds, with the specified ''message''. ''message'' can be of any Lua data type. Causes the LuaAutomation mod to trigger an ''int'' [[usage:atlatc:events|event]] (the Advtrains equivalent of [[usage:mods:mesecons|Mesecons]]' ''interrupt'') on this component after the given ''time'', in seconds, with the specified ''message''. ''message'' can be of any Lua data type.
 +
 +Use of this function is discouraged, as "fork bombs" can easily be built. Please use ''interrupt_safe()'' or make sure to ''clear_interrupts()'' in appropriate places.
 +
 +=== interrupt_safe(time, message) ===
 +
 +//since version 3.0//
 +
 +Like ''interrupt()'', but does not add an interrupt and returns false when an interrupt (of any type) is already present for this component. Returns true when interrupt was successfully added.
  
 ===interrupt_pos(pos, message) === ===interrupt_pos(pos, message) ===
  
 Triggers immediately an ''ext_int'' [[usage:atlatc:events|event]] on the active component at ''pos''. ''message'' can be of any Lua data type. Triggers immediately an ''ext_int'' [[usage:atlatc:events|event]] on the active component at ''pos''. ''message'' can be of any Lua data type.
 +
 +=== clear_interrupts() ===
 +
 +//since version 3.0//
 +
 +Removes any pending interrupts (both of type 'int' and 'ext_int') set on this node.
 +
  
 ==== Railway Time ==== ==== Railway Time ====
Line 106: Line 121:
 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 ''event.msg''. msg can be any data type and is accessible in ''event.msg''.
 +<code>
 +  -- Example: schedule a "depart" event on the next full 5 minutes
 +  local now = rwt.now()
 +  local next_5minutes = rwt.next_rpt(now, "05;00", 0)
 +  schedule(next_5minutes, "depart")
 +</code>
  
 === schedule_in(rwtime, msg) === === schedule_in(rwtime, msg) ===
usage/atlatc/api.txt · Last modified: 2023-07-05 17:48 by maverick2797