diff --git a/components/lua/luastate.cpp b/components/lua/luastate.cpp index 3b4f5c9e2f..d8899a2634 100644 --- a/components/lua/luastate.cpp +++ b/components/lua/luastate.cpp @@ -5,6 +5,7 @@ #endif // NO_LUAJIT #include +#include #include #include @@ -385,7 +386,9 @@ namespace LuaUtil sol::function LuaState::loadInternalLib(std::string_view libName) { const auto path = packageNameToPath(libName, mLibSearchPaths); - sol::load_result res = mSol.load_file(Files::pathToUnicodeString(path), sol::load_mode::text); + std::ifstream stream(path); + std::string fileContent(std::istreambuf_iterator(stream), {}); + sol::load_result res = mSol.load(fileContent, Files::pathToUnicodeString(path), sol::load_mode::text); if (!res.valid()) throw std::runtime_error("Lua error: " + res.get()); return res;