7 Commits

8 changed files with 288 additions and 39 deletions

View File

@ -1,5 +1,22 @@
unused_args = false
allow_defined_top = true
exclude_files = {".luacheckrc"}
globals = { globals = {
"sound_api", "minetest", "mcl_sounds", "default", "ks_sounds", "minetest", "xcompat",
"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
"default", "mcl_sounds", "ks_sounds", "nodes_nature", "fl_stone", "fl_topsoil", "fl_trees", "hades_sounds", "rp_sounds",
} }

25
DEV.md
View File

@ -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: Agnostically depend
### 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
You can do this by using a custom field in your node def instead of the `sounds` key. 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` * 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. * 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 add this mod to your mod.confs depends and directly call the sound_api as follows
```lua ```lua
minetest.register_node(nodename, { 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 * input: optional table to override some or all of returned values
## Materials API
consult `/src/materials.lua` at this time

View File

@ -1,5 +1,5 @@
MIT Copyright 2021 wsor4035 MIT Copyright 2021-2024 wsor4035
Permission is hereby granted, free of charge, to any person obtaining a copy of 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 this software and associated documentation files (the "Software"), to deal in

View File

@ -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 ## Installing
* `git clone https://github.com/mt-mods/sound_api.git` clone via git or install via contentdb (soon)
* `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`
## Dev Docs ## Dev Docs

View File

