summaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_client.cpp
diff options
context:
space:
mode:
authorRui <rui.minetest@gmail.com>2017-06-11 20:58:26 +0900
committerLoïc Blot <nerzhul@users.noreply.github.com>2017-06-11 13:58:26 +0200
commitff73c7a5da6ab8ac0bb678ebf25b83e805397029 (patch)
tree1e91e8226000250c4636bbb188330d105c85d019 /src/script/lua_api/l_client.cpp
parent03ff53e16bafe1aaa278625864c546a525d08dfc (diff)
downloadminetest-ff73c7a5da6ab8ac0bb678ebf25b83e805397029.tar.gz
minetest-ff73c7a5da6ab8ac0bb678ebf25b83e805397029.tar.bz2
minetest-ff73c7a5da6ab8ac0bb678ebf25b83e805397029.zip
Sound: Add pitch option (#5960)
* Sound: Add pitch option
Diffstat (limited to 'src/script/lua_api/l_client.cpp')
-rw-r--r--src/script/lua_api/l_client.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/script/lua_api/l_client.cpp b/src/script/lua_api/l_client.cpp
index eab7bdfae..b4dfe9174 100644
--- a/src/script/lua_api/l_client.cpp
+++ b/src/script/lua_api/l_client.cpp
@@ -227,12 +227,14 @@ int ModApiClient::l_sound_play(lua_State *L)
SimpleSoundSpec spec;
read_soundspec(L, 1, spec);
- float gain = 1.0;
+ float gain = 1.0f;
+ float pitch = 1.0f;
bool looped = false;
s32 handle;
if (lua_istable(L, 2)) {
getfloatfield(L, 2, "gain", gain);
+ getfloatfield(L, 2, "pitch", pitch);
getboolfield(L, 2, "loop", looped);
lua_getfield(L, 2, "pos");
@@ -240,13 +242,13 @@ int ModApiClient::l_sound_play(lua_State *L)
v3f pos = read_v3f(L, -1) * BS;
lua_pop(L, 1);
handle = sound->playSoundAt(
- spec.name, looped, gain * spec.gain, pos);
+ spec.name, looped, gain * spec.gain, pos, pitch);
lua_pushinteger(L, handle);
return 1;
}
}
- handle = sound->playSound(spec.name, looped, gain * spec.gain);
+ handle = sound->playSound(spec.name, looped, gain * spec.gain, 0.0f, pitch);
lua_pushinteger(L, handle);
return 1;