From ed57962bbd30116baf2faddf06b0ccd06b892d9b Mon Sep 17 00:00:00 2001 From: wsor4035 <24964441+wsor4035@users.noreply.github.com> Date: Sun, 25 Feb 2024 00:10:30 -0500 Subject: [PATCH] convert mod from sound api to xcompat --- .luacheckrc | 25 ++++++++++++++++++++--- DEV.md | 25 ++++++++--------------- README.md | 20 ++++++++---------- init.lua | 16 ++++++++++----- mod.conf | 2 +- sound_api_core/init.lua => src/sounds.lua | 0 6 files changed, 50 insertions(+), 38 deletions(-) rename sound_api_core/init.lua => src/sounds.lua (100%) diff --git a/.luacheckrc b/.luacheckrc index b0e119f..332f00a 100644 --- a/.luacheckrc +++ b/.luacheckrc @@ -1,5 +1,24 @@ +unused_args = false +allow_defined_top = true + +exclude_files = {".luacheckrc"} + globals = { - "sound_api", "minetest", "mcl_sounds", "default", "ks_sounds", - "nodes_nature", "fl_stone", "fl_topsoil", "fl_trees", - "hades_sounds", "rp_sounds", + "minetest", "sound_api", "xcompat", "default", + "mcl_sounds", "ks_sounds", "nodes_nature", "fl_stone", + "fl_topsoil", "fl_trees", "hades_sounds", "rp_sounds", +} + +read_globals = { + string = {fields = {"split"}}, + table = {fields = {"copy", "getn"}}, + + --luac + "math", "table", + + -- Builtin + "vector", "ItemStack", "dump", "DIR_DELIM", "VoxelArea", "Settings", "PcgRandom", "VoxelManip", "PseudoRandom", + + --mod produced + "fl_dyes", "fl_hand", "fl_tools", "mobkit", "fl_tnt", "i3", } \ No newline at end of file diff --git a/DEV.md b/DEV.md index 10b3b19..1fa2412 100644 --- a/DEV.md +++ b/DEV.md @@ -1,20 +1,8 @@ -# Sound API +# Xcompat dev docs -This mod is a wrapper for [sound api library](https://github.com/mt-mods/sound_api_core/). +## Sound API -## Usage of the sound api - -### Option 1: embed - -You can insert the [sound api library](https://github.com/mt-mods/sound_api_core/) directly into your mod as a submodule and use the following to load it. - -```lua -local sound_api = dofile(modpath .. "/sound_api_core/init.lua") -``` - -additionally the author recommends that you use dependabot(github) or similar to help you keep the submodule up to date. - -### Option 2: Agnostically depend +### Option 1: Agnostically depend You can do this by using a custom field in your node def instead of the `sounds` key. @@ -34,17 +22,20 @@ where: * key: string name of the field from the sound api you want to use, for example `node_sound_stone_defaults` * input: table input of fields you want passed to the key field, used to override specific sounds. -### Option 3: Hard depend +### Option 2: Hard depend add this mod to your mod.confs depends and directly call the sound_api as follows ```lua minetest.register_node(nodename, { ... - sounds = sound_api.node_sound_stone_defaults(input) + sounds = xcompat.sounds.node_sound_stone_defaults(input) ... }) ``` * input: optional table to override some or all of returned values +## Materials API + +consult `/src/materials.lua` at this time \ No newline at end of file diff --git a/README.md b/README.md index 735572a..c079f4b 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,14 @@ -# Sound API +# xcompat + +a mod that aims to facilitate other mods to be game agnostic by handling sounds and crafting + +thanks to: +* MisterE, OgelGames, and Blockhead for naming advice/suggestion +* luk3yx, Blockhead, Buckaroo for bouncing ideas on the concept of this mod -mod that enables sound to be game agnostic ## Installing -* `git clone https://github.com/mt-mods/sound_api.git` -* `cd sound_api` -* `git submodule init` -* `git submodule update` - -to update please use the following commands starting inside the mod directory - -* `git pull` -* `git submodule sync` -* `git submodule update` +clone via git or install via contentdb (soon) ## Dev Docs diff --git a/init.lua b/init.lua index ec392e2..ea3483e 100644 --- a/init.lua +++ b/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) diff --git a/mod.conf b/mod.conf index 9ae1ebe..3ff63d9 100644 --- a/mod.conf +++ b/mod.conf @@ -1,2 +1,2 @@ -name = sound_api +name = xcompat optional_depends = default, fl_stone, fl_trees, mcl_sounds, hades_sounds, ks_sounds, nodes_nature, fl_topsoil, fl_trees \ No newline at end of file diff --git a/sound_api_core/init.lua b/src/sounds.lua similarity index 100% rename from sound_api_core/init.lua rename to src/sounds.lua