module scripts.lua.audio; import bindbc.lua; import raylib; import variables; import graphics.effects; import std.conv; import system.debugwriteln; import system.config; import std.string; import std.algorithm; import system.init; import graphics.playback; import std.file; import graphics.collision; import audio.sfx; extern (C) nothrow int luaL_loadMusic(lua_State* L) { try { char* musicPath = cast(char*)luaL_checkstring(L, 1); music = LoadMusicStream(musicPath); } catch (Exception e) { debugWriteln(e.msg); } return 0; } extern (C) nothrow int luaL_playMusic(lua_State* L) { if (systemSettings.soundState != false) PlayMusicStream(music); return 0; } extern (C) nothrow int luaL_stopMusic(lua_State* L) { if (systemSettings.soundState != false) StopMusicStream(music); return 0; } extern (C) nothrow int luaL_unloadMusic(lua_State* L) { UnloadMusicStream(music); music = Music(); return 0; } extern (C) nothrow int luaL_setMusicVolume(lua_State *L) { SetMusicVolume(music, luaL_checknumber(L, 1)); return 0; } extern (C) nothrow int luaL_loadSfx(lua_State *L) { try { int index = cast(int)luaL_checkinteger(L, 1); string filename = to!string(luaL_checkstring(L, 2)); loadSfx(index, filename); } catch (Exception e) { debugWriteln(e.msg); } return 0; } extern (C) nothrow int luaL_playSfx(lua_State *L) { try { playSfx(cast(int)(luaL_checkinteger(L, 1))); } catch (Exception e) { debugWriteln(e.msg); } return 0; } extern (C) nothrow int luaL_stopSfx(lua_State *L) { int index = cast(int)luaL_checkinteger(L, 1); if (systemSettings.soundState != false) StopSound(sfx[index]); return 0; } extern (C) nothrow int luaL_setSfxVolume(lua_State *L) { int index = cast(int)luaL_checkinteger(L, 1); float volumeValue = cast(float)luaL_checknumber(L, 2); SetSoundVolume(sfx[index], volumeValue); return 0; } extern (C) nothrow int luaL_unloadSfx(lua_State *L) { int index = cast(int)luaL_checkinteger(L, 1); UnloadSound(sfx[index]); return 0; }