Try avoid crash on nil
parent
27f836f2e4
commit
f0e3df951a
3
init.lua
3
init.lua
|
@ -6,6 +6,9 @@ minetest.register_node("nopvp:nopvp", {
|
||||||
minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage)
|
minetest.register_on_punchplayer(function(player, hitter, time_from_last_punch, tool_capabilities, dir, damage)
|
||||||
if damage > 0 then
|
if damage > 0 then
|
||||||
local pos = player:getpos()
|
local pos = player:getpos()
|
||||||
|
if not pos then
|
||||||
|
return false
|
||||||
|
end
|
||||||
local p1 = {x = pos.x - 5, y = pos.y - 5, z = pos.z - 5}
|
local p1 = {x = pos.x - 5, y = pos.y - 5, z = pos.z - 5}
|
||||||
local p2 = {x = pos.y + 5, y = pos.y + 5, z = pos.z + 5}
|
local p2 = {x = pos.y + 5, y = pos.y + 5, z = pos.z + 5}
|
||||||
if #minetest.find_nodes_in_area(p1, p2, {"nopvp:nopvp"}) > 0 then
|
if #minetest.find_nodes_in_area(p1, p2, {"nopvp:nopvp"}) > 0 then
|
||||||
|
|
Loading…
Reference in New Issue