From b19033b224f4f8ec33f10ba40327f1d811c04fbb Mon Sep 17 00:00:00 2001 From: orwell96 Date: Thu, 2 Feb 2017 16:40:51 +0100 Subject: LuaAutomation - Basic component implementation Implements the base code for LuaAutomation, an ATC rail and a punch-operated 'operation panel' as well as interface for passive components. Changes in advtrains code where neccessary. Supported passive components are light signals, switches and mesecon switches --- advtrains/advtrains_luaautomation/passive_api.txt | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 advtrains/advtrains_luaautomation/passive_api.txt (limited to 'advtrains/advtrains_luaautomation/passive_api.txt') 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, ) + end + end +} \ No newline at end of file -- cgit v1.2.3