diff --git a/bows.lua b/bows.lua index bac8893..0f9857d 100644 --- a/bows.lua +++ b/bows.lua @@ -1,4 +1,8 @@ -local stiffness= 0 +--~ +--~ Shot and reload system +--~ + +local stiffness= 0 local reload = 0 minetest.register_on_joinplayer(function(player) @@ -69,14 +73,18 @@ local function reloading (player) minetest.after(reload, reloaded, player, throwing_hud) end -if not disable_wooden_bow then +--~ +--~ Bows +--~ + +if not DISABLE_WOODEN_BOW then minetest.register_tool("throwing:bow_wood", { description = "Wooden Bow", inventory_image = "throwing_bow_wood.png", wield_scale = {x=1, y=1, z=0.5}, stack_max = 1, on_use = function(itemstack, user, pointed_thing) - stiffness = 13 + stiffness = 11 reload = 1.2 if throwing_shoot_arrow(itemstack, user, pointed_thing) then reloading(user) @@ -91,69 +99,31 @@ if not disable_wooden_bow then minetest.register_craft({ output = 'throwing:bow_wood', recipe = { - {'farming:string', 'group:wood', ''}, - {'farming:string', '', 'group:wood'}, - {'farming:string', 'group:wood', ''}, + {'', 'default:stick', ''}, + {'farming:string', '', 'default:stick'}, + {'', 'default:stick', ''}, } }) minetest.register_craft({ output = 'throwing:bow_wood', recipe = { - {'', 'group:wood', 'farming:string'}, - {'group:wood', '', 'farming:string'}, - {'', 'group:wood', 'farming:string'}, + {'', 'default:stick', ''}, + {'default:stick', '', 'farming:string'}, + {'', 'default:stick', ''}, } }) end -if not disable_golden_bow then -- To be changed soon - minetest.register_tool("throwing:bow_gold", { - description = "Golden Bow", - inventory_image = "throwing_bow_gold.png", - wield_scale = {x=1, y=1, z=0.5}, - stack_max = 1, - on_use = function(itemstack, user, pointed_thing) - stiffness = 16 - reload = 1.6 - if throwing_shoot_arrow(itemstack, user, pointed_thing) then - reloading(user) - if not minetest.setting_getbool("creative_mode") then - itemstack:add_wear(65535/400) - end - end - return itemstack - end, - }) - - minetest.register_craft({ - output = 'throwing:bow_gold', - recipe = { - {'farming:string', 'default:gold_ingot', ''}, - {'farming:string', '', 'default:gold_ingot'}, - {'farming:string', 'default:gold_ingot', ''}, - } - }) - - minetest.register_craft({ - output = 'throwing:bow_gold', - recipe = { - {'', 'default:gold_ingot', 'farming:string'}, - {'default:gold_ingot', '', 'farming:string'}, - {'', 'default:gold_ingot', 'farming:string'}, - } - }) -end - -if not disable_composite_bow then - minetest.register_tool("throwing:bow_composite", { - description = "Composite Bow", - inventory_image = "throwing_bow_composite.png", - wield_scale = {x=1, y=1, z=0.5}, +if not DISABLE_LONGBOW then + minetest.register_tool("throwing:longbow", { + description = "Longbow", + inventory_image = "throwing_longbow.png", + wield_scale = {x=1, y=2.5, z=0.5}, stack_max = 1, on_use = function(itemstack, user, pointed_thing) stiffness = 18 - reload = 1.4 + reload = 2.5 if throwing_shoot_arrow(itemstack, user, pointed_thing) then reloading(user) if not minetest.setting_getbool("creative_mode") then @@ -163,39 +133,77 @@ if not disable_composite_bow then return itemstack end, }) - + minetest.register_craft({ - output = 'throwing:bow_composite', + output = 'throwing:longbow', recipe = { {'farming:string', 'group:wood', ''}, - {'farming:string', 'default:steel_ingot', 'default:steel_ingot'}, + {'farming:string', '', 'group:wood'}, {'farming:string', 'group:wood', ''}, } }) - + minetest.register_craft({ - output = 'throwing:bow_composite', + output = 'throwing:longbow', recipe = { {'', 'group:wood', 'farming:string'}, - {'default:steel_ingot', 'default:steel_ingot', 'farming:string'}, + {'group:wood', '', 'farming:string'}, {'', 'group:wood', 'farming:string'}, } }) end -if not disable_steel_bow then - minetest.register_tool("throwing:bow_steel", { - description = "Steel Bow", - inventory_image = "throwing_bow_steel.png", - wield_scale = {x=1, y=1, z=0.5}, +if not DISABLE_COMPOSITE_BOW then + minetest.register_tool("throwing:bow_composite", { + description = "Composite Bow", + inventory_image = "throwing_bow_composite.png", + wield_scale = {x=1, y=1.4, z=0.5}, stack_max = 1, on_use = function(itemstack, user, pointed_thing) - stiffness = 20 - reload = 1.6 + stiffness = 18 + reload = 1.5 if throwing_shoot_arrow(itemstack, user, pointed_thing) then reloading(user) if not minetest.setting_getbool("creative_mode") then - itemstack:add_wear(65535/200) + itemstack:add_wear(65535/150) + end + end + return itemstack + end, + }) + + minetest.register_craft({ + output = 'throwing:bow_composite', + recipe = { + {'farming:string', 'group:wood', ''}, + {'farming:string', '', 'default:steel_ingot'}, + {'farming:string', 'group:wood', ''}, + } + }) + + minetest.register_craft({ + output = 'throwing:bow_composite', + recipe = { + {'', 'group:wood', 'farming:string'}, + {'default:steel_ingot', '', 'farming:string'}, + {'', 'group:wood', 'farming:string'}, + } + }) +end + +if not DISABLE_STEEL_BOW then + minetest.register_tool("throwing:bow_steel", { + description = "Steel Bow", + inventory_image = "throwing_bow_steel.png", + wield_scale = {x=1, y=1.4, z=0.5}, + stack_max = 1, + on_use = function(itemstack, user, pointed_thing) + stiffness = 20 + reload = 1.7 + if throwing_shoot_arrow(itemstack, user, pointed_thing) then + reloading(user) + if not minetest.setting_getbool("creative_mode") then + itemstack:add_wear(65535/250) end end return itemstack diff --git a/init.lua b/init.lua index 5ecdb89..39806fc 100644 --- a/init.lua +++ b/init.lua @@ -13,42 +13,58 @@ arrows = { {"throwing:arrow_fireworks_blue", "throwing:arrow_fireworks_blue_entity"}, } -dofile(minetest.get_modpath("throwing").."/config.lua") -dofile(minetest.get_modpath("throwing").."/bows.lua") -if not disable_steel_arrow then - dofile(minetest.get_modpath("throwing").."/steel_arrow.lua") -end -if not disable_stone_arrow then - dofile(minetest.get_modpath("throwing").."/stone_arrow.lua") -end -if not disable_stone_arrow then - dofile(minetest.get_modpath("throwing").."/obsidian_arrow.lua") -end -if not disable_fire_arrow then - dofile(minetest.get_modpath("throwing").."/fire_arrow.lua") -end -if not disable_teleport_arrow then - dofile(minetest.get_modpath("throwing").."/teleport_arrow.lua") -end -if not disable_dig_arrow then - dofile(minetest.get_modpath("throwing").."/dig_arrow.lua") -end -if not disable_build_arrow then - dofile(minetest.get_modpath("throwing").."/build_arrow.lua") -end -if not disable_tnt_arrow then - dofile(minetest.get_modpath("throwing").."/tnt_arrow.lua") -end -if not disable_torch_arrow then - dofile(minetest.get_modpath("throwing").."/torch_arrow.lua") -end -if not disable_diamond_arrow then - dofile(minetest.get_modpath("throwing").."/diamond_arrow.lua") -end -if not disable_shell_arrow then - dofile(minetest.get_modpath("throwing").."/shell_arrow.lua") +local input = io.open(minetest.get_modpath("throwing").."/throwing.conf", "r") +if input then + dofile(minetest.get_modpath("throwing").."/throwing.conf") + input:close() + input = nil end +dofile(minetest.get_modpath("throwing").."/bows.lua") + +if not DISABLE_STEEL_ARROW then + dofile(minetest.get_modpath("throwing").."/steel_arrow.lua") +end + +if not DISABLE_STONE_ARROW then + dofile(minetest.get_modpath("throwing").."/stone_arrow.lua") +end + +if not DISABLE_STONE_ARROW then + dofile(minetest.get_modpath("throwing").."/obsidian_arrow.lua") +end + +if not DISABLE_FIRE_ARROW then + dofile(minetest.get_modpath("throwing").."/fire_arrow.lua") +end + +if not DISABLE_TELEPORT_ARROW then + dofile(minetest.get_modpath("throwing").."/teleport_arrow.lua") +end + +if not DISABLE_DIG_ARROW then + dofile(minetest.get_modpath("throwing").."/dig_arrow.lua") +end + +if not DISABLE_BUILD_ARROW then + dofile(minetest.get_modpath("throwing").."/build_arrow.lua") +end + +if not DISABLE_TNT_ARROW then + dofile(minetest.get_modpath("throwing").."/tnt_arrow.lua") +end + +if not DISABLE_TORCH_ARROW then + dofile(minetest.get_modpath("throwing").."/torch_arrow.lua") +end + +if not DISABLE_DIAMOND_ARROW then + dofile(minetest.get_modpath("throwing").."/diamond_arrow.lua") +end + +if not DISABLE_SHELL_ARROW then + dofile(minetest.get_modpath("throwing").."/shell_arrow.lua") +end if minetest.setting_get("log_mods") then minetest.log("action", "throwing loaded") diff --git a/textures/throwing_bow_wood.png b/textures/throwing_bow_wood.png index cb1944e..8b0f018 100644 Binary files a/textures/throwing_bow_wood.png and b/textures/throwing_bow_wood.png differ diff --git a/textures/throwing_longbow.png b/textures/throwing_longbow.png new file mode 100644 index 0000000..040a8c1 Binary files /dev/null and b/textures/throwing_longbow.png differ diff --git a/throwing.conf b/throwing.conf new file mode 100644 index 0000000..6345fe4 --- /dev/null +++ b/throwing.conf @@ -0,0 +1 @@ +DISABLE_TNT_ARROW = true \ No newline at end of file diff --git a/throwing.conf.example b/throwing.conf.example new file mode 100644 index 0000000..54dabd7 --- /dev/null +++ b/throwing.conf.example @@ -0,0 +1,6 @@ +# You can disable any bow and arrow by writing lines like these inside throwing.conf +# +# DISABLE_WOODEN_BOW = true +# +# DISABLE_TNT_ARROW = true +