From 9cb782dca23ac1f28b5cae1848caa8009466728a Mon Sep 17 00:00:00 2001 From: Sergei Mozhaisky Date: Mon, 18 May 2020 09:12:30 +0000 Subject: [PATCH] update: digtron --- digtron/nodes/node_crate.lua | 12 +++++++++--- digtron/util.lua | 5 ++++- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/digtron/nodes/node_crate.lua b/digtron/nodes/node_crate.lua index 196b21f..532473a 100644 --- a/digtron/nodes/node_crate.lua +++ b/digtron/nodes/node_crate.lua @@ -271,7 +271,9 @@ local loaded_on_dig = function(pos, player, loaded_node_name) local inv = player:get_inventory() local stack = inv:add_item("main", stack) if stack:get_count() > 0 then - minetest.add_item(pos, stack) + -- prevent crash by not dropping loaded crate (see #44) + -- minetest.add_item(pos, stack) + return false end -- call on_dignodes callback minetest.remove_node(pos) @@ -333,6 +335,7 @@ minetest.register_node("digtron:loaded_crate", { after_place_node = function(pos, placer, itemstack, pointed_thing) loaded_after_place(pos, itemstack) end, + on_drop = function(a, b, c) end -- prevent dropping loaded digtrons, causing server to crash (see #44) }) minetest.register_node("digtron:loaded_locked_crate", { @@ -349,7 +352,9 @@ minetest.register_node("digtron:loaded_locked_crate", { local meta = minetest.get_meta(pos) meta:set_string("owner", "") end, - +-- can_dig = function(pos,node,player) +-- return player and not minetest.is_protected(pos, player:get_player_name()) and player_permitted(pos,player) +-- end, on_dig = function(pos, node, player) if player and not minetest.is_protected(pos, player:get_player_name()) and player_permitted(pos,player) then return loaded_on_dig(pos, player, "digtron:loaded_locked_crate") @@ -373,7 +378,8 @@ minetest.register_node("digtron:loaded_locked_crate", { "digtron:loaded_locked_crate"..minetest.pos_to_string(pos), loaded_formspec_string:gsub("${title}", meta:get_string("title"), 1)) end - end, + end, + on_drop = function(a, b, c) end -- prevent dropping loaded digtrons, causing server to crash }) minetest.register_on_player_receive_fields(function(player, formname, fields) diff --git a/digtron/util.lua b/digtron/util.lua index aca1c07..d69ea71 100644 --- a/digtron/util.lua +++ b/digtron/util.lua @@ -325,6 +325,9 @@ local damage_def = { damage_groups = {}, } digtron.damage_creatures = function(player, source_pos, target_pos, amount, items_dropped) + if type(player) ~= 'userdata' then + return + end local objects = minetest.env:get_objects_inside_radius(target_pos, 1.0) if objects ~= nil then damage_def.damage_groups.fleshy = amount @@ -433,4 +436,4 @@ digtron.show_offset_markers = function(pos, offset, period) local entity = safe_add_entity({x=buildpos.x, y=buildpos.y, z=z_pos + period}, "digtron:marker") if entity ~= nil then entity:setyaw(1.5708) end end -end \ No newline at end of file +end