minetest-mm/mods/advtrains/advtrains_luaautomation/passive_api.txt

24 lines
720 B
Plaintext
Raw Normal View History

2020-11-16 17:58:14 +01:00
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.
2021-02-19 14:15:18 +01:00
All passive components have a table called 'advtrains' in their node definition and have the group 'save_in_at_nodedb' set, so they work in unloaded chunks.
2020-11-16 17:58:14 +01:00
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
}