From c598987f83e50e0b678e89cd507a5a284a18b62a Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Thu, 16 Jul 2015 21:18:54 +0000 Subject: 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 --- plugins/MirLua/src/mlua_script_loader.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'plugins/MirLua/src/mlua_script_loader.cpp') 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); } -- cgit v1.2.3