From ddcef3c20f24f5eb82144a9114a9200e751d9f86 Mon Sep 17 00:00:00 2001 From: flux <25628292+fluxionary@users.noreply.github.com> Date: Wed, 26 Oct 2022 10:23:06 -0700 Subject: [PATCH 1/6] don't let explosions destroy sign entities --- display_api/display.lua | 11 ++++++++--- signs/compatibility.lua | 8 +++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/display_api/display.lua b/display_api/display.lua index 2baef11..63881fe 100644 --- a/display_api/display.lua +++ b/display_api/display.lua @@ -269,13 +269,18 @@ end function display_api.register_display_entity(entity_name) if not minetest.registered_entities[entity_name] then minetest.register_entity(':'..entity_name, { - collisionbox = { 0, 0, 0, 0, 0, 0 }, - visual = "upright_sprite", - textures = {}, + initial_properties = { + collisionbox = {0, 0, 0, 0, 0, 0}, + visual = "upright_sprite", + textures = {}, + }, on_activate = display_api.on_activate, get_staticdata = function(self) return minetest.serialize({ nodepos = self.nodepos }) end, + on_blast = function(self, damage) + return false, false, {} + end, }) end end diff --git a/signs/compatibility.lua b/signs/compatibility.lua index dea8750..aad6fdd 100644 --- a/signs/compatibility.lua +++ b/signs/compatibility.lua @@ -61,9 +61,11 @@ minetest.register_lbm({ name = "signs:conpatibility_1", -- We need to have this entity registered to be able to remove it. if minetest.registered_entities["signs:text"] == nil then minetest.register_entity("signs:text", { - collisionbox = { 0, 0, 0, 0, 0, 0 }, - visual = "upright_sprite", - textures = {}, + on_activate = function(self) + if self.object then + self.object:remove() + end + end }) end From 2d3ab486b68c8124a726beddc34a445cb4716f55 Mon Sep 17 00:00:00 2001 From: flux <25628292+fluxionary@users.noreply.github.com> Date: Wed, 26 Oct 2022 10:32:25 -0700 Subject: [PATCH 2/6] destroy sign entities if sign node is exploded --- display_api/display.lua | 10 ++++++++++ ontime_clocks/nodes.lua | 6 ++++++ signs_api/init.lua | 1 + steles/nodes.lua | 1 + 4 files changed, 18 insertions(+) diff --git a/display_api/display.lua b/display_api/display.lua index 63881fe..cbe9e9d 100644 --- a/display_api/display.lua +++ b/display_api/display.lua @@ -251,6 +251,16 @@ function display_api.on_destruct(pos) end end +function display_api.on_blast(pos, intensity) + if not minetest.is_protected(pos, "tnt:blast") then + local node = minetest.get_node(pos) + local drops = minetest.get_node_drops(node, "tnt:blast") + minetest.remove_node(pos) + display_api.on_destruct(pos) + return drops + end +end + -- On_rotate (screwdriver) callback for display_api items. Prevents invalid -- rotations and reorients entities. function display_api.on_rotate(pos, node, user, _, new_param2) diff --git a/ontime_clocks/nodes.lua b/ontime_clocks/nodes.lua index dcdcbdd..0341eaa 100644 --- a/ontime_clocks/nodes.lua +++ b/ontime_clocks/nodes.lua @@ -59,6 +59,7 @@ minetest.register_node("ontime_clocks:green_digital", { on_place = display_api.on_place, on_construct = clock_on_construct, on_destruct = display_api.on_destruct, + on_blast = display_api.on_blast, on_rotate = display_api.on_rotate, on_timer = clock_on_timer, }) @@ -92,6 +93,7 @@ minetest.register_node("ontime_clocks:red_digital", { on_place = display_api.on_place, on_construct = clock_on_construct, on_destruct = display_api.on_destruct, + on_blast = display_api.on_blast, on_rotate = display_api.on_rotate, on_timer = clock_on_timer, }) @@ -124,6 +126,7 @@ minetest.register_node("ontime_clocks:white", { on_place = display_api.on_place, on_construct = clock_on_construct, on_destruct = display_api.on_destruct, + on_blast = display_api.on_blast, on_rotate = display_api.on_rotate, on_timer = clock_on_timer, }) @@ -156,6 +159,7 @@ minetest.register_node("ontime_clocks:frameless_black", { on_place = display_api.on_place, on_construct = clock_on_construct, on_destruct = display_api.on_destruct, + on_blast = display_api.on_blast, on_rotate = display_api.on_rotate, on_timer = clock_on_timer, }) @@ -188,6 +192,7 @@ minetest.register_node("ontime_clocks:frameless_gold", { on_place = display_api.on_place, on_construct = clock_on_construct, on_destruct = display_api.on_destruct, + on_blast = display_api.on_blast, on_rotate = display_api.on_rotate, on_timer = clock_on_timer, }) @@ -220,6 +225,7 @@ minetest.register_node("ontime_clocks:frameless_white", { on_place = display_api.on_place, on_construct = clock_on_construct, on_destruct = display_api.on_destruct, + on_blast = display_api.on_blast, on_rotate = display_api.on_rotate, on_timer = clock_on_timer, }) diff --git a/signs_api/init.lua b/signs_api/init.lua index 77767e2..fd2db03 100644 --- a/signs_api/init.lua +++ b/signs_api/init.lua @@ -192,6 +192,7 @@ function signs_api.register_sign(mod, name, model) display_api.on_construct(pos) end, on_destruct = display_api.on_destruct, + on_blast = display_api.on_blast, on_rotate = signs_api.on_rotate, on_receive_fields = signs_api.on_receive_fields, on_punch = function(pos, node, player, pointed_thing) diff --git a/steles/nodes.lua b/steles/nodes.lua index 04f83f2..d805adf 100644 --- a/steles/nodes.lua +++ b/steles/nodes.lua @@ -83,6 +83,7 @@ for i, material in ipairs(steles.materials) do set_formspec(pos) end, on_destruct = display_api.on_destruct, + on_blast = display_api.on_blast, on_rotate = display_api.on_rotate, on_receive_fields = function(pos, formname, fields, player) if not minetest.is_protected(pos, player:get_player_name()) then From 98094437b4e2012084b885b057339a9280b06eed Mon Sep 17 00:00:00 2001 From: flux <25628292+fluxionary@users.noreply.github.com> Date: Wed, 26 Oct 2022 10:39:18 -0700 Subject: [PATCH 3/6] remove redundant destructor call --- display_api/display.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/display_api/display.lua b/display_api/display.lua index cbe9e9d..6c8705d 100644 --- a/display_api/display.lua +++ b/display_api/display.lua @@ -256,7 +256,6 @@ function display_api.on_blast(pos, intensity) local node = minetest.get_node(pos) local drops = minetest.get_node_drops(node, "tnt:blast") minetest.remove_node(pos) - display_api.on_destruct(pos) return drops end end From 24a14ddc85249eda6c2e8b11d0f7f8e607624d10 Mon Sep 17 00:00:00 2001 From: flux <25628292+fluxionary@users.noreply.github.com> Date: Fri, 28 Jul 2023 16:26:38 -0700 Subject: [PATCH 4/6] make sure other things don't try to interact w/ the signs entity --- display_api/display.lua | 3 +++ 1 file changed, 3 insertions(+) diff --git a/display_api/display.lua b/display_api/display.lua index 6c8705d..f60a0bf 100644 --- a/display_api/display.lua +++ b/display_api/display.lua @@ -282,6 +282,9 @@ function display_api.register_display_entity(entity_name) collisionbox = {0, 0, 0, 0, 0, 0}, visual = "upright_sprite", textures = {}, + physical = false, + collide_with_objects = false, + pointable = false, }, on_activate = display_api.on_activate, get_staticdata = function(self) From 17aa2666df48b8b1516c1565d0d094b2cb714c0d Mon Sep 17 00:00:00 2001 From: flux <25628292+fluxionary@users.noreply.github.com> Date: Wed, 16 Aug 2023 14:07:01 -0700 Subject: [PATCH 5/6] name will be "" for non-players or unknown players. --- display_api/display.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/display_api/display.lua b/display_api/display.lua index f60a0bf..ef74a07 100644 --- a/display_api/display.lua +++ b/display_api/display.lua @@ -252,7 +252,7 @@ function display_api.on_destruct(pos) end function display_api.on_blast(pos, intensity) - if not minetest.is_protected(pos, "tnt:blast") then + if not minetest.is_protected(pos, "") then local node = minetest.get_node(pos) local drops = minetest.get_node_drops(node, "tnt:blast") minetest.remove_node(pos) From a3f02acde10777ff9e5d5d2c0211e58d3cbe2035 Mon Sep 17 00:00:00 2001 From: flux <25628292+fluxionary@users.noreply.github.com> Date: Wed, 16 Aug 2023 14:07:21 -0700 Subject: [PATCH 6/6] remove default value from initial values --- display_api/display.lua | 1 - 1 file changed, 1 deletion(-) diff --git a/display_api/display.lua b/display_api/display.lua index ef74a07..37d94aa 100644 --- a/display_api/display.lua +++ b/display_api/display.lua @@ -282,7 +282,6 @@ function display_api.register_display_entity(entity_name) collisionbox = {0, 0, 0, 0, 0, 0}, visual = "upright_sprite", textures = {}, - physical = false, collide_with_objects = false, pointable = false, },