diff options
author | orwell96 <orwell@bleipb.de> | 2018-08-16 19:18:03 +0200 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2018-08-16 19:18:03 +0200 |
commit | 05cb6090ac9537650a900b64768bf3ed959cebed (patch) | |
tree | 11b7e3ab4bb846ab069fc10832b07cb36d6eb6dd /advtrains_luaautomation/passive.lua | |
parent | 5fad61e9c981115a183527ffe58a7bbe26fea4e7 (diff) | |
download | advtrains-05cb6090ac9537650a900b64768bf3ed959cebed.tar.gz advtrains-05cb6090ac9537650a900b64768bf3ed959cebed.tar.bz2 advtrains-05cb6090ac9537650a900b64768bf3ed959cebed.zip |
Move passive API to the advtrains core
to remove dependency of interlocking on luaautomation
Diffstat (limited to 'advtrains_luaautomation/passive.lua')
-rw-r--r-- | advtrains_luaautomation/passive.lua | 52 |
1 files changed, 0 insertions, 52 deletions
diff --git a/advtrains_luaautomation/passive.lua b/advtrains_luaautomation/passive.lua deleted file mode 100644 index e0902f5..0000000 --- a/advtrains_luaautomation/passive.lua +++ /dev/null @@ -1,52 +0,0 @@ --- passive.lua --- API to passive components, as described in passive_api.txt - -local function getstate(parpos) - local pos=atlatc.pcnaming.resolve_pos(parpos) - if type(pos)~="table" or (not pos.x or not pos.y or not pos.z) then - debug.sethook() - error("Invalid position supplied to getstate") - end - local node=advtrains.ndb.get_node(pos) - local ndef=minetest.registered_nodes[node.name] - if ndef and ndef.luaautomation and ndef.luaautomation.getstate then - local st=ndef.luaautomation.getstate - if type(st)=="function" then - return st(pos, node) - else - return st - end - end - return nil -end - -local function setstate(parpos, newstate) - local pos=atlatc.pcnaming.resolve_pos(parpos) - if type(pos)~="table" or (not pos.x or not pos.y or not pos.z) then - debug.sethook() - error("Invalid position supplied to setstate") - end - local node=advtrains.ndb.get_node(pos) - local ndef=minetest.registered_nodes[node.name] - if ndef and ndef.luaautomation and ndef.luaautomation.setstate then - local st=ndef.luaautomation.setstate - st(pos, node, newstate) - end -end - -local function is_passive(parpos) - local pos=atlatc.pcnaming.resolve_pos(parpos) - if type(pos)~="table" or (not pos.x or not pos.y or not pos.z) then - return false - end - local node=advtrains.ndb.get_node(pos) - local ndef=minetest.registered_nodes[node.name] - if ndef and ndef.luaautomation and ndef.luaautomation.getstate then - return true - end - return false -end - --- gets called from environment.lua --- return the values here to keep them local -return getstate, setstate, is_passive |