| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- 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;
- }
|