This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
usage:nodes:atc_rail [2019-07-02 15:06] 82.67.173.193 added information to wiki article (2/4) |
usage:nodes:atc_rail [2023-12-12 01:41] (current) blockhead name was changed in some version or another |
||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== | + | ====== |
- | {{ http:// | + | {{ :usage: |
- | //Do anything you want with ATC rails.// | + | |
- | + | ||
- | ---- | + | |
- | FIXME This is a draft. Please improve this page by creating relevant pages, adding information and references to internal or external sources. | + | |
- | ---- | + | |
- | + | ||
- | //Note: this page has been written for Advtrains 2.0.1 TSS and Minetest 5.1.0. Examples and practices described in this page don't take advantage of improvements introduced in later releases.// | + | |
===== Properties ===== | ===== Properties ===== | ||
Line 31: | Line 24: | ||
* This node is an [[usage: | * This node is an [[usage: | ||
- | ===== Environments | + | ===== Operation |
- | + | ||
- | Each active component is assigned to an environment. This is where all data are held. Components in different environments can't interfere with each other. | + | |
- | + | ||
- | **Note: the [[# | + | |
- | + | ||
- | ==== Creating an environment ===== | + | |
- | //Main article: [[usage: | + | |
- | + | ||
- | + | ||
- | An environment is created by using '' | + | |
- | + | ||
- | ==== Setting up an environment ==== | + | |
- | //Main article: [[usage: | + | |
- | + | ||
- | + | ||
- | You've created your first LuaATC environment! If you execute ''/ | + | |
- | + | ||
- | {{: | + | |
- | + | ||
- | It allows you to edit your environment initialization code. | + | |
- | + | ||
- | * The button "Run InitCode" | + | |
- | * The button "Clear S" removes all elements from the '' | + | |
- | * The button " | + | |
- | * The button " | + | |
- | When the init code fails to execute, the '' | + | |
- | + | ||
- | More information on how to use that initialization code to do amazing things is given below. | + | |
- | + | ||
- | ===== Coding guide ===== | + | |
- | ==== Predefined global variables ==== | + | |
- | + | ||
- | The following global variables are available inside a LuaAutomation ATC rail: | + | |
- | + | ||
- | === S === | + | |
- | + | ||
- | A table shared between all components of an environment. Its contents are persistent over server restarts. Any value is allowed, except functions: | + | |
- | + | ||
- | **Do not store functions in this table. Calling them from another component may work, but they will be discarded on server shutdown and this may lead to unexpected results.** | + | |
- | + | ||
- | === F === | + | |
- | + | ||
- | A table shared between all components of an environment. Its contents are discarded on server shutdown or when the init code gets re-run. Any value is allowed, **even functions**. | + | |
- | + | ||
- | This table is not made to store data, but to provide static value and function definitions. This table should be populated by the initialization code. | + | |
- | + | ||
- | ==== Available Lua functions ==== | + | |
- | + | ||
- | The standard Lua globals are available in the LuaATC environment: | + | |
- | + | ||
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | + | ||
- | The standard Lua functions are available in the LuaATC environment: | + | |
- | + | ||
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | * '' | + | |
- | + | ||
- | ==== LuaAutomation-specific functions ==== | + | |
- | + | ||
- | In the following functions, all parameters named '' | + | |
- | + | ||
- | * a default Minetest position vector (like '' | + | |
- | * the '' | + | |
- | * a string, the name of a [[# | + | |
- | + | ||
- | === POS(x, y, z) === | + | |
- | + | ||
- | A shorthand function to designate a Minetest position vector like '' | + | |
- | + | ||
- | === getstate(pos) === | + | |
- | + | ||
- | Gets the state of a passive component at position '' | + | |
- | + | ||
- | === setstate(pos, | + | |
- | + | ||
- | Sets the state of a passive component at position '' | + | |
- | + | ||
- | === is_passive(pos) === | + | |
- | + | ||
- | Checks whether there is a passive component at position '' | + | |
- | + | ||
- | === interrupt(time, | + | |
- | + | ||
- | Causes the LuaAutomation mod to trigger an '' | + | |
- | + | ||
- | This function is not available in init code. | + | |
- | + | ||
- | === interrupt_pos(pos, | + | |
- | + | ||
- | Triggers immediately an '' | + | |
- | + | ||
- | **Use with care! This may lead to expotential growth of interrupts.** | + | |
- | + | ||
- | === digiline_send(channel, | + | |
- | + | ||
- | Sends a [[usage: | + | |
- | + | ||
- | 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 '' | + | The LuaATC Rail is an active LuaATC component. It holds Lua code that is executed on specific |
- | ==== Events ==== | + | Every LuaATC rail must belong to an [[usage: |
- | In a LuaAutomation ATC controller, | + | //Note: you have to create |
- | <code lua> | + | |
- | event = { | + | |
- | type = "< | + | |
- | < | + | |
- | -- additional content | + | |
- | } | + | |
- | </code> | + | |
+ | ===== API ===== | ||
+ | For details how to program LuaATC rails, refer to the [[usage: | ||
+ | {{indexmenu> | ||
===== Trivia ===== | ===== Trivia ===== | ||
- | The LuaAutomation ATC rail has the same texture as the [[usage: | + | The LuaAutomation ATC rail has the same texture as the [[usage: |