summaryrefslogtreecommitdiff
path: root/src/script
diff options
context:
space:
mode:
authorBrandon <brandon@bremaweb.com>2016-07-10 00:08:26 -0500
committerparamat <mat.gregory@virginmedia.com>2017-05-03 03:12:45 +0100
commitbd921a7916f0fafc493b1c4d0eeb5e2bb1d6a7c2 (patch)
tree55f92cc02fce2acc9bb041a34de3c474b894bd00 /src/script
parentf1d7a26b7c341b468f34325cec5c3d495f175a8f (diff)
downloadminetest-bd921a7916f0fafc493b1c4d0eeb5e2bb1d6a7c2.tar.gz
minetest-bd921a7916f0fafc493b1c4d0eeb5e2bb1d6a7c2.tar.bz2
minetest-bd921a7916f0fafc493b1c4d0eeb5e2bb1d6a7c2.zip
Sound API: Add fading sounds
Diffstat (limited to 'src/script')
-rw-r--r--src/script/common/c_content.cpp2
-rw-r--r--src/script/common/c_converter.h2
-rw-r--r--src/script/lua_api/l_server.cpp11
-rw-r--r--src/script/lua_api/l_server.h3
4 files changed, 18 insertions, 0 deletions
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp
index 5fe5af58d..8696ad7cb 100644
--- a/src/script/common/c_content.cpp
+++ b/src/script/common/c_content.cpp
@@ -680,6 +680,7 @@ void read_server_sound_params(lua_State *L, int index,
if(lua_istable(L, index)){
getfloatfield(L, index, "gain", params.gain);
getstringfield(L, index, "to_player", params.to_player);
+ getfloatfield(L, index, "fade", params.fade);
lua_getfield(L, index, "pos");
if(!lua_isnil(L, -1)){
v3f p = read_v3f(L, -1)*BS;
@@ -712,6 +713,7 @@ void read_soundspec(lua_State *L, int index, SimpleSoundSpec &spec)
} else if(lua_istable(L, index)){
getstringfield(L, index, "name", spec.name);
getfloatfield(L, index, "gain", spec.gain);
+ getfloatfield(L, index, "fade", spec.fade);
} else if(lua_isstring(L, index)){
spec.name = lua_tostring(L, index);
}
diff --git a/src/script/common/c_converter.h b/src/script/common/c_converter.h
index a5fbee765..b0f61a8ca 100644
--- a/src/script/common/c_converter.h
+++ b/src/script/common/c_converter.h
@@ -77,6 +77,8 @@ void setfloatfield(lua_State *L, int table,
const char *fieldname, float value);
void setboolfield(lua_State *L, int table,
const char *fieldname, bool value);
+void setstringfield(lua_State *L, int table,
+ const char *fieldname, const char *value);
v3f checkFloatPos (lua_State *L, int index);
v2f check_v2f (lua_State *L, int index);
diff --git a/src/script/lua_api/l_server.cpp b/src/script/lua_api/l_server.cpp
index 7b723d14c..ea993d7b7 100644
--- a/src/script/lua_api/l_server.cpp
+++ b/src/script/lua_api/l_server.cpp
@@ -455,6 +455,16 @@ int ModApiServer::l_sound_stop(lua_State *L)
return 0;
}
+int ModApiServer::l_sound_fade(lua_State *L)
+{
+ NO_MAP_LOCK_REQUIRED;
+ s32 handle = luaL_checkinteger(L, 1);
+ float step = luaL_checknumber(L, 2);
+ float gain = luaL_checknumber(L, 3);
+ getServer(L)->fadeSound(handle, step, gain);
+ return 0;
+}
+
// is_singleplayer()
int ModApiServer::l_is_singleplayer(lua_State *L)
{
@@ -518,6 +528,7 @@ void ModApiServer::Initialize(lua_State *L, int top)
API_FCT(show_formspec);
API_FCT(sound_play);
API_FCT(sound_stop);
+ API_FCT(sound_fade);
API_FCT(get_player_information);
API_FCT(get_player_privs);
diff --git a/src/script/lua_api/l_server.h b/src/script/lua_api/l_server.h
index 3a4a917c0..251a0ce89 100644
--- a/src/script/lua_api/l_server.h
+++ b/src/script/lua_api/l_server.h
@@ -68,6 +68,9 @@ private:
// sound_stop(handle)
static int l_sound_stop(lua_State *L);
+ // sound_fade(handle, step, gain)
+ static int l_sound_fade(lua_State *L);
+
// get_player_privs(name, text)
static int l_get_player_privs(lua_State *L);