0
0
Fork 0

Allow to shoot arrow anywhere in inventory

This commit is contained in:
Wuzzy 2017-02-21 21:59:45 +01:00
parent db7a3e9f03
commit d25feb2990
1 changed files with 25 additions and 12 deletions

View File

@ -25,20 +25,33 @@ mcl_throwing.shoot_arrow = function(arrow_item, pos, dir, yaw, shooter)
end
local player_shoot_arrow = function(itemstack, player)
for arrow_item, arrow_entity in pairs(arrows) do
if player:get_inventory():get_stack("main", player:get_wield_index()+1):get_name() == arrow_item then
local inv = player:get_inventory()
local arrow_stack, arrow_itemstring, arrow_stack_id
for i=1, inv:get_size("main") do
local it = inv:get_stack("main", i)
if not it:is_empty() and minetest.get_item_group(it:get_name(), "ammo_bow") ~= 0 then
arrow_stack = it
arrow_itemstring = it:get_name()
arrow_stack_id = i
break
end
end
if not minetest.setting_getbool("creative_mode") then
player:get_inventory():remove_item("main", arrow_item)
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()
mcl_throwing.shoot_arrow(arrow_item, {x=playerpos.x,y=playerpos.y+1.5,z=playerpos.z}, dir, yaw, player)
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
return false
end
local powerup_function = function(nextbow)