summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/mlua_script_loader.cpp
diff options
context:
space:
mode:
authorAlexander Lantsev <aunsane@gmail.com>2015-07-16 21:18:54 +0000
committerAlexander Lantsev <aunsane@gmail.com>2015-07-16 21:18:54 +0000
commitc598987f83e50e0b678e89cd507a5a284a18b62a (patch)
tree18cc9e86afb6df9026aa1034cdd14eb9ec42186f /plugins/MirLua/src/mlua_script_loader.cpp
parentcacafe063ff2742077cdc42c2946c6a4ad9ad132 (diff)
MirLua:
- lua_pushliteral for literals - added m_protocol module - version bump git-svn-id: http://svn.miranda-ng.org/main/trunk@14580 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/mlua_script_loader.cpp')
-rw-r--r--plugins/MirLua/src/mlua_script_loader.cpp17
1 files changed, 16 insertions, 1 deletions
diff --git a/plugins/MirLua/src/mlua_script_loader.cpp b/plugins/MirLua/src/mlua_script_loader.cpp
index 7150ebdc48..3a25345c93 100644
--- a/plugins/MirLua/src/mlua_script_loader.cpp
+++ b/plugins/MirLua/src/mlua_script_loader.cpp
@@ -21,7 +21,13 @@ void CLuaScriptLoader::RegisterScriptsFolder(const char *path)
void CLuaScriptLoader::LoadScript(const TCHAR *path)
{
- if (luaL_dofile(L, T2Utf(path)))
+ if (luaL_loadfile(L, T2Utf(path)))
+ {
+ CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)lua_tostring(L, -1));
+ return;
+ }
+
+ if (lua_pcall(L, 0, 1, 0))
{
CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)lua_tostring(L, -1));
return;
@@ -30,6 +36,14 @@ void CLuaScriptLoader::LoadScript(const TCHAR *path)
TCHAR buf[4096];
mir_sntprintf(buf, _T("%s:OK"), path);
CallService(MS_NETLIB_LOGW, (WPARAM)hNetlib, (LPARAM)buf);
+
+ if (lua_istable(L, -1))
+ {
+ lua_pushliteral(L, "Load");
+ lua_gettable(L, -2);
+ if (lua_isfunction(L, -1) && lua_pcall(L, 0, 0, 0))
+ CallService(MS_NETLIB_LOG, (WPARAM)hNetlib, (LPARAM)lua_tostring(L, -1));
+ }
}
void CLuaScriptLoader::LoadScripts(const TCHAR *scriptDir)
@@ -77,6 +91,7 @@ void CLuaScriptLoader::UnloadScript(const TCHAR *path)
lua_pushnil(L);
lua_setfield(L, -2, moduleName);
lua_pop(L, 1);
+
lua_pushnil(L);
lua_setglobal(L, moduleName);
}