2024-02-25 06:10:30 +01:00
|
|
|
local modpath = minetest.get_modpath("xcompat")
|
2022-01-19 04:29:18 +01:00
|
|
|
|
2024-02-25 06:10:30 +01:00
|
|
|
xcompat = {
|
2024-05-26 17:07:43 +02:00
|
|
|
modpath = modpath,
|
2024-02-25 06:10:30 +01:00
|
|
|
}
|
|
|
|
|
2024-05-26 17:07:43 +02:00
|
|
|
xcompat.gameid = dofile(modpath .. "/src/gameid.lua")
|
|
|
|
xcompat.utilities = dofile(modpath .. "/src/utilities.lua")
|
|
|
|
|
|
|
|
xcompat.sounds = dofile(modpath .. "/src/sounds.lua")
|
|
|
|
xcompat.materials = dofile(modpath .. "/src/materials.lua")
|
|
|
|
xcompat.textures = dofile(modpath .. "/src/textures.lua")
|
2024-05-26 18:31:52 +02:00
|
|
|
xcompat.functions = dofile(modpath .. "/src/functions.lua")
|
2024-09-09 00:01:52 +02:00
|
|
|
xcompat.player = dofile(modpath .. "/src/player.lua")
|
2024-05-26 17:07:43 +02:00
|
|
|
|
2022-08-12 06:31:57 +02:00
|
|
|
local function validate_sound(key)
|
2024-02-25 06:10:30 +01:00
|
|
|
if key and xcompat.sounds[key] then
|
2022-08-12 06:31:57 +02:00
|
|
|
return true
|
|
|
|
elseif key then
|
|
|
|
minetest.log("warning", "attempted to call invalid sound: "..key)
|
|
|
|
else
|
|
|
|
minetest.log("warning", "sound_def is missing a sound_api key")
|
|
|
|
end
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
|
2022-01-30 02:46:20 +01:00
|
|
|
minetest.register_on_mods_loaded(function()
|
|
|
|
for name, def in pairs(minetest.registered_nodes) do
|
2022-08-12 06:31:57 +02:00
|
|
|
if def._sound_def and validate_sound(def._sound_def.key) then
|
2022-01-30 02:46:20 +01:00
|
|
|
minetest.override_item(name, {
|
2024-02-25 06:10:30 +01:00
|
|
|
sounds = xcompat.sounds[def._sound_def.key](def._sound_def.input)
|
2022-01-30 02:46:20 +01:00
|
|
|
})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
local old_reg_node = minetest.register_node
|
|
|
|
function minetest.register_node(name, def)
|
2022-08-12 06:31:57 +02:00
|
|
|
if def._sound_def and validate_sound(def._sound_def.key) then
|
2024-02-25 06:10:30 +01:00
|
|
|
def.sounds = xcompat.sounds[def._sound_def.key](def._sound_def.input)
|
2022-01-30 02:46:20 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
old_reg_node(name, def)
|
|
|
|
end
|
2022-08-12 06:31:57 +02:00
|
|
|
end)
|
2024-05-26 17:07:43 +02:00
|
|
|
|
2024-08-16 21:00:36 +02:00
|
|
|
dofile(modpath .. "/src/commands.lua")
|
|
|
|
|
2024-08-19 07:07:07 +02:00
|
|
|
if minetest.get_modpath("mtt") and mtt.enabled then
|
2024-08-16 21:00:36 +02:00
|
|
|
-- register tests
|
|
|
|
dofile(modpath .. "/mtt.lua")
|
|
|
|
end
|