Skip to content

Commit e837621

Browse files
committedNov 26, 2016
Farming/fire: Add tool break sounds
Add tool break sounds to hoes and flint and steel. Flint and steel: Reduce gain of use sound and only add tool wear if not in creative mode.
1 parent fd87b04 commit e837621

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed
 

Diff for: ‎mods/farming/api.lua

+8-1
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,21 @@ farming.hoe_on_use = function(itemstack, user, pointed_thing, uses)
5050
return
5151
end
5252

53-
-- turn the node into soil, wear out item and play sound
53+
-- turn the node into soil and play sound
5454
minetest.set_node(pt.under, {name = regN[under.name].soil.dry})
5555
minetest.sound_play("default_dig_crumbly", {
5656
pos = pt.under,
5757
gain = 0.5,
5858
})
5959

6060
if not minetest.setting_getbool("creative_mode") then
61+
-- wear tool
62+
local wdef = itemstack:get_definition()
6163
itemstack:add_wear(65535/(uses-1))
64+
-- tool break sound
65+
if itemstack:get_count() == 0 and wdef.sound and wdef.sound.breaks then
66+
minetest.sound_play(wdef.sound.breaks, {pos = pt.above, gain = 0.5})
67+
end
6268
end
6369
return itemstack
6470
end
@@ -94,6 +100,7 @@ farming.register_hoe = function(name, def)
94100
return farming.hoe_on_use(itemstack, user, pointed_thing, def.max_uses)
95101
end,
96102
groups = def.groups,
103+
sound = {breaks = "default_tool_breaks"},
97104
})
98105
-- Register its recipe
99106
if def.material == nil then

Diff for: ‎mods/fire/init.lua

+10-2
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,14 @@ minetest.register_node("fire:permanent_flame", {
8686
minetest.register_tool("fire:flint_and_steel", {
8787
description = "Flint and Steel",
8888
inventory_image = "fire_flint_steel.png",
89+
sound = {breaks = "default_tool_breaks"},
90+
8991
on_use = function(itemstack, user, pointed_thing)
9092
local pt = pointed_thing
9193
minetest.sound_play(
9294
"fire_flint_and_steel",
93-
{pos = pt.above, gain = 0.6, max_hear_distance = 8}
95+
{pos = pt.above, gain = 0.5, max_hear_distance = 8}
9496
)
95-
itemstack:add_wear(1000)
9697
if pt.type == "node" then
9798
local node_under = minetest.get_node(pt.under).name
9899
local nodedef = minetest.registered_nodes[node_under]
@@ -112,6 +113,13 @@ minetest.register_tool("fire:flint_and_steel", {
112113
end
113114
end
114115
if not minetest.setting_getbool("creative_mode") then
116+
-- wear tool
117+
local wdef = itemstack:get_definition()
118+
itemstack:add_wear(1000)
119+
-- tool break sound
120+
if itemstack:get_count() == 0 and wdef.sound and wdef.sound.breaks then
121+
minetest.sound_play(wdef.sound.breaks, {pos = pt.above, gain = 0.5})
122+
end
115123
return itemstack
116124
end
117125
end

0 commit comments

Comments
 (0)
Please sign in to comment.