summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/mlua_script_loader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/MirLua/src/mlua_script_loader.cpp')
-rw-r--r--plugins/MirLua/src/mlua_script_loader.cpp27
1 files changed, 5 insertions, 22 deletions
diff --git a/plugins/MirLua/src/mlua_script_loader.cpp b/plugins/MirLua/src/mlua_script_loader.cpp
index b95b907c8a..b374007dce 100644
--- a/plugins/MirLua/src/mlua_script_loader.cpp
+++ b/plugins/MirLua/src/mlua_script_loader.cpp
@@ -4,20 +4,6 @@ CLuaScriptLoader::CLuaScriptLoader(lua_State *L) : L(L)
{
}
-void CLuaScriptLoader::RegisterScriptsFolder(const char *path)
-{
- lua_getglobal(L, "package");
- lua_getfield(L, -1, "path");
- const char *oldPath = luaL_checkstring(L, -1);
- lua_pop(L, 1);
- if (!mir_strlen(oldPath))
- lua_pushfstring(L, "%s\\?.lua", path);
- else
- lua_pushfstring(L, "%s;%s\\?.lua", oldPath, path);
- lua_setfield(L, -2, "path");
- lua_pop(L, 1);
-}
-
void CLuaScriptLoader::LoadScript(const TCHAR *scriptDir, const TCHAR *file)
{
TCHAR fullPath[MAX_PATH], path[MAX_PATH];
@@ -43,14 +29,15 @@ void CLuaScriptLoader::LoadScript(const TCHAR *scriptDir, const TCHAR *file)
}
}
-void CLuaScriptLoader::LoadScripts(const TCHAR *scriptDir)
+void CLuaScriptLoader::LoadScripts()
{
+ TCHAR scriptDir[MAX_PATH];
+ FoldersGetCustomPathT(g_hScriptsFolder, scriptDir, _countof(scriptDir), VARST(MIRLUA_PATHT));
+
TCHAR buf[4096];
mir_sntprintf(buf, _T("Loading scripts from %s"), scriptDir);
CallService(MS_NETLIB_LOGW, (WPARAM)hNetlib, (LPARAM)buf);
- RegisterScriptsFolder(ptrA(mir_utf8encodeT(scriptDir)));
-
TCHAR searchMask[MAX_PATH];
mir_sntprintf(searchMask, _T("%s\\%s"), scriptDir, _T("*.lua"));
@@ -70,9 +57,5 @@ void CLuaScriptLoader::LoadScripts(const TCHAR *scriptDir)
void CLuaScriptLoader::Load(lua_State *L)
{
- TCHAR scriptDir[MAX_PATH];
- CLuaScriptLoader loader(L);
-
- FoldersGetCustomPathT(g_hCommonScriptFolder, scriptDir, _countof(scriptDir), VARST(COMMON_SCRIPTS_PATHT));
- loader.LoadScripts(scriptDir);
+ CLuaScriptLoader(L).LoadScripts();
} \ No newline at end of file