From b5bc1751b5671965865ccb1ad231c9337df47e56 Mon Sep 17 00:00:00 2001 From: Joachim Stolberg Date: Fri, 30 Oct 2020 17:49:01 +0100 Subject: [PATCH] Fix bug: Tubes do not recognize when TA2 nodes are added/removed --- basic_machines/consumer.lua | 5 +---- basis/command.lua | 18 ++++++++++-------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/basic_machines/consumer.lua b/basic_machines/consumer.lua index 70ad1ad..ff32904 100644 --- a/basic_machines/consumer.lua +++ b/basic_machines/consumer.lua @@ -180,10 +180,7 @@ function techage.register_consumer(base_name, inv_name, tiles, tNode, validState if (meta:contains("node_number")) then meta:set_string("node_number", "") end - local number = "-" - if stage > 2 then - number = techage.add_node(pos, name_pas) - end + local number = techage.add_node(pos, name_pas, stage == 2) if crd.power_netw then crd.power_netw:after_place_node(pos) end diff --git a/basis/command.lua b/basis/command.lua index e8b87b8..98ac92a 100644 --- a/basis/command.lua +++ b/basis/command.lua @@ -207,10 +207,15 @@ end -- Add node to the techage lists. -- Function determines and returns the node position number, -- needed for message communication. -function techage.add_node(pos, name) +-- If TA2 node, return '-' instead of a real number, because +-- TA2 nodes should not support number based commands. +function techage.add_node(pos, name, is_ta2) if item_handling_node(name) then Tube:after_place_node(pos) end + if is_ta2 then + return "-" + end local key = minetest.hash_node_position(pos) return NumbersToBeRecycled[key] or get_number(pos, true) end @@ -222,13 +227,10 @@ function techage.remove_node(pos, oldnode, oldmetadata) if number and tonumber(number) then local key = minetest.hash_node_position(pos) NumbersToBeRecycled[key] = number - local ninfo = NodeInfoCache[number] or update_nodeinfo(number) - if ninfo then - NodeInfoCache[number] = nil - if item_handling_node(ninfo.name) then - Tube:after_dig_node(pos) - end - end + NodeInfoCache[number] = nil + end + if oldnode and item_handling_node(oldnode.name) then + Tube:after_dig_node(pos) end end