@ -1,9 +1,12 @@
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"),
}
local function validate_sound(key) local function validate_sound(key)
if key and sound_api[key] then if key and xcompat.sounds[key] then
return true return true
elseif key then elseif key then
minetest.log("warning", "attempted to call invalid sound: "..key) minetest.log("warning", "attempted to call invalid sound: "..key)
@ -17,7 +20,7 @@ minetest.register_on_mods_loaded(function()
for name, def in pairs(minetest.registered_nodes) do for name, def in pairs(minetest.registered_nodes) do
if def._sound_def and validate_sound(def._sound_def.key) then if def._sound_def and validate_sound(def._sound_def.key) then
minetest.override_item(name, { 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
end end
@ -25,7 +28,7 @@ minetest.register_on_mods_loaded(function()
local old_reg_node = minetest.register_node local old_reg_node = minetest.register_node
function minetest.register_node(name, def) function minetest.register_node(name, def)
if def._sound_def and validate_sound(def._sound_def.key) then 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 end
old_reg_node(name, def) old_reg_node(name, def)

View File

@ -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 optional_depends = default, fl_stone, fl_trees, mcl_sounds, hades_sounds, ks_sounds, nodes_nature, fl_topsoil, fl_trees

242
src/materials.lua Normal file
View File

@ -0,0 +1,242 @@
local materials = {
dirt = "default:dirt",
sand = "default:sand",
gravel = "default:gravel",
copper_ingot = "default:copper_ingot",
steel_ingot = "default:steel_ingot",
gold_ingot = "default:gold_ingot",
tin_ingot = "default:tin_ingot",
mese = "default:mese",
mese_crystal = "default:mese_crystal",
mese_crystal_fragment = "default:mese_crystal_fragment",
torch = "default:torch",
diamond = "default:diamond",
clay_lump = "default:clay_lump",
water_bucket = "bucket:bucket_water",
empty_bucket = "bucket:bucket_empty",
dye_dark_grey = "dye:dark_grey",
dye_black = "dye:black",
dye_white = "dye:white",
dye_green = "dye:green",
dye_red = "dye:red",
dye_yellow = "dye:yellow",
dye_brown = "dye:brown",
dye_blue = "dye:blue",
dye_violet = "dye:violet",
dye_grey = "dye:grey",
dye_dark_green = "dye:dark_green",
dye_orange = "dye:orange",
dye_pink = "dye:pink",
silicon = "mesecons_materials:silicon",
string = "farming:string",
paper = "default:paper",
book = "default:book",
iron_lump = "default:iron_lump",
wool_grey = "wool:grey",
wool_green = "wool:green",
wool_dark_green = "wool:dark_green",
wool_brown = "wool:brown",
wool_black = "wool:black",
wool_white = "wool:white",
slab_stone = "stairs:slab_stone",
slab_wood = "stairs:slab_wood",
glass = "default:glass",
glass_block = "default:glass",
glass_bottle = "vessels:glass_bottle",
coal_lump = "default:coal_lump",
stone = "default:stone",
desert_stone = "default:desert_stone",
desert_sand = "default:desert_sand",
chest = "default:chest",
cobble = "default:cobble",
brick = "default:brick",
obsidian_glass = "default:obsidian_glass",
}
if minetest.get_modpath("moreores") then
materials.silver_ingot = "moreores:silver_ingot"
end
if minetest.get_modpath("mcl_core") then
materials = {
dirt = "mcl_core:dirt",
sand = "mcl_core:sand",
gravel = "mcl_core:gravel",
copper_ingot = "mcl_copper:copper_ingot",
steel_ingot = "mcl_core:iron_ingot",
gold_ingot = "mcl_core:gold_ingot",
tin_ingot = "mcl_core:iron_ingot",
mese = "mesecons_torch:redstoneblock",
mese_crystal = "mesecons:redstone",
mese_crystal_fragment = "mcl_core:iron_ingot",
torch = "mcl_torches:torch",
diamond = "mcl_core:diamond",
clay_lump = "default:clay_lump",
water_bucket = "mcl_buckets:bucket:bucket_water",
empty_bucket = "mcl_buckets:bucket_empty",
dye_dark_grey = "mcl_dyes:dark_grey",
dye_black = "mcl_dyes:black",
dye_white = "mcl_dyes:white",
dye_green = "mcl_dyes:green",
dye_red = "mcl_dyes:red",
dye_yellow = "mcl_dyes:yellow",
dye_brown = "mcl_dyes:brown",
dye_blue = "mcl_dyes:blue",
dye_violet = "mcl_dyes:violet",
dye_grey = "mcl_dyes:grey",
dye_dark_green = "mcl_dyes:dark_green",
dye_orange = "mcl_dyes:orange",
dye_pink = "mcl_dyes:pink",
silicon = "mcl_core:iron_ingot",
string = "mcl_mobitems:string",
paper = "mcl_core:paper",
book = "mcl_core:book",
iron_lump = "mcl_core:stone_with_iron",
wool_grey = "mcl_wool:grey",
wool_green = "mcl_wool:green",
wool_dark_green = "mcl_wool:dark_green",
wool_brown = "mcl_wool:brown",
wool_black = "mcl_wool:black",
wool_white = "mcl_wool:white",
slab_stone = "mcl_stairs:slab_stone",
slab_wood = "mcl_stairs:slab_wood",
glass = "mcl_core:glass",
glass_block = "mcl_core:glass",
glass_bottle = "mcl_core:glass_bottle",
coal_lump = "mcl_core:coal",
stone = "mcl_core:stone",
desert_stone = "mcl_core:redsandstone",
desert_sand = "mcl_core:sand",
chest = "mcl_chests:chest",
cobble = "mcl_core:cobble",
brick = "mcl_core:brick",
}
elseif minetest.get_modpath("fl_ores") and minetest.get_modpath("fl_stone") then
materials = {
dirt = "fl_topsoil:dirt",
sand = "fl_stone:sand",
gravel = "fl_topsoil:gravel",
steel_ingot = "fl_ores:iron_ingot",
gold_ingot = "fl_ores:gold_ingot",
mese = "fl_ores:iron_ingot",
mese_crystal = "fl_ores:iron_ingot",
mese_crystal_fragment = "fl_ores:iron_ingot",
torch = "fl_light_sources:torch",
diamond = "fl_ores:diamond",
clay_lump = "fl_bricks:clay_lump",
water_bucket = "fl_bucket:bucket_water",
empty_bucket = "fl_bucket:bucket",
dye_dark_grey = "fl_dyes:dark_grey_dye",
dye_black = "fl_dyes:black_dye",
dye_white = "fl_dyes:white_dye",
dye_green = "fl_dyes:green_dye",
dye_red = "fl_dyes:red_dye",
dye_yellow = "fl_dyes:yellow_dye",
dye_brown = "fl_dyes:brown_dye",
dye_blue = "fl_dyes:blue_dye",
dye_violet = "fl_dyes:violet_dye",
dye_grey = "fl_dyes:grey_dye",
dye_dark_green = "fl_dyes:dark_green_dye",
dye_orange = "fl_dyes:orange_dye",
dye_pink = "fl_dyes:pink_dye",
copper_ingot = "fl_ores:copper_ingot",
tin_ingot = "fl_ores:tin_ingot",
silver_ingot = "fl_ores:iron_ingot",
silicon = "mesecons_materials:silicon",
string = "fl_plantlife:oxeye_daisy",
paper = "basic_materials:plastic_sheet",
iron_lump = "fl_ores:iron_ore",
wool_grey = "",
wool_green = "",
wool_dark_green = "",
wool_brown = "",
wool_black = "",
wool_white = "",
slab_stone = "fl_stone:stone_slab",
slab_wood = "fl_trees:apple_plank_slab",
glass = "fl_glass:framed_glass",
glass_block = "fl_glass:framed_glass",
glass_bottle = "fl_bottles:bottle",
coal_lump = "fl_ores:coal_ore",
stone = "fl_stone:stone",
desert_stone = "fl_stone:desert_stone",
desert_sand = "fl_stone:desert_sand",
chest = "fl_storage:wood_chest",
cobble = "fl_stone:stone_rubble",
brick = "",
}
elseif minetest.get_modpath("hades_core") then
materials = {
sand = "hades_core:fertile_sand",
gravel = "hades_core:gravel",
copper_ingot = "hades_core:copper_ingot",
steel_ingot = "hades_core:steel_ingot",
gold_ingot = "hades_core:gold_ingot",
tin_ingot = "hades_core:tin_ingot",
silver_ingot = "--unknown--",
mese = "hades_core:mese",
mese_crystal = "hades_core:mese_crystal",
mese_crystal_fragment = "hades_core:mese_crystal_fragment",
torch = "hades_torches:torch",
diamond = "hades_core:diamond",
clay_lump = "hades_core:clay_lump",
clay_brick = "hades_core:clay_brick",
--[[
Since hades doesnt have buckets or water for the user,
using dirt from near water to pull the water out
]]
water_bucket = "hades_core:dirt",
empty_bucket = "hades_core:fertile_sand",
dye_dark_grey = "dye:dark_grey",
dye_black = "dye:black",
dye_white = "dye:white",
dye_green = "dye:green",
dye_red = "dye:red",
dye_yellow = "dye:yellow",
dye_brown = "dye:brown",
dye_blue = "dye:blue",
dye_violet = "dye:violet",
dye_grey = "dye:grey",
dye_dark_green = "dye:dark_green",
dye_orange = "dye:orange",
dye_pink = "dye:pink",
silicon = "hades_materials:silicon",
string = "hades_farming:string",
paper = "hades_core:paper",
book = "hades_core:book",
iron_lump = "hades_core:iron_lump",
wool_grey = "wool:grey",
wool_green = "wool:green",
wool_dark_green = "wool:dark_green",
wool_brown = "wool:brown",
wool_black = "wool:black",
wool_white = "wool:white",
slab_stone = "stairs:slab_stone",
slab_wood = "stairs:slab_wood",
glass = "hades_core:glass",
glass_block = "hades_core:glass",
glass_bottle = "vessels:glass_bottle",
obsidian_glass = "hades_core:obsidian_glass",
coal_lump = "hades_core:coal_lump",
stone = "hades_core:stone",
desert_stone = "hades_core:stone_baked",
desert_sand = "hades_core:volcanic_sand",
chest = "hades_chests:chest";
cobble = "hades_core:cobble",
brick = "hades_core:brick"
}
if minetest.get_modpath("hades_bucket") then
materials["water_bucket"] = "hades_bucket:bucket_water"
materials["empty_bucket"] = "hades_bucket:bucket_empty"
end
if minetest.get_modpath("hades_extraores") then
materials["silver_ingot"] = "hades_extraores:silver_ingot"
end
if minetest.get_modpath("hades_default") then
materials.desert_sand = "hades_default:desert_sand"
end
end
return materials