mirror of
https://github.com/mt-mods/xcompat.git
synced 2025-10-30 15:55:38 +01:00
convert mod from sound api to xcompat
This commit is contained in:
16
init.lua
16
init.lua
@@ -1,9 +1,15 @@
|
||||
local modpath = minetest.get_modpath("sound_api")
|
||||
local modpath = minetest.get_modpath("xcompat")
|
||||
|
||||
sound_api = dofile(modpath .. "/sound_api_core/init.lua")
|
||||
xcompat = {
|
||||
sounds = dofile(modpath .. "/src/sounds.lua"),
|
||||
materials = dofile(modpath .. "/src/materials.lua"),
|
||||
}
|
||||
|
||||
--this exists for legacy compat reasons
|
||||
sound_api = xcompat.sounds -- luacheck: ignore
|
||||
|
||||
local function validate_sound(key)
|
||||
if key and sound_api[key] then
|
||||
if key and xcompat.sounds[key] then
|
||||
return true
|
||||
elseif key then
|
||||
minetest.log("warning", "attempted to call invalid sound: "..key)
|
||||
@@ -17,7 +23,7 @@ minetest.register_on_mods_loaded(function()
|
||||
for name, def in pairs(minetest.registered_nodes) do
|
||||
if def._sound_def and validate_sound(def._sound_def.key) then
|
||||
minetest.override_item(name, {
|
||||
sounds = sound_api[def._sound_def.key](def._sound_def.input)
|
||||
sounds = xcompat.sounds[def._sound_def.key](def._sound_def.input)
|
||||
})
|
||||
end
|
||||
end
|
||||
@@ -25,7 +31,7 @@ minetest.register_on_mods_loaded(function()
|
||||
local old_reg_node = minetest.register_node
|
||||
function minetest.register_node(name, def)
|
||||
if def._sound_def and validate_sound(def._sound_def.key) then
|
||||
def.sounds = sound_api[def._sound_def.key](def._sound_def.input)
|
||||
def.sounds = xcompat.sounds[def._sound_def.key](def._sound_def.input)
|
||||
end
|
||||
|
||||
old_reg_node(name, def)
|
||||
|
||||
Reference in New Issue
Block a user