mirror of
https://github.com/minetest-mods/moreblocks.git
synced 2024-09-27 14:50:30 +02:00
use loop over table to map sound functions (partially applied suggestion from appgurueu)
This commit is contained in:
parent
f823628fcd
commit
52dacbdebf
52
sounds.lua
52
sounds.lua
|
@ -1,48 +1,20 @@
|
||||||
--[[
|
--[[
|
||||||
More Blocks: sound definitions
|
More Blocks: sound definitions
|
||||||
|
|
||||||
Copyright © 2011-2020 Hugo Locurcio and contributors.
|
Copyright © 2011-2021 Hugo Locurcio and contributors.
|
||||||
Licensed under the zlib license. See LICENSE.md for more information.
|
Licensed under the zlib license. See LICENSE.md for more information.
|
||||||
--]]
|
--]]
|
||||||
|
|
||||||
function moreblocks.node_sound_wood_defaults()
|
local has_default_mod = minetest.get_modpath("default")
|
||||||
if minetest.get_modpath("default") then
|
for _, sound in ipairs({"dirt", "wood", "stone", "metal", "glass", "leaves"}) do
|
||||||
-- default game
|
-- use sound-function from default if available
|
||||||
return default.node_sound_wood_defaults()
|
-- otherwise fall back to a no-op function (no sounds)
|
||||||
end
|
local sound_function_name = "node_sound_" .. sound .. "_defaults"
|
||||||
end
|
if has_default_mod then
|
||||||
|
-- use default sounds
|
||||||
function moreblocks.node_sound_glass_defaults()
|
moreblocks[sound_function_name] = default[sound_function_name]
|
||||||
if minetest.get_modpath("default") then
|
else
|
||||||
-- default game
|
-- no-op
|
||||||
return default.node_sound_glass_defaults()
|
moreblocks[sound_function_name] = function() end
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function moreblocks.node_sound_metal_defaults()
|
|
||||||
if minetest.get_modpath("default") then
|
|
||||||
-- default game
|
|
||||||
return default.node_sound_metal_defaults()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function moreblocks.node_sound_stone_defaults()
|
|
||||||
if minetest.get_modpath("default") then
|
|
||||||
-- default game
|
|
||||||
return default.node_sound_stone_defaults()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function moreblocks.node_sound_dirt_defaults()
|
|
||||||
if minetest.get_modpath("default") then
|
|
||||||
-- default game
|
|
||||||
return default.node_sound_dirt_defaults()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function moreblocks.node_sound_leaves_defaults()
|
|
||||||
if minetest.get_modpath("default") then
|
|
||||||
-- default game
|
|
||||||
return default.node_sound_leaves_defaults()
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user