diff --git a/mods/armor/README.txt b/mods/armor/README.txt index 5c16bb1..8083da5 100644 --- a/mods/armor/README.txt +++ b/mods/armor/README.txt @@ -5,5 +5,5 @@ By Kaadmy, for Pixture Adds craftable and wearable armor -Asset license: CC BY-SA 4.0 +Media files license: CC BY-SA 4.0 Source code license: LGPLv2.1 diff --git a/mods/armor/init.lua b/mods/armor/init.lua index ab76def..022ed1c 100644 --- a/mods/armor/init.lua +++ b/mods/armor/init.lua @@ -250,6 +250,7 @@ for mat_index, matdef in ipairs(armor.materials) do armor_changed = true end if armor_changed then + minetest.sound_play({name="armor_equip", object=user}, {gain=0.5}, true) armor.update(user) return itemstack end @@ -310,6 +311,7 @@ end) -- Move armor items to correct slot minetest.register_on_player_inventory_action(function(player, action, inventory, inventory_info) + local sound -- 1 == equip, 2 = unequip if action == "move" and inventory_info.to_list == "armor" then local stack = inventory:get_stack(inventory_info.to_list, inventory_info.to_index) local name = stack:get_name() @@ -318,6 +320,7 @@ minetest.register_on_player_inventory_action(function(player, action, inventory, inventory:set_stack("armor", inventory_info.to_index, "") inventory:set_stack("armor", slot, stack) end + sound = 1 elseif action == "put" and inventory_info.listname == "armor" then local name = inventory_info.stack:get_name() local slot = minetest.get_item_group(name, "armor_slot") @@ -325,11 +328,29 @@ minetest.register_on_player_inventory_action(function(player, action, inventory, inventory:set_stack("armor", inventory_info.index, "") inventory:set_stack("armor", slot, stack) end + sound = 1 end - if action == "move" and inventory_info.to_list == "armor" or inventory_info.from_list == "armor" then - armor.update(player) - elseif action == "put" or action == "take" and inventory_info.listname == "armor" then - armor.update(player) + if action == "move" then + if inventory_info.to_list == "armor" then + sound = 1 + armor.update(player) + elseif inventory_info.from_list == "armor" then + sound = 2 + armor.update(player) + end + elseif inventory_info.listname == "armor" then + if action == "put" then + sound = 1 + armor.update(player) + elseif action == "take" then + sound = 2 + armor.update(player) + end + end + if sound == 1 then + minetest.sound_play({name="armor_equip", object=player}, {gain=0.5}, true) + elseif sound == 2 then + minetest.sound_play({name="armor_unequip", object=player}, {gain=0.5}, true) end end) diff --git a/mods/armor/sounds/armor_equip.ogg b/mods/armor/sounds/armor_equip.ogg new file mode 100644 index 0000000..7cd5b80 Binary files /dev/null and b/mods/armor/sounds/armor_equip.ogg differ diff --git a/mods/armor/sounds/armor_unequip.ogg b/mods/armor/sounds/armor_unequip.ogg new file mode 100644 index 0000000..5ef767d Binary files /dev/null and b/mods/armor/sounds/armor_unequip.ogg differ