summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/mlua_script_loader.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2016-01-02 14:34:22 +0000
committerAlexander Lantsev <aunsane@gmail.com>2016-01-02 14:34:22 +0000
commit90cac394f9e49fb2ccc5e588dd78e093e0510c4e (patch)
treeacf914658e21f60982dd6a337dec0fa4c3d4d85a /plugins/MirLua/src/mlua_script_loader.cpp
parent7e52ce761a2b20c48da31b84a4f54fa7f00a3ee7 (diff)
MirLua: added setting c libs path via folders plugin
git-svn-id: http://svn.miranda-ng.org/main/trunk@15992 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
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