mirror of
https://github.com/mt-mods/xcompat.git
synced 2024-12-22 09:00:17 +01:00
add agnostic way to use mod
This commit is contained in:
parent
87df854e11
commit
599ddf9f1c
@ -1,7 +1,3 @@
|
|||||||
globals = {
|
globals = {
|
||||||
"sound_api",
|
"sound_api", "minetest",
|
||||||
}
|
|
||||||
|
|
||||||
read_globals = {
|
|
||||||
"minetest",
|
|
||||||
}
|
}
|
21
init.lua
21
init.lua
@ -1,3 +1,22 @@
|
|||||||
local modpath = minetest.get_modpath("sounds_api")
|
local modpath = minetest.get_modpath("sounds_api")
|
||||||
|
|
||||||
sound_api = dofile(modpath .. "/sound_api_core/init.lua")
|
sound_api = dofile(modpath .. "/sound_api_core/init.lua")
|
||||||
|
|
||||||
|
minetest.register_on_mods_loaded(function()
|
||||||
|
for name, def in pairs(minetest.registered_nodes) do
|
||||||
|
if def._sound_def and def._sound_def.key then
|
||||||
|
minetest.override_item(name, {
|
||||||
|
sounds = sound_api[def._sound_def.key](def._sound_def.input)
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local old_reg_node = minetest.register_node
|
||||||
|
function minetest.register_node(name, def)
|
||||||
|
if def._sound_def and def._sound_def.key then
|
||||||
|
def.sounds = sound_api[def._sound_def.key](def._sound_def.input)
|
||||||
|
end
|
||||||
|
|
||||||
|
old_reg_node(name, def)
|
||||||
|
end
|
||||||
|
end)
|
Loading…
Reference in New Issue
Block a user