From 2abe0851a365b43026aaa794dc3f2c9fd6522b43 Mon Sep 17 00:00:00 2001 From: unknown <24964441+wsor4035@users.noreply.github.com> Date: Tue, 18 Jan 2022 22:16:01 -0500 Subject: [PATCH 1/5] intial commit --- .luacheckrc | 7 ++ LICENSE | 19 +++++ init.lua | 242 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 268 insertions(+) create mode 100644 .luacheckrc create mode 100644 LICENSE create mode 100644 init.lua diff --git a/.luacheckrc b/.luacheckrc new file mode 100644 index 0000000..5b3d0e4 --- /dev/null +++ b/.luacheckrc @@ -0,0 +1,7 @@ +globals = { + "sound_api", +} + +read_globals = { + "minetest", "mcl_sounds", "default", "ks_sounds", "nodes_nature", "fl_stone", "fl_topsoil", "fl_trees", +} \ No newline at end of file diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..50e6e01 --- /dev/null +++ b/LICENSE @@ -0,0 +1,19 @@ + +MIT Copyright 2021 wsor4035 + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software is furnished to do so, +subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \ No newline at end of file diff --git a/init.lua b/init.lua new file mode 100644 index 0000000..8445fee --- /dev/null +++ b/init.lua @@ -0,0 +1,242 @@ +sound_api = {} + +--convert some games for api usage + +--ks_sounds conversion +--currently loggy and bedrock are ignored +local ks = {} + +function ks.node_sound_defaults(table) + table = table or {} + table.footstep = table.footstep or ks_sounds.generalnode_sounds.footstep + table.dug = table.dug or ks_sounds.generalnode_sounds.dug + table.dig = table.dig or ks_sounds.generalnode_sounds.dig + table.place = table.place or ks_sounds.generalnode_sounds.place + return table +end + +function ks.node_sound_wood_defaults(table) + table = table or {} + table.footstep = table.footstep or ks_sounds.woodennode_sounds.footstep + table.dug = table.dug or ks_sounds.woodennode_sounds.dug + table.dig = table.dig or ks_sounds.woodennode_sounds.dig + table.place = table.place or ks_sounds.woodennode_sounds.place + ks.node_sound_defaults(table) + return table +end + +function ks.node_sound_leaves_defaults(table) + table = table or {} + table.footstep = table.footstep or ks_sounds.leafynode_sounds.footstep + table.dug = table.dug or ks_sounds.leafynode_sounds.dug + table.dig = table.dig or ks_sounds.leafynode_sounds.dig + table.place = table.place or ks_sounds.leafynode_sounds.place + ks.node_sound_defaults(table) + return table +end + +function ks.node_sound_snow_defaults(table) + table = table or {} + table.footstep = table.footstep or ks_sounds.snowynode_sounds.footstep + table.dug = table.dug or ks_sounds.snowynode_sounds.dug + table.dig = table.dig or ks_sounds.snowynode_sounds.dig + table.place = table.place or ks_sounds.snowynode_sounds.place + ks.node_sound_defaults(table) + return table +end + + +--api +function sound_api.node_sound_default(table) + if minetest.get_modpath("default") then + return default.node_sound_defaults(table) + elseif minetest.get_modpath("mcl_sounds") then + return mcl_sounds.node_sound_defaults(table) + elseif minetest.get_modpath("ks_sounds") then + return ks.node_sound_default(table) + elseif minetest.get_modpath("nodes_nature") then + return nodes_nature.node_sound_default(table) + else + return table + end +end + +function sound_api.node_sound_stone_defaults(table) + if minetest.get_modpath("default") then + return default.node_sound_stone_defaults(table) + elseif minetest.get_modpath("mcl_sounds") then + return mcl_sounds.node_sound_stone_defaults(table) + elseif minetest.get_modpath("nodes_nature") then + return nodes_nature.node_sound_stone_defaults(table) + elseif minetest.get_modpath("fl_stone") then + return fl_stone.sounds.stone(table) + else + return table + end +end + +function sound_api.node_sound_dirt_defaults(table) + if minetest.get_modpath("default") then + return default.node_sound_dirt_defaults(table) + elseif minetest.get_modpath("mcl_sounds") then + return mcl_sounds.node_sound_dirt_defaults(table) + elseif minetest.get_modpath("nodes_nature") then + return nodes_nature.node_sound_dirt_defaults(table) + --s/dirt/grass + elseif minetest.get_modpath("fl_topsoil") then + return fl_topsoil.sounds.grass(table) + else + return table + end +end + +function sound_api.node_sound_sand_defaults(table) + if minetest.get_modpath("default") then + return default.node_sound_sand_defaults(table) + elseif minetest.get_modpath("mcl_sounds") then + return mcl_sounds.node_sound_sand_defaults(table) + elseif minetest.get_modpath("nodes_nature") then + return nodes_nature.node_sound_sand_defaults(table) + elseif minetest.get_modpath("fl_stone") then + return fl_stone.sounds.sand(table) + else + return table + end +end + +function sound_api.node_sound_gravel_defaults(table) + if minetest.get_modpath("default") then + return default.node_sound_gravel_defaults(table) + --s/gravel/sand + elseif minetest.get_modpath("mcl_sounds") then + return mcl_sounds.node_sound_sand_defaults(table) + elseif minetest.get_modpath("nodes_nature") then + return nodes_nature.node_sound_gravel_defaults(table) + elseif minetest.get_modpath("fl_topsoil") then + return fl_topsoil.sounds.gravel(table) + else + return table + end +end + +function sound_api.node_sound_wood_defaults(table) + if minetest.get_modpath("default") then + return default.node_sound_wood_defaults(table) + elseif minetest.get_modpath("mcl_sounds") then + return mcl_sounds.node_sound_wood_defaults(table) + elseif minetest.get_modpath("ks_sounds") then + return ks.node_sound_wood_default(table) + elseif minetest.get_modpath("nodes_nature") then + return nodes_nature.node_sound_wood_defaults(table) + elseif minetest.get_modpath("fl_trees") then + return fl_trees.sounds.wood(table) + else + return table + end +end + +function sound_api.node_sound_leaves_defaults(table) + if minetest.get_modpath("default") then + return default.node_sound_leaves_defaults(table) + elseif minetest.get_modpath("mcl_sounds") then + return mcl_sounds.node_sound_leaves_defaults(table) + elseif minetest.get_modpath("ks_sounds") then + return ks.node_sound_leaves_default(table) + elseif minetest.get_modpath("nodes_nature") then + return nodes_nature.node_sound_leaves_defaults(table) + else + return table + end +end + +function sound_api.node_sound_glass_defaults(table) + if minetest.get_modpath("default") then + return default.node_sound_glass_defaults(table) + elseif minetest.get_modpath("mcl_sounds") then + return mcl_sounds.node_sound_glass_defaults(table) + elseif minetest.get_modpath("nodes_nature") then + return nodes_nature.node_sound_glass_defaults(table) + else + return table + end +end + + +function sound_api.node_sound_ice_defaults(table) + if minetest.get_modpath("default") then + return default.node_sound_ice_defaults(table) + --s/ice/glass + elseif minetest.get_modpath("mcl_sounds") then + return mcl_sounds.node_sound_glass_defaults(table) + --s/ice/glass + elseif minetest.get_modpath("nodes_nature") then + return nodes_nature.node_sound_glass_defaults(table) + else + return table + end +end + +function sound_api.node_sound_metal_defaults(table) + if minetest.get_modpath("default") then + return default.node_sound_metal_defaults(table) + elseif minetest.get_modpath("mcl_sounds") then + return mcl_sounds.node_sound_metal_defaults(table) + else + return table + end +end + +function sound_api.node_sound_water_defaults(table) + if minetest.get_modpath("default") then + return default.node_sound_water_defaults(table) + elseif minetest.get_modpath("mcl_sounds") then + return mcl_sounds.node_sound_water_defaults(table) + elseif minetest.get_modpath("nodes_nature") then + return nodes_nature.node_sound_water_defaults(table) + else + return table + end +end + +function sound_api.node_sound_lava_defaults(table) + --s/lava/water + if minetest.get_modpath("default") then + return default.node_sound_water_defaults(table) + elseif minetest.get_modpath("mcl_sounds") then + return mcl_sounds.node_sound_lava_defaults(table) + --s/lava/water + elseif minetest.get_modpath("nodes_nature") then + return nodes_nature.node_sound_water_defaults(table) + else + return table + end +end + +function sound_api.node_sound_snow_defaults(table) + if minetest.get_modpath("default") then + return default.node_sound_snow_defaults(table) + elseif minetest.get_modpath("mcl_sounds") then + return mcl_sounds.node_sound_snow_defaults(table) + elseif minetest.get_modpath("ks_sounds") then + return ks.node_sound_snow_default(table) + elseif minetest.get_modpath("nodes_nature") then + return nodes_nature.node_sound_snow_defaults(table) + elseif minetest.get_modpath("fl_topsoil") then + return fl_topsoil.sounds.snow(table) + else + return table + end +end + +function sound_api.node_sound_wool_defaults(table) + --s/wool/default + if minetest.get_modpath("default") then + return default.node_sound_defaults(table) + elseif minetest.get_modpath("mcl_sounds") then + return mcl_sounds.node_sound_wool_defaults(table) + else + return table + end +end + +return sound_api \ No newline at end of file From a75bfbf2d67ae10f9d0c02a0ab2a0b326c82e9f4 Mon Sep 17 00:00:00 2001 From: unknown <24964441+wsor4035@users.noreply.github.com> Date: Tue, 18 Jan 2022 22:38:26 -0500 Subject: [PATCH 2/5] add alias grass -> function --- init.lua | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/init.lua b/init.lua index 8445fee..122b4c1 100644 --- a/init.lua +++ b/init.lua @@ -90,6 +90,11 @@ function sound_api.node_sound_dirt_defaults(table) end end +--return dirt as some games use dirt vs grass +function sound_api.node_sound_grass_defaults(table) + return sound_api.node_sound_dirt_defaults(table) +end + function sound_api.node_sound_sand_defaults(table) if minetest.get_modpath("default") then return default.node_sound_sand_defaults(table) From 87bd12dd0facb4c58f8643b10f98a27dd112b21a Mon Sep 17 00:00:00 2001 From: unknown <24964441+wsor4035@users.noreply.github.com> Date: Tue, 18 Jan 2022 23:02:19 -0500 Subject: [PATCH 3/5] fix global leak --- .luacheckrc | 4 ---- init.lua | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index 5b3d0e4..dc03d95 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,7 +1,3 @@ -globals = { - "sound_api", -} - read_globals = { "minetest", "mcl_sounds", "default", "ks_sounds", "nodes_nature", "fl_stone", "fl_topsoil", "fl_trees", } \ No newline at end of file diff --git a/init.lua b/init.lua index 122b4c1..9dc6b24 100644 --- a/init.lua +++ b/init.lua @@ -1,4 +1,4 @@ -sound_api = {} +local sound_api = {} --convert some games for api usage From 6956e49e775f325116f8e0c643899c089c691e1e Mon Sep 17 00:00:00 2001 From: unknown <24964441+wsor4035@users.noreply.github.com> Date: Sun, 27 Feb 2022 10:44:38 -0500 Subject: [PATCH 4/5] fix https://github.com/mt-mods/sound_api_core/issues/ --- .luacheckrc | 4 +++- init.lua | 31 ++++++++++++++++++++++++++++++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/.luacheckrc b/.luacheckrc index dc03d95..1bd7ddb 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,3 +1,5 @@ read_globals = { - "minetest", "mcl_sounds", "default", "ks_sounds", "nodes_nature", "fl_stone", "fl_topsoil", "fl_trees", + "minetest", "mcl_sounds", "default", "ks_sounds", + "nodes_nature", "fl_stone", "fl_topsoil", "fl_trees", + "hades_sounds", } \ No newline at end of file diff --git a/init.lua b/init.lua index 9dc6b24..a7db7dc 100644 --- a/init.lua +++ b/init.lua @@ -56,6 +56,8 @@ function sound_api.node_sound_default(table) return ks.node_sound_default(table) elseif minetest.get_modpath("nodes_nature") then return nodes_nature.node_sound_default(table) + elseif minetest.get_modpath("hades_sounds") then + return hades_sounds.node_sound_defaults(table) else return table end @@ -70,6 +72,8 @@ function sound_api.node_sound_stone_defaults(table) return nodes_nature.node_sound_stone_defaults(table) elseif minetest.get_modpath("fl_stone") then return fl_stone.sounds.stone(table) + elseif minetest.get_modpath("hades_sounds") then + return hades_sounds.node_sound_stone_defaults(table) else return table end @@ -85,6 +89,8 @@ function sound_api.node_sound_dirt_defaults(table) --s/dirt/grass elseif minetest.get_modpath("fl_topsoil") then return fl_topsoil.sounds.grass(table) + elseif minetest.get_modpath("hades_sounds") then + return hades_sounds.node_sound_dirt_defaults(table) else return table end @@ -92,7 +98,11 @@ end --return dirt as some games use dirt vs grass function sound_api.node_sound_grass_defaults(table) - return sound_api.node_sound_dirt_defaults(table) + if minetest.get_modpath("hades_sounds") then + return hades_sounds.node_sound_grass_defaults(table) + else + return sound_api.node_sound_dirt_defaults(table) + end end function sound_api.node_sound_sand_defaults(table) @@ -104,6 +114,8 @@ function sound_api.node_sound_sand_defaults(table) return nodes_nature.node_sound_sand_defaults(table) elseif minetest.get_modpath("fl_stone") then return fl_stone.sounds.sand(table) + elseif minetest.get_modpath("hades_sounds") then + return hades_sounds.node_sound_sand_defaults(table) else return table end @@ -119,6 +131,8 @@ function sound_api.node_sound_gravel_defaults(table) return nodes_nature.node_sound_gravel_defaults(table) elseif minetest.get_modpath("fl_topsoil") then return fl_topsoil.sounds.gravel(table) + elseif minetest.get_modpath("hades_sounds") then + return hades_sounds.node_sound_gravel_defaults(table) else return table end @@ -135,6 +149,8 @@ function sound_api.node_sound_wood_defaults(table) return nodes_nature.node_sound_wood_defaults(table) elseif minetest.get_modpath("fl_trees") then return fl_trees.sounds.wood(table) + elseif minetest.get_modpath("hades_sounds") then + return hades_sounds.node_sound_wood_defaults(table) else return table end @@ -149,6 +165,8 @@ function sound_api.node_sound_leaves_defaults(table) return ks.node_sound_leaves_default(table) elseif minetest.get_modpath("nodes_nature") then return nodes_nature.node_sound_leaves_defaults(table) + elseif minetest.get_modpath("hades_sounds") then + return hades_sounds.node_sound_leaves_defaults(table) else return table end @@ -161,6 +179,8 @@ function sound_api.node_sound_glass_defaults(table) return mcl_sounds.node_sound_glass_defaults(table) elseif minetest.get_modpath("nodes_nature") then return nodes_nature.node_sound_glass_defaults(table) + elseif minetest.get_modpath("hades_sounds") then + return hades_sounds.node_sound_glass_defaults(table) else return table end @@ -176,6 +196,9 @@ function sound_api.node_sound_ice_defaults(table) --s/ice/glass elseif minetest.get_modpath("nodes_nature") then return nodes_nature.node_sound_glass_defaults(table) + --s/ice/glass + elseif minetest.get_modpath("hades_sounds") then + return hades_sounds.node_sound_glass_defaults(table) else return table end @@ -186,6 +209,8 @@ function sound_api.node_sound_metal_defaults(table) return default.node_sound_metal_defaults(table) elseif minetest.get_modpath("mcl_sounds") then return mcl_sounds.node_sound_metal_defaults(table) + elseif minetest.get_modpath("hades_sounds") then + return hades_sounds.node_sound_metal_defaults(table) else return table end @@ -198,6 +223,8 @@ function sound_api.node_sound_water_defaults(table) return mcl_sounds.node_sound_water_defaults(table) elseif minetest.get_modpath("nodes_nature") then return nodes_nature.node_sound_water_defaults(table) + elseif minetest.get_modpath("hades_sounds") then + return hades_sounds.node_sound_water_defaults(table) else return table end @@ -212,6 +239,8 @@ function sound_api.node_sound_lava_defaults(table) --s/lava/water elseif minetest.get_modpath("nodes_nature") then return nodes_nature.node_sound_water_defaults(table) + elseif minetest.get_modpath("hades_sounds") then + return hades_sounds.node_sound_lava_defaults(table) else return table end From 39c02a99de4c00bae20d20534aa80d8aaa37eb88 Mon Sep 17 00:00:00 2001 From: wsor4035 <24964441+wsor4035@users.noreply.github.com> Date: Mon, 25 Apr 2022 21:14:25 -0400 Subject: [PATCH 5/5] add bleeding edge repixture support (#4) --- .luacheckrc | 2 +- init.lua | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/.luacheckrc b/.luacheckrc index 1bd7ddb..0d32191 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,5 +1,5 @@ read_globals = { "minetest", "mcl_sounds", "default", "ks_sounds", "nodes_nature", "fl_stone", "fl_topsoil", "fl_trees", - "hades_sounds", + "hades_sounds", "rp_sounds", } \ No newline at end of file diff --git a/init.lua b/init.lua index a7db7dc..13396c3 100644 --- a/init.lua +++ b/init.lua @@ -58,6 +58,8 @@ function sound_api.node_sound_default(table) return nodes_nature.node_sound_default(table) elseif minetest.get_modpath("hades_sounds") then return hades_sounds.node_sound_defaults(table) + elseif minetest.get_modpath("rp_sounds") then + return rp_sounds.node_sound_defaults(table) else return table end @@ -74,6 +76,8 @@ function sound_api.node_sound_stone_defaults(table) return fl_stone.sounds.stone(table) elseif minetest.get_modpath("hades_sounds") then return hades_sounds.node_sound_stone_defaults(table) + elseif minetest.get_modpath("rp_sounds") then + return rp_sounds.node_sound_stone_defaults(table) else return table end @@ -91,6 +95,8 @@ function sound_api.node_sound_dirt_defaults(table) return fl_topsoil.sounds.grass(table) elseif minetest.get_modpath("hades_sounds") then return hades_sounds.node_sound_dirt_defaults(table) + elseif minetest.get_modpath("rp_sounds") then + return rp_sounds.node_sound_dirt_defaults(table) else return table end @@ -116,6 +122,8 @@ function sound_api.node_sound_sand_defaults(table) return fl_stone.sounds.sand(table) elseif minetest.get_modpath("hades_sounds") then return hades_sounds.node_sound_sand_defaults(table) + elseif minetest.get_modpath("rp_sounds") then + return rp_sounds.node_sound_sand_defaults(table) else return table end @@ -151,6 +159,8 @@ function sound_api.node_sound_wood_defaults(table) return fl_trees.sounds.wood(table) elseif minetest.get_modpath("hades_sounds") then return hades_sounds.node_sound_wood_defaults(table) + elseif minetest.get_modpath("rp_sounds") then + return rp_sounds.node_sound_wood_defaults(table) else return table end @@ -167,6 +177,8 @@ function sound_api.node_sound_leaves_defaults(table) return nodes_nature.node_sound_leaves_defaults(table) elseif minetest.get_modpath("hades_sounds") then return hades_sounds.node_sound_leaves_defaults(table) + elseif minetest.get_modpath("rp_sounds") then + return rp_sounds.node_sound_leaves_defaults(table) else return table end @@ -181,6 +193,8 @@ function sound_api.node_sound_glass_defaults(table) return nodes_nature.node_sound_glass_defaults(table) elseif minetest.get_modpath("hades_sounds") then return hades_sounds.node_sound_glass_defaults(table) + elseif minetest.get_modpath("rp_sounds") then + return rp_sounds.node_sound_glass_defaults(table) else return table end @@ -225,6 +239,8 @@ function sound_api.node_sound_water_defaults(table) return nodes_nature.node_sound_water_defaults(table) elseif minetest.get_modpath("hades_sounds") then return hades_sounds.node_sound_water_defaults(table) + elseif minetest.get_modpath("rp_sounds") then + return rp_sounds.node_sound_water_defaults(table) else return table end @@ -241,6 +257,9 @@ function sound_api.node_sound_lava_defaults(table) return nodes_nature.node_sound_water_defaults(table) elseif minetest.get_modpath("hades_sounds") then return hades_sounds.node_sound_lava_defaults(table) + --s/lava/water + elseif minetest.get_modpath("rp_sounds") then + return rp_sounds.node_sound_water_defaults(table) else return table end @@ -257,6 +276,8 @@ function sound_api.node_sound_snow_defaults(table) return nodes_nature.node_sound_snow_defaults(table) elseif minetest.get_modpath("fl_topsoil") then return fl_topsoil.sounds.snow(table) + elseif minetest.get_modpath("rp_sounds") then + return rp_sounds.node_sound_snow_defaults(table) else return table end