mirror of
https://github.com/minetest-mods/throwing.git
synced 2025-01-09 09:40:26 +01:00
Call allow_shot twice
Once before the delay, and one after it
This commit is contained in:
parent
973b3430e8
commit
99e3ce6ed4
14
init.lua
14
init.lua
@ -311,8 +311,6 @@ end
|
|||||||
|
|
||||||
|
|
||||||
---------- Bows -----------
|
---------- Bows -----------
|
||||||
local bow_cooldown = {}
|
|
||||||
|
|
||||||
function throwing.register_bow(name, def)
|
function throwing.register_bow(name, def)
|
||||||
if not string.find(name, ":") then
|
if not string.find(name, ":") then
|
||||||
name = throwing.modname..":"..name
|
name = throwing.modname..":"..name
|
||||||
@ -341,7 +339,7 @@ function throwing.register_bow(name, def)
|
|||||||
local index = (def.throw_itself and user:get_wield_index()) or user:get_wield_index()+1
|
local index = (def.throw_itself and user:get_wield_index()) or user:get_wield_index()+1
|
||||||
local res, new_stack = def.allow_shot(user, user:get_inventory():get_stack("main", index), index)
|
local res, new_stack = def.allow_shot(user, user:get_inventory():get_stack("main", index), index)
|
||||||
if not res then
|
if not res then
|
||||||
return new_stack or itemstack
|
return (def.throw_itself and new_stack) or itemstack
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Sound
|
-- Sound
|
||||||
@ -350,6 +348,16 @@ function throwing.register_bow(name, def)
|
|||||||
end
|
end
|
||||||
|
|
||||||
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
|
||||||
|
local old_new_stack = new_stack
|
||||||
|
res, new_stack = def.allow_shot(user, user:get_inventory():get_stack("main", index), index)
|
||||||
|
if not new_stack then
|
||||||
|
new_stack = old_new_stack
|
||||||
|
end
|
||||||
|
if not res then
|
||||||
|
return (def.throw_itself and new_stack) or itemstack
|
||||||
|
end
|
||||||
|
|
||||||
-- Shoot arrow
|
-- Shoot arrow
|
||||||
if shoot_arrow(itemstack, user, def.throw_itself, new_stack) then
|
if shoot_arrow(itemstack, user, def.throw_itself, new_stack) then
|
||||||
if not minetest.settings:get_bool("creative_mode") then
|
if not minetest.settings:get_bool("creative_mode") then
|
||||||
|
Loading…
Reference in New Issue
Block a user