1
0
Fork 0

Add sounds when using composter

This commit is contained in:
SmokeyDope 2023-03-16 01:46:01 +00:00 committed by Gitea
parent 3b4fc04330
commit 20f8e18098
1 changed files with 5 additions and 3 deletions

View File

@ -76,6 +76,7 @@ local function composter_add_item(pos, node, player, itemstack, pointed_thing)
if chance > 0 then if chance > 0 then
if not is_creative_enabled(player:get_player_name()) then if not is_creative_enabled(player:get_player_name()) then
itemstack:take_item() itemstack:take_item()
minetest.sound_play({name="default_gravel_dug", pos=above, gain=1}, true)
end end
-- calculate leveling up chance -- calculate leveling up chance
local rand = math.random(0,100) local rand = math.random(0,100)
@ -84,7 +85,6 @@ local function composter_add_item(pos, node, player, itemstack, pointed_thing)
local level = registered_nodes[node.name]["_mcl_compost_level"] local level = registered_nodes[node.name]["_mcl_compost_level"]
-- spawn green particles above new layer -- spawn green particles above new layer
mcl_dye.add_bone_meal_particle(vector_offset(pos, 0, level/8, 0)) mcl_dye.add_bone_meal_particle(vector_offset(pos, 0, level/8, 0))
-- TODO: play some sounds
-- update composter block -- update composter block
if level < 7 then if level < 7 then
level = level + 1 level = level + 1
@ -94,6 +94,8 @@ local function composter_add_item(pos, node, player, itemstack, pointed_thing)
swap_node(pos, {name = "mcl_composters:composter_" .. level}) swap_node(pos, {name = "mcl_composters:composter_" .. level})
-- a full composter becomes ready for harvest after one second -- a full composter becomes ready for harvest after one second
-- the block will get updated by the node timer callback set in node reg def -- the block will get updated by the node timer callback set in node reg def
minetest.sound_play({name="default_grass_footstep", pos=above, gain=1}, true)
if level == 7 then if level == 7 then
local timer = get_node_timer(pos) local timer = get_node_timer(pos)
timer:start(1) timer:start(1)
@ -114,7 +116,7 @@ end
local function composter_ready(pos) local function composter_ready(pos)
swap_node(pos, {name = "mcl_composters:composter_ready"}) swap_node(pos, {name = "mcl_composters:composter_ready"})
-- maybe spawn particles again? -- maybe spawn particles again?
-- TODO: play some sounds minetest.sound_play({name="default_dig_snappy", pos=above, gain=1}, true)
return false return false
end end