1
0
mirror of https://github.com/mt-mods/signs_lib.git synced 2024-12-25 08:40:17 +01:00

handle interactions w/ explosions (#14)

* prevent signs entities from being destroyed

* handle tnt destroying a sign

* remove redundant destructor call
This commit is contained in:
fluxionary 2022-10-26 17:01:27 -07:00 committed by GitHub
parent 3d0e8d47e6
commit aff005e745
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

24
api.lua
View File

@ -172,6 +172,9 @@ minetest.register_entity("signs_lib:text", {
self.object:remove()
end
end,
on_blast = function(self, damage)
return false, false, {}
end,
})
function signs_lib.delete_objects(pos)
@ -742,6 +745,15 @@ function signs_lib.destruct_sign(pos)
signs_lib.delete_objects(pos)
end
function signs_lib.blast_sign(pos, intensity)
if signs_lib.can_modify(pos, "") then
local node = minetest.get_node(pos)
local drops = minetest.get_node_drops(node, "tnt:blast")
minetest.remove_node(pos)
return drops
end
end
local function make_infotext(text)
text = trim_input(text)
local lines = signs_lib.split_lines_and_words(text) or {}
@ -803,7 +815,16 @@ end
function signs_lib.can_modify(pos, player)
local meta = minetest.get_meta(pos)
local owner = meta:get_string("owner")
local playername = player:get_player_name()
local playername
if type(player) == "userdata" then
playername = player:get_player_name()
elseif type(player) == "string" then
playername = player
else
playername = ""
end
if minetest.is_protected(pos, playername) then
minetest.record_protection_violation(pos, playername)
@ -984,6 +1005,7 @@ function signs_lib.register_sign(name, raw_def)
end
def.after_place_node = raw_def.after_place_node or signs_lib.after_place_node
def.on_blast = raw_def.on_blast or signs_lib.blast_sign
if raw_def.entity_info then