forked from VoxeLibre/VoxeLibre
Allow to shoot arrow anywhere in inventory
This commit is contained in:
parent
db7a3e9f03
commit
d25feb2990
|
@ -25,20 +25,33 @@ mcl_throwing.shoot_arrow = function(arrow_item, pos, dir, yaw, shooter)
|
||||||
end
|
end
|
||||||
|
|
||||||
local player_shoot_arrow = function(itemstack, player)
|
local player_shoot_arrow = function(itemstack, player)
|
||||||
for arrow_item, arrow_entity in pairs(arrows) do
|
local inv = player:get_inventory()
|
||||||
if player:get_inventory():get_stack("main", player:get_wield_index()+1):get_name() == arrow_item then
|
local arrow_stack, arrow_itemstring, arrow_stack_id
|
||||||
if not minetest.setting_getbool("creative_mode") then
|
for i=1, inv:get_size("main") do
|
||||||
player:get_inventory():remove_item("main", arrow_item)
|
local it = inv:get_stack("main", i)
|
||||||
end
|
if not it:is_empty() and minetest.get_item_group(it:get_name(), "ammo_bow") ~= 0 then
|
||||||
local playerpos = player:getpos()
|
arrow_stack = it
|
||||||
local dir = player:get_look_dir()
|
arrow_itemstring = it:get_name()
|
||||||
local yaw = player:get_look_horizontal()
|
arrow_stack_id = i
|
||||||
|
break
|
||||||
mcl_throwing.shoot_arrow(arrow_item, {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, dir, yaw, player)
|
|
||||||
return true
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return false
|
if not minetest.setting_getbool("creative_mode") then
|
||||||
|
if not arrow_stack then
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
arrow_stack:take_item()
|
||||||
|
inv:set_stack("main", arrow_stack_id, arrow_stack)
|
||||||
|
end
|
||||||
|
local playerpos = player:getpos()
|
||||||
|
local dir = player:get_look_dir()
|
||||||
|
local yaw = player:get_look_horizontal()
|
||||||
|
|
||||||
|
if not arrow_itemstring then
|
||||||
|
arrow_itemstring = "mcl_throwing:arrow"
|
||||||
|
end
|
||||||
|
mcl_throwing.shoot_arrow(arrow_itemstring, {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, dir, yaw, player)
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
local powerup_function = function(nextbow)
|
local powerup_function = function(nextbow)
|
||||||
|
|
Reference in New Issue