aboutsummaryrefslogtreecommitdiff
path: root/advtrains_luaautomation/passive_api.txt
blob: a7352083d6d7cfbd7922245aa98ad487e77f19a4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
}