I propose a key/value table with a table of sounds as value and some functions.
The table could look like this
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
registered_sounds = {
{"wood_sounds",
{
footstep = <SimpleSoundSpec>,
dig = <SimpleSoundSpec>,
dug = <SimpleSoundSpec>,
place = <SimpleSoundSpec>,
place_failed = <SimpleSoundSpec>,
}
},
{"gravel_sounds",
{
footstep = <SimpleSoundSpec>,
dig = <SimpleSoundSpec>,
dug = <SimpleSoundSpec>,
place = <SimpleSoundSpec>,
place_failed = <SimpleSoundSpec>,
}
},
{"stone_sounds",
{
footstep = <SimpleSoundSpec>,
dig = <SimpleSoundSpec>,
dug = <SimpleSoundSpec>,
place = <SimpleSoundSpec>,
place_failed = <SimpleSoundSpec>,
}
}
}
Sounds will be added with sounds.register(name, def), it can be overwritten with sounds.overwrite(name, def) and probably a sound.is_registered(name) function to check if a sound is already registered. I think a delete function is not necessary because once a sound is registered it is used somewhere and deleting a registered sound only causes errors.
using a sound could look like this
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
- Code: Select all
minetest.register_node("dirt:dirt", {
description = S("Dirt"),
tiles = {"default_dirt.png"},
groups = {crumbly = 3, soil = 1},
sounds = sounds.get("dirt_sounds"),
})
What kinds of sounds are in MTG?
- Damage sounds are hard coded, so they are out
- Node sounds like footsteps and dig/dug
- Tool sounds (break)
- Any more?
What kind of other sounds could be in a Minetest game?
- Mob sounds
- Environment sounds
- GUI effects (e.g. play sound when change wield item)
- Player sounds (panting, hunger)
All this could be handled by this API. Mods are able to overwrite sounds, use already existing sounds and so on
What do you think?