aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--advtrains_luaautomation/environment.lua2
-rw-r--r--advtrains_luaautomation/pcnaming.lua7
2 files changed, 7 insertions, 2 deletions
diff --git a/advtrains_luaautomation/environment.lua b/advtrains_luaautomation/environment.lua
index 63aa68d..e93b9c3 100644
--- a/advtrains_luaautomation/environment.lua
+++ b/advtrains_luaautomation/environment.lua
@@ -150,7 +150,7 @@ local static_env = {
--interrupts are handled per node, position unknown. (same goes for digilines)
--however external interrupts can be set here.
interrupt_pos = function(parpos, imesg)
- local pos=atlatc.pcnaming.resolve_pos(parpos)
+ local pos=atlatc.pcnaming.resolve_pos(parpos, "interrupt_pos")
atlatc.interrupt.add(0, pos, {type="ext_int", ext_int=true, message=imesg})
end,
-- sends an atc command to train regardless of where it is in the world
diff --git a/advtrains_luaautomation/pcnaming.lua b/advtrains_luaautomation/pcnaming.lua
index ebb769f..71f4d9a 100644
--- a/advtrains_luaautomation/pcnaming.lua
+++ b/advtrains_luaautomation/pcnaming.lua
@@ -44,7 +44,12 @@ minetest.register_craftitem("advtrains_luaautomation:pcnaming",{
return
end
local node = advtrains.ndb.get_node(pos)
- if node.name and (minetest.get_item_group(node.name, "advtrains_signal")>0 or advtrains.is_passive(pos)) then
+ local ndef = minetest.registered_nodes[node.name]
+ if node.name and (
+ minetest.get_item_group(node.name, "advtrains_signal")>0 --is IL signal
+ or advtrains.is_passive(pos) -- is passive component
+ or (ndef and ndef.luaautomation) -- is active component
+ ) then
--look if this one already has a name
local pn=""
for name, npos in pairs(atlatc.pcnaming.name_map) do
pan class="hl opt">[node.name] local st if ndef and ndef.advtrains and ndef.advtrains.getstate then st=ndef.advtrains.getstate elseif ndef and ndef.luaautomation and ndef.luaautomation.getstate then if not deprecation_warned[node.name] then minetest.log("warning", node.name.." uses deprecated definition of ATLATC functions in the 'luaautomation' field. Please move them to the 'advtrains' field!") end st=ndef.luaautomation.getstate else return nil end if type(st)=="function" then return st(pos, node) else return st end end function advtrains.setstate(parpos, newstate, pnode) local pos if atlatc then pos = atlatc.pcnaming.resolve_pos(parpos) else pos = advtrains.round_vector_floor_y(parpos) end 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=pnode or advtrains.ndb.get_node(pos) local ndef=minetest.registered_nodes[node.name] local st if ndef and ndef.advtrains and ndef.advtrains.setstate then st=ndef.advtrains.setstate elseif ndef and ndef.luaautomation and ndef.luaautomation.setstate then if not deprecation_warned[node.name] then minetest.log("warning", node.name.." uses deprecated definition of ATLATC functions in the 'luaautomation' field. Please move them to the 'advtrains' field!") end st=ndef.luaautomation.setstate else return nil end if advtrains.get_train_at_pos(pos) then return false end if advtrains.interlocking and advtrains.interlocking.route.has_route_lock(minetest.pos_to_string(pos)) then return false end st(pos, node, newstate) return true end function advtrains.is_passive(parpos, pnode) local pos if atlatc then pos = atlatc.pcnaming.resolve_pos(parpos) else pos = advtrains.round_vector_floor_y(parpos) end 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=pnode or advtrains.ndb.get_node(pos) local ndef=minetest.registered_nodes[node.name] if ndef and ndef.advtrains and ndef.advtrains.getstate then return true elseif ndef and ndef.luaautomation and ndef.luaautomation.getstate then if not deprecation_warned[node.name] then minetest.log("warning", node.name.." uses deprecated definition of ATLATC functions in the 'luaautomation' field. Please move them to the 'advtrains' field!") end return true else return false end end