Allow rightclicking for bows at any time

This commit is contained in:
Wuzzy 2017-02-14 22:09:00 +01:00
parent 4d0e1eb2e9
commit 64ae08073a
1 changed files with 20 additions and 23 deletions

View File

@ -41,16 +41,21 @@ local player_shoot_arrow = function(itemstack, player)
return false return false
end end
local powerup_function = function(nextbow)
return function(itemstack, placer, pointed_thing)
local wear = itemstack:get_wear()
itemstack:replace(nextbow)
itemstack:add_wear(wear)
return itemstack
end
end
minetest.register_tool("mcl_throwing:bow", { minetest.register_tool("mcl_throwing:bow", {
description = "Bow", description = "Bow",
inventory_image = "mcl_throwing_bow.png", inventory_image = "mcl_throwing_bow.png",
stack_max = 1, stack_max = 1,
on_place = function(itemstack, placer, pointed_thing) on_place = powerup_function("mcl_throwing:bow_0"),
local wear = itemstack:get_wear() on_secondary_use = powerup_function("mcl_throwing:bow_0"),
itemstack:replace("mcl_throwing:bow_0")
itemstack:add_wear(wear)
return itemstack
end,
groups = {weapon=1,weapon_ranged=1}, groups = {weapon=1,weapon_ranged=1},
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
local wear = itemstack:get_wear() local wear = itemstack:get_wear()
@ -69,12 +74,8 @@ minetest.register_tool("mcl_throwing:bow_0", {
inventory_image = "mcl_throwing_bow_0.png", inventory_image = "mcl_throwing_bow_0.png",
stack_max = 1, stack_max = 1,
groups = {not_in_creative_inventory=1, not_in_craft_guide=1}, groups = {not_in_creative_inventory=1, not_in_craft_guide=1},
on_place = function(itemstack, placer, pointed_thing) on_place = powerup_function("mcl_throwing:bow_1"),
local wear = itemstack:get_wear() on_secondary_use = powerup_function("mcl_throwing:bow_1"),
itemstack:replace("mcl_throwing:bow_1")
itemstack:add_wear(wear)
return itemstack
end,
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
local wear = itemstack:get_wear() local wear = itemstack:get_wear()
itemstack:add_wear(wear) itemstack:add_wear(wear)
@ -92,12 +93,8 @@ minetest.register_tool("mcl_throwing:bow_1", {
inventory_image = "mcl_throwing_bow_1.png", inventory_image = "mcl_throwing_bow_1.png",
stack_max = 1, stack_max = 1,
groups = {not_in_creative_inventory=1, not_in_craft_guide=1}, groups = {not_in_creative_inventory=1, not_in_craft_guide=1},
on_place = function(itemstack, placer, pointed_thing) on_place = powerup_function("mcl_throwing:bow_2"),
local wear = itemstack:get_wear() on_secondary_use = powerup_function("mcl_throwing:bow_2"),
itemstack:replace("mcl_throwing:bow_2")
itemstack:add_wear(wear)
return itemstack
end,
on_use = function(itemstack, user, pointed_thing) on_use = function(itemstack, user, pointed_thing)
local wear = itemstack:get_wear() local wear = itemstack:get_wear()
itemstack:add_wear(wear) itemstack:add_wear(wear)