diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-06-10 13:43:07 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-06-10 13:43:07 +0000 |
commit | 22ecdc28ebf053a6b335b802949f4f774af97d26 (patch) | |
tree | 980abced379dcc5a3c0021eac4ccdd20358387bc /plugins/MirLua/src/mlua.cpp | |
parent | 61eb66b5f8be46f1e5fe148aefb0364e3ceb9d59 (diff) |
MirLua:
- removed unwanted paths to script searching
- fixed crash on event hook/service call
- code cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@14103 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/mlua.cpp')
-rw-r--r-- | plugins/MirLua/src/mlua.cpp | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/plugins/MirLua/src/mlua.cpp b/plugins/MirLua/src/mlua.cpp index fc73ee3496..b6d3895940 100644 --- a/plugins/MirLua/src/mlua.cpp +++ b/plugins/MirLua/src/mlua.cpp @@ -5,7 +5,15 @@ CMLua::CMLua() L = luaL_newstate();
luaL_openlibs(L);
- luaopen_m(L);
+ lua_getglobal(L, "package");
+ lua_pushstring(L, "");
+ lua_setfield(L, -2, "path");
+ lua_pushstring(L, "");
+ lua_setfield(L, -2, "cpath");
+ lua_pop(L, 1);
+
+ luaL_newlib(L, coreLib);
+ lua_setglobal(L, "M");
Preload(M_ICONSLIBNAME, luaopen_m_icons);
Preload(M_MENUSLIBNAME, luaopen_m_menus);
@@ -16,9 +24,20 @@ CMLua::~CMLua() lua_close(L);
}
+void CMLua::AddPath(const char *path)
+{
+ lua_getglobal(L, "package");
+ lua_getfield(L, -1, "path");
+ const char *oldPath = luaL_checkstring(L, -1);
+ lua_pop(L, 1);
+ lua_pushfstring(L, "%s;%s\\?.lua", oldPath, path);
+ lua_setfield(L, -2, "path");
+ lua_pop(L, 1);
+}
+
void CMLua::Load(const char *path)
{
- if (luaL_dofile(L, path))
+ if (luaL_dofile(L, path));
printf("%s\n", lua_tostring(L, -1));
}
|