fix tool crash

This commit is contained in:
Evert Prants 2018-10-10 18:46:20 +03:00
parent 5084213ee5
commit f826e18ad9
Signed by: evert
GPG Key ID: 1688DA83D222D0B5

View File

@ -115,15 +115,15 @@ function ele.register_tool(toolname, tooldef)
if tooldef.on_use then if tooldef.on_use then
local original_on_use = tooldef.on_use local original_on_use = tooldef.on_use
tooldef.on_use = function (itemstack, player, pointed_thing) tooldef.on_use = function (itemstack, player, pointed_thing)
if not player or minetest.is_protected(pos, player:get_player_name()) then local pos = pointed_thing.under
if not pos or not player or minetest.is_protected(pos, player:get_player_name()) then
return itemstack return itemstack
end end
local storage = ele.tools.get_tool_property(itemstack, "storage") local storage = ele.tools.get_tool_property(itemstack, "storage")
local usage = ele.tools.get_tool_property(itemstack, "usage") local usage = ele.tools.get_tool_property(itemstack, "usage")
local pos = pointed_thing.under
if not pos or (storage < usage and not creative) then if storage < usage and not creative then
return nil return nil
end end