From 91728b874ec5c2571824d0c5a21798a84e23aaee Mon Sep 17 00:00:00 2001 From: flux <25628292+fluxionary@users.noreply.github.com> Date: Tue, 1 Aug 2023 18:37:29 -0700 Subject: [PATCH 1/2] don't remove node above door if it's not a doors:hidden node --- mods/doors/init.lua | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/mods/doors/init.lua b/mods/doors/init.lua index 0c0f089682..f5c89bc399 100644 --- a/mods/doors/init.lua +++ b/mods/doors/init.lua @@ -19,6 +19,10 @@ local function replace_old_owner_information(pos) end end +local function is_doors_upper_node(pos) + return minetest.get_node(pos).name == "doors:hidden" +end + -- returns an object to a door object or nil function doors.get(pos) local node_name = minetest.get_node(pos).name @@ -388,7 +392,9 @@ function doors.register(name, def) end end def.after_dig_node = function(pos, node, meta, digger) - minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z}) + if is_doors_upper_node(pos) then + minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z}) + end minetest.check_for_falling({x = pos.x, y = pos.y + 1, z = pos.z}) end def.on_rotate = function(pos, node, user, mode, new_param2) @@ -426,15 +432,21 @@ function doors.register(name, def) def.node_dig_prediction = "" else def.on_blast = function(pos, intensity) - minetest.remove_node(pos) + if is_doors_upper_node(pos) then + minetest.remove_node(pos) + end -- hidden node doesn't get blasted away. - minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z}) + if is_doors_upper_node(pos) then + minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z}) + end return {name} end end def.on_destruct = function(pos) - minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z}) + if is_doors_upper_node(pos) then + minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z}) + end end def.drawtype = "mesh" @@ -642,7 +654,9 @@ function doors.register_trapdoor(name, def) def.node_dig_prediction = "" else def.on_blast = function(pos, intensity) - minetest.remove_node(pos) + if is_doors_upper_node(pos) then + minetest.remove_node(pos) + end return {name} end end From b56a94827e63db717e79492040616a3953432289 Mon Sep 17 00:00:00 2001 From: flux <25628292+fluxionary@users.noreply.github.com> Date: Wed, 2 Aug 2023 12:08:12 -0700 Subject: [PATCH 2/2] properly check if the node *above* the door is the hidden node --- mods/doors/init.lua | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/mods/doors/init.lua b/mods/doors/init.lua index f5c89bc399..d198f1e221 100644 --- a/mods/doors/init.lua +++ b/mods/doors/init.lua @@ -392,10 +392,11 @@ function doors.register(name, def) end end def.after_dig_node = function(pos, node, meta, digger) - if is_doors_upper_node(pos) then - minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z}) + local above = pos:offset(0, 1, 0) + if is_doors_upper_node(above) then + minetest.remove_node(above) end - minetest.check_for_falling({x = pos.x, y = pos.y + 1, z = pos.z}) + minetest.check_for_falling(above) end def.on_rotate = function(pos, node, user, mode, new_param2) return false @@ -432,20 +433,20 @@ function doors.register(name, def) def.node_dig_prediction = "" else def.on_blast = function(pos, intensity) - if is_doors_upper_node(pos) then - minetest.remove_node(pos) - end + minetest.remove_node(pos) + local above = pos:offset(0, 1, 0) -- hidden node doesn't get blasted away. - if is_doors_upper_node(pos) then - minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z}) + if is_doors_upper_node(above) then + minetest.remove_node(above) end return {name} end end def.on_destruct = function(pos) - if is_doors_upper_node(pos) then - minetest.remove_node({x = pos.x, y = pos.y + 1, z = pos.z}) + local above = pos:offset(0, 1, 0) + if is_doors_upper_node(above) then + minetest.remove_node(above) end end @@ -654,9 +655,7 @@ function doors.register_trapdoor(name, def) def.node_dig_prediction = "" else def.on_blast = function(pos, intensity) - if is_doors_upper_node(pos) then - minetest.remove_node(pos) - end + minetest.remove_node(pos) return {name} end end