From 6a81492c4dc5778701c312ec6add4e377b510c55 Mon Sep 17 00:00:00 2001 From: oilboi <47129783+oilboi@users.noreply.github.com> Date: Thu, 28 May 2020 04:28:05 -0400 Subject: [PATCH] Make arrows finite --- mods/bow/init.lua | 73 ++++++++++++++++-------------- mods/bow/textures/arrow_core.png | Bin 114 -> 0 bytes mods/bow/textures/arrow_item.png | Bin 714 -> 1785 bytes mods/bow/textures/front_alpha.png | Bin 1018 -> 0 bytes 4 files changed, 39 insertions(+), 34 deletions(-) delete mode 100644 mods/bow/textures/arrow_core.png delete mode 100644 mods/bow/textures/front_alpha.png diff --git a/mods/bow/init.lua b/mods/bow/init.lua index f8f463d..84187a8 100644 --- a/mods/bow/init.lua +++ b/mods/bow/init.lua @@ -211,49 +211,54 @@ minetest.register_globalstep(function(dtime) if minetest.get_item_group(item, "bow") > 0 then --begin to pull the bow back if player:get_player_control().RMB == true then - local meta = player:get_meta() - local animation = meta:get_float("bow_loading_animation") - - if animation <= 5 then - - if animation == 0 then - animation = 1 - player:set_wielded_item(ItemStack("bow:bow_1")) - end - animation = animation + (dtime*2) + local inv = player:get_inventory() + if inv:contains_item("main", ItemStack("bow:arrow")) then + local meta = player:get_meta() + local animation = meta:get_float("bow_loading_animation") - --print(animation) + if animation <= 5 then - meta:set_float("bow_loading_animation", animation) - - local level = minetest.get_item_group(item, "bow_loaded") - - - local new_level = math.floor(animation + 0.5) - - --print(new_level,level) - - if new_level > level then - if level > 0 then - minetest.sound_play("bow_pull_back", {object=player, gain = 1.0, max_hear_distance = 60,pitch = 0.7+new_level*0.1}) + if animation == 0 then + animation = 1 + player:set_wielded_item(ItemStack("bow:bow_1")) + end + animation = animation + (dtime*2) + + --print(animation) + + meta:set_float("bow_loading_animation", animation) + + local level = minetest.get_item_group(item, "bow_loaded") + + + local new_level = math.floor(animation + 0.5) + + --print(new_level,level) + + if new_level > level then + if level > 0 then + minetest.sound_play("bow_pull_back", {object=player, gain = 1.0, max_hear_distance = 60,pitch = 0.7+new_level*0.1}) + end + player:set_wielded_item(ItemStack("bow:bow_"..new_level)) end - player:set_wielded_item(ItemStack("bow:bow_"..new_level)) end end - - --player:set_wielded_item(ItemStack("main:glass")) else local power = minetest.get_item_group(item, "bow_loaded") if power > 0 then - local dir = player:get_look_dir() - local vel = vector.multiply(dir,power*10) - local pos = player:get_pos() - pos.y = pos.y + 1.625 - local object = minetest.add_entity(pos,"bow:arrow") - object:set_velocity(vel) - object:get_luaentity().owner = player:get_player_name() - minetest.sound_play("bow", {object=player, gain = 1.0, max_hear_distance = 60,pitch = math.random(80,100)/100}) + local inv = player:get_inventory() + if inv:contains_item("main", ItemStack("bow:arrow")) then + local dir = player:get_look_dir() + local vel = vector.multiply(dir,power*10) + local pos = player:get_pos() + pos.y = pos.y + 1.625 + local object = minetest.add_entity(pos,"bow:arrow") + object:set_velocity(vel) + object:get_luaentity().owner = player:get_player_name() + minetest.sound_play("bow", {object=player, gain = 1.0, max_hear_distance = 60,pitch = math.random(80,100)/100}) + inv:remove_item("main", ItemStack("bow:arrow")) + end end player:set_wielded_item(ItemStack("bow:bow_empty")) diff --git a/mods/bow/textures/arrow_core.png b/mods/bow/textures/arrow_core.png deleted file mode 100644 index 175333db62454545c171836e987d5ab9453c50e6..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 114 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`oCO|{#S9GG!XV7ZFl&wkP*BCw z#WBP}FgYb5;RpYb6lS$erB0@OQU?wgNU<$WWH`mgJfDxj*MU*~_DY6Ypn3*RS3j3^ HP6aB^>EX>4U6ba`-PAZ2)IW&i+q+O1Yuk}D|; z{O1&N1SGMD<4`OSbAvhlBuka;ejVNRvkMoCz*3@=piKMk-){cF!=%MC}q7FuSd-S<>$IPu)FwdwZ|i zdt1B9E?~=HZ|d9$nbE_-V+6tcTR@3;J^FE$grYE1Ky|gn9w>zpF(~fjs8XhGsLf8H z0*sCuN3_g^Wy%y>Brc$wKspL_j*_H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