diff --git a/api.lua b/api.lua index 5b1834f..c7e65de 100644 --- a/api.lua +++ b/api.lua @@ -131,7 +131,7 @@ function obsidianmese.fire_sword(itemstack, user, pointed_thing) end -- play shoot attack sound - minetest.sound_play("throwing_sound", { + minetest.sound_play("obsidianmese_throwing", { pos = pos, gain = 1.0, -- default max_hear_distance = 10, @@ -193,7 +193,7 @@ function obsidianmese.pick_engraved_place(itemstack, placer, pointed_thing) local pos = minetest.get_pointed_thing_position(pointed_thing) local pointed_node = minetest.get_node(pos) - -- check if have to use default on_place first + -- check if we have to use default on_place first if pick_engraved_place_blacklist[pointed_node.name] ~= nil then return minetest.item_place(itemstack, placer, pointed_thing) end @@ -204,6 +204,7 @@ function obsidianmese.pick_engraved_place(itemstack, placer, pointed_thing) local stack_mod = stack_name_split[1] udef = minetest.registered_nodes[stack_name] + -- print(dump(udef)) -- not for farming - that should be part of a hoe if stack_mod ~= "farming" or stack_mod ~= "farming_addons" then @@ -212,6 +213,14 @@ function obsidianmese.pick_engraved_place(itemstack, placer, pointed_thing) inv:set_stack("main", idx, temp_stack) -- itemstack = obsidianmese.add_wear(itemstack) + + -- play sound + if udef.sounds then + if udef.sounds.place then + minetest.sound_play(udef.sounds.place) + end + end + return itemstack elseif udef and udef.on_use then temp_stack = udef.on_use(stack, placer, pointed_thing) or stack @@ -241,12 +250,28 @@ function obsidianmese.pick_engraved_place(itemstack, placer, pointed_thing) inv:set_stack("main", idx, temp_stack) -- itemstack = obsidianmese.add_wear(itemstack) + + -- play sound + if udef and udef.sounds then + if udef.sounds.place then + minetest.sound_play(udef.sounds.place) + end + end + return itemstack end end -- if everything else fails use default on_place stack = minetest.item_place(stack, placer, pointed_thing) inv:set_stack("main", idx, stack) + + -- play sound + if udef and udef.sounds then + if udef.sounds.place then + minetest.sound_play(udef.sounds.place) + end + end + return itemstack end end diff --git a/crafting.lua b/crafting.lua index f80e9f9..2e0b747 100644 --- a/crafting.lua +++ b/crafting.lua @@ -8,7 +8,7 @@ minetest.register_craftitem("obsidianmese:mese_apple", { inventory_image = "obsidianmese_apple.png", on_use = function(itemstack, user, pointed_thing) - minetest.sound_play("apple_eat", { + minetest.sound_play("obsidianmese_apple_eat", { pos = user:getpos(), max_hear_distance = 32, gain = 0.5, diff --git a/sounds/apple_eat.1.ogg b/sounds/obsidianmese_apple_eat.1.ogg similarity index 100% rename from sounds/apple_eat.1.ogg rename to sounds/obsidianmese_apple_eat.1.ogg diff --git a/sounds/apple_eat.2.ogg b/sounds/obsidianmese_apple_eat.2.ogg similarity index 100% rename from sounds/apple_eat.2.ogg rename to sounds/obsidianmese_apple_eat.2.ogg diff --git a/sounds/throwing_sound.ogg b/sounds/obsidianmese_throwing.ogg similarity index 100% rename from sounds/throwing_sound.ogg rename to sounds/obsidianmese_throwing.ogg