summaryrefslogtreecommitdiff
path: root/advtrains_luaautomation/passive_api.txt
diff options
context:
space:
mode:
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>2020-10-10 23:28:42 +0200
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>2020-10-10 23:28:42 +0200
commit5aad0930d1ddd63d9021d833a9379b4a01bd8414 (patch)
tree8fac88986a2cd4f00ed6b1855dd1dafa08c09662 /advtrains_luaautomation/passive_api.txt
downloadforks-modpack-5aad0930d1ddd63d9021d833a9379b4a01bd8414.tar.gz
forks-modpack-5aad0930d1ddd63d9021d833a9379b4a01bd8414.tar.bz2
forks-modpack-5aad0930d1ddd63d9021d833a9379b4a01bd8414.zip
Squashed 'advtrains/' content from commit 3256c27
git-subtree-dir: advtrains git-subtree-split: 3256c2778d626548541bcdfabf3026f781a2287c
Diffstat (limited to 'advtrains_luaautomation/passive_api.txt')
-rw-r--r--advtrains_luaautomation/passive_api.txt24
1 files changed, 24 insertions, 0 deletions
diff --git a/advtrains_luaautomation/passive_api.txt b/advtrains_luaautomation/passive_api.txt
new file mode 100644
index 0000000..9852e94
--- /dev/null
+++ b/advtrains_luaautomation/passive_api.txt
@@ -0,0 +1,24 @@
+Lua Automation - Passive Component API
+
+Passive components are nodes that do not have code running in them. However, active components can query these and request actions from them. Examples:
+Switches
+Signals
+Displays
+Mesecon Transmitter
+Those passive components can also be used inside interlocking systems.
+
+All passive components have a table called 'advtrains' in their node definition and have the group 'save_in_nodedb' set, so they work in unloaded chunks.
+Example for a switch:
+advtrains = {
+ getstate = function(pos, node)
+ return "st"
+ end,
+ -- OR
+ getstate = "st",
+
+ setstate = function(pos, node, newstate)
+ if newstate=="cr" then
+ advtrains.ndb.swap_node(pos, <corresponding switch alt>)
+ end
+ end
+} \ No newline at end of file