mirror of
https://github.com/minetest-mods/throwing.git
synced 2025-01-09 17:50:25 +01:00
Prevent starting more than one bow delay at a time
This commit is contained in:
parent
3db25456f2
commit
b39b1b21c3
4
init.lua
4
init.lua
@ -331,7 +331,8 @@ function throwing.register_bow(name, def)
|
|||||||
local meta = itemstack:get_meta()
|
local meta = itemstack:get_meta()
|
||||||
local cooldown = def.cooldown or tonumber(minetest.settings:get("throwing.bow_cooldown")) or 0.2
|
local cooldown = def.cooldown or tonumber(minetest.settings:get("throwing.bow_cooldown")) or 0.2
|
||||||
|
|
||||||
if cooldown > 0 and meta:get_int("cooldown") > os.time() then
|
if cooldown > 0 and meta:get_int("cooldown") > os.time()
|
||||||
|
or meta:get_int("delay") > os.time() then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -347,6 +348,7 @@ function throwing.register_bow(name, def)
|
|||||||
minetest.sound_play(def.sound, {to_player=user:get_player_name()})
|
minetest.sound_play(def.sound, {to_player=user:get_player_name()})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
meta:set_int("delay", os.time() + def.delay or 0)
|
||||||
minetest.after(def.delay or 0, function()
|
minetest.after(def.delay or 0, function()
|
||||||
-- Re-check that the arrow can be thrown. Overwrite the new_stack
|
-- Re-check that the arrow can be thrown. Overwrite the new_stack
|
||||||
local old_new_stack = new_stack
|
local old_new_stack = new_stack
|
||||||
|
Loading…
Reference in New Issue
Block a user