Fix crash

This commit is contained in:
Sys Quatre 2020-08-09 00:58:12 +02:00
parent 8770387fbc
commit a5b33a6e9a

View File

@ -69,17 +69,18 @@ function spears_set_entity(spear_type, base_damage, toughness)
if self._stickpos then
local node = minetest.get_node(self._stickpos)
local node_cracky = minetest.registered_nodes[node.name].groups.cracky
local pos = self.object:get_pos()
if node_cracky and node_cracky < 3 then
minetest.sound_play("default_metal_footstep", {pos = pos}, true)
self.object:remove()
minetest.add_item(self.object:get_pos(), {name='spears:spear_' .. spear_type, wear = self._wear})
minetest.add_item(pos, {name='spears:spear_' .. spear_type, wear = self._wear})
elseif not self._node_walkable then
minetest.sound_play("default_place_node", {pos = throw_pos}, true)
end
self._node_walkable = minetest.registered_nodes[node.name].walkable
if not node or not self._node_walkable then -- Fall when node is removed
self.object:remove()
minetest.add_item(self.object:get_pos(), {name='spears:spear_' .. spear_type, wear = self._wear})
minetest.add_item(pos, {name='spears:spear_' .. spear_type, wear = self._wear})
return
end
else -- Spear is flying