summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/mlua.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.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.cpp')
-rw-r--r--plugins/MirLua/src/mlua.cpp24
1 files changed, 18 insertions, 6 deletions
diff --git a/plugins/MirLua/src/mlua.cpp b/plugins/MirLua/src/mlua.cpp
index 81dbc6f612..50ea5070f8 100644
--- a/plugins/MirLua/src/mlua.cpp
+++ b/plugins/MirLua/src/mlua.cpp
@@ -17,6 +17,23 @@ CMLua::~CMLua()
Unload();
}
+void CMLua::SetPaths()
+{
+ TCHAR path[MAX_PATH];
+
+ lua_getglobal(L, "package");
+
+ FoldersGetCustomPathT(g_hScriptsFolder, path, _countof(path), VARST(MIRLUA_CPATHT));
+ lua_pushfstring(L, "%s\\?.dll", ptrA(mir_utf8encodeT(path)));
+ lua_setfield(L, -2, "cpath");
+
+ FoldersGetCustomPathT(g_hScriptsFolder, path, _countof(path), VARST(MIRLUA_PATHT));
+ lua_pushfstring(L, "%s\\?.lua", ptrA(mir_utf8encodeT(path)));
+ lua_setfield(L, -2, "path");
+
+ lua_pop(L, 1);
+}
+
void CMLua::Load()
{
CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)"Loading lua engine");
@@ -24,12 +41,7 @@ void CMLua::Load()
CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)"Loading std modules");
luaL_openlibs(L);
- lua_getglobal(L, "package");
- lua_pushliteral(L, "");
- lua_setfield(L, -2, "path");
- lua_pushliteral(L, "");
- lua_setfield(L, -2, "cpath");
- lua_pop(L, 1);
+ SetPaths();
lua_pushcclosure(L, luaM_print, 0);
lua_setglobal(L, "print");