From 1268bd21972708c43386d54432f72787e2c3700b Mon Sep 17 00:00:00 2001 From: MCUmbrella Date: Mon, 4 Dec 2023 15:02:42 +0800 Subject: [PATCH] bugfix --- src/engine/LuaRuntime.cpp | 8 ++++++-- the_engine/data/lua/main.lua | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/engine/LuaRuntime.cpp b/src/engine/LuaRuntime.cpp index 085e615..5ff4339 100644 --- a/src/engine/LuaRuntime.cpp +++ b/src/engine/LuaRuntime.cpp @@ -249,7 +249,9 @@ void LuaRuntime::init() UserdataMetatable() .addFunction("getName", &Sound::getName) .addFunction("getPath", &Sound::getPath) - .addFunction("reassign", &Sound::reassign) + .addStaticFunction("reassign", [](Sound* instance, const string& path){ + return instance->reassign(cfg.userDataPath + "/assets/sounds/" + path); + }) .addFunction("play", &Sound::play) ); @@ -258,7 +260,9 @@ void LuaRuntime::init() UserdataMetatable() .addFunction("getName", &Music::getName) .addFunction("getPath", &Music::getPath) - .addFunction("reassign", &Music::reassign) + .addStaticFunction("reassign", [](Music* instance, const string& path){ + return instance->reassign(cfg.userDataPath + "/assets/sounds/" + path); + }) .addFunction("isCurrent", &Music::isCurrent) .addFunction("play", &Music::play) .addStaticFunction("pause", &Music::pause) diff --git a/the_engine/data/lua/main.lua b/the_engine/data/lua/main.lua index d5fd309..f4fd6d0 100644 --- a/the_engine/data/lua/main.lua +++ b/the_engine/data/lua/main.lua @@ -52,4 +52,4 @@ end function cleanup() RenderManager.unloadTexture(CURSOR_TEXTURE) Runtime.log("Placeholder level ended") -end +end