aboutsummaryrefslogtreecommitdiff
path: root/advtrains/advtrains_luaautomation/passive_api.txt
diff options
context:
space:
mode:
authorGabriel Pérez-Cerezo <gabriel@gpcf.eu>2017-02-05 16:32:53 +0100
committerGabriel Pérez-Cerezo <gabriel@gpcf.eu>2017-02-05 16:32:53 +0100
commit746e328b7b77514d343bfe76922de0244b608278 (patch)
treee098b101c3ab96239f2827d44b8f8b97b3dc95d1 /advtrains/advtrains_luaautomation/passive_api.txt
parentbfd24ee43a10ab79674636e9dad725cdba093f63 (diff)
parent61e48fff280075ec52bfaa31644c22b08814d680 (diff)
downloadadvtrains-746e328b7b77514d343bfe76922de0244b608278.tar.gz
advtrains-746e328b7b77514d343bfe76922de0244b608278.tar.bz2
advtrains-746e328b7b77514d343bfe76922de0244b608278.zip
Merge branch 'master' of https://github.com/orwell96/advtrains
Diffstat (limited to 'advtrains/advtrains_luaautomation/passive_api.txt')
-rw-r--r--advtrains/advtrains_luaautomation/passive_api.txt23
1 files changed, 23 insertions, 0 deletions
diff --git a/advtrains/advtrains_luaautomation/passive_api.txt b/advtrains/advtrains_luaautomation/passive_api.txt
new file mode 100644
index 0000000..a735208
--- /dev/null
+++ b/advtrains/advtrains_luaautomation/passive_api.txt
@@ -0,0 +1,23 @@
+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
+
+All passive components have a table called 'luaautomation' in their node definition and have the group 'save_in_nodedb' set, so they work in unloaded chunks.
+Example for a switch:
+luaautomation = {
+ 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