Remove bow when weared down
This commit is contained in:
parent
7194800898
commit
1b811c0941
20
api.lua
20
api.lua
|
@ -687,7 +687,9 @@ function XBows.shoot(self, itemstack, user, pointed_thing)
|
||||||
|
|
||||||
---stop punching close objects/nodes when shooting
|
---stop punching close objects/nodes when shooting
|
||||||
minetest.after(0.2, function()
|
minetest.after(0.2, function()
|
||||||
if user:get_wielded_item():get_name() == itemstack:get_name() then
|
local wield_item = user:get_wielded_item()
|
||||||
|
|
||||||
|
if wield_item:get_count() > 0 and wield_item:get_name() == itemstack:get_name() then
|
||||||
user:set_wielded_item(ItemStack({name = bow_name, wear = itemstack:get_wear()}))
|
user:set_wielded_item(ItemStack({name = bow_name, wear = itemstack:get_wear()}))
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
@ -707,16 +709,24 @@ function XBows.shoot(self, itemstack, user, pointed_thing)
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
if not self:is_creative(user:get_player_name()) then
|
|
||||||
itemstack:add_wear(65535 / uses)
|
|
||||||
end
|
|
||||||
|
|
||||||
minetest.sound_play(sound_name, {
|
minetest.sound_play(sound_name, {
|
||||||
gain = 0.3,
|
gain = 0.3,
|
||||||
pos = user:get_pos(),
|
pos = user:get_pos(),
|
||||||
max_hear_distance = 10
|
max_hear_distance = 10
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if not self:is_creative(user:get_player_name()) then
|
||||||
|
itemstack:add_wear(65535 / uses)
|
||||||
|
end
|
||||||
|
|
||||||
|
if itemstack:get_count() == 0 then
|
||||||
|
minetest.sound_play('default_tool_breaks', {
|
||||||
|
gain = 0.3,
|
||||||
|
pos = user:get_pos(),
|
||||||
|
max_hear_distance = 10
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
return itemstack
|
return itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Ŝarĝante…
Reference in New Issue