forked from mtcontrib/spears
Fix crash
This commit is contained in:
parent
8770387fbc
commit
a5b33a6e9a
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user