mirror of
https://github.com/mt-mods/xcompat.git
synced 2024-12-22 17:10:18 +01:00
convert mod from sound api to xcompat
This commit is contained in:
parent
fe6ea96fa0
commit
ed57962bbd
25
.luacheckrc
25
.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",
|
||||
}
|
25
DEV.md
25
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
|
20
README.md
20
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
|
||||
|
||||
|
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)
|
||||
|
2
mod.conf
2
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
|
Loading…
Reference in New Issue
Block a user