Group-based sounds?

User avatar
y.st.
Member
 
Posts: 38
Joined: Fri Mar 20, 2015 01:24
GitHub: y-st
IRC: Yst
In-game: Yst

Group-based sounds?

by y.st. » Tue Aug 25, 2015 06:52

In the Minetest API <https://github.com/minetest/minetest/blob/0.4.13/doc/lua_api.txt#L3164>, group-based sounds are mentioned, but not explained. Does anyone know how they work? How would one go about choosing the default sound for a given group? I couldn't see anything in minetest_game that looked like it was setting any default sounds, so I'm not even sure if minetest_game implements the feature. I think it might be a nice feature to use for my own game though.
 

User avatar
rubenwardy
Member
 
Posts: 4500
Joined: Tue Jun 12, 2012 18:11
GitHub: rubenwardy
IRC: rubenwardy
In-game: rubenwardy

Re: Group-based sounds?

by rubenwardy » Wed Aug 26, 2015 15:03

Puzzling.

This is the commit which added that line in the lua_api.txt file:

Lua API for playing sounds by celeron55, 24th March 2012

and there's no detection on the CPP side of "__groups" or any other string, and the minetest_game of that time doesn't use anything like __group.

Minetest Game uses variables such as default.sounds.glass etc to share sounds, that's probably the best way to do it.
 

User avatar
y.st.
Member
 
Posts: 38
Joined: Fri Mar 20, 2015 01:24
GitHub: y-st
IRC: Yst
In-game: Yst

Re: Group-based sounds?

by y.st. » Wed Aug 26, 2015 18:26

I was able to dig up a little more since then, and it seems that instead of setting a default sound name, the engine uses hard-coded sound names based on group names <https://github.com/minetest/minetest/blob/0.4.13/src/game.cpp#L3789>. I can't say this is the best way to do things, as the sounds require the "default_dig_" prefix, that file name is likely to be part of a module called default, and not every game has a default, but at least we know how to use it now. It seems strange that this method of setting sounds only applies to digging nodes. For example, the sound used for walking on nodes must always be set manually. The engine also seems to base the sound on the "main" group, so I'll need to do some experimenting and see if I can figure out what the main group means. I suspect it means the group that is currently used to dig the node, meaning that the main group may change based on the tool used.

I think __group doesn't show up in minetest_game because it is a default value. There is no need to explicitly set it. I can't seem to find the code that makes __group be the default value, but the documentation <https://github.com/minetest/minetest/blob/0.4.13/doc/lua_api.txt#L3164> says it's the default.
 


Return to Minetest Features

Who is online

Users browsing this forum: No registered users and 2 guests

cron