fix audio.play type checks

This commit is contained in:
MihailRis 2026-04-10 12:21:11 +03:00
parent 736cdb0980
commit 6daaa4895b

View file

@ -8,7 +8,7 @@ inline const char* DEFAULT_CHANNEL = "regular";
inline int extract_channel_index(lua::State* L, int idx) {
const char* channel = DEFAULT_CHANNEL;
if (!lua::isnoneornil(L, idx)) {
if (lua::isstring(L, idx)) {
channel = lua::tostring(L, idx);
}
int index = audio::get_channel_index(channel);
@ -121,7 +121,7 @@ static int l_audio_play_stream(lua::State* L) {
return lua::pushinteger(
L,
static_cast<lua::Integer>(play_stream(
lua::tostring(L, 1),
lua::require_string(L, 1),
false,
lua::tonumber(L, 2),
lua::tonumber(L, 3),
@ -144,7 +144,7 @@ static int l_audio_play_stream_2d(lua::State* L) {
return lua::pushinteger(
L,
static_cast<lua::Integer>(play_stream(
lua::tostring(L, 1),
lua::require_string(L, 1),
true,
0.0,
0.0,
@ -170,7 +170,7 @@ static int l_audio_play_sound(lua::State* L) {
return lua::pushinteger(
L,
static_cast<lua::Integer>(play_sound(
lua::tostring(L, 1),
lua::require_string(L, 1),
false,
lua::tonumber(L, 2),
lua::tonumber(L, 3),
@ -193,7 +193,7 @@ static int l_audio_play_sound_2d(lua::State* L) {
return lua::pushinteger(
L,
static_cast<lua::Integer>(play_sound(
lua::tostring(L, 1),
lua::require_string(L, 1),
true,
0.0,
0.0,