mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
parent
03ff53e16b
commit
ff73c7a5da
10 changed files with 68 additions and 54 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue