diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2016-02-17 11:31:59 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2016-02-17 11:31:59 +0000 |
commit | 2c7da3b79ebbd1833d1edfdef52d14c2ef2547eb (patch) | |
tree | 15beb4e894b43b7e0a9d5912e01dbdc0fd663d0e /plugins/MirLua/src/mlua_script.cpp | |
parent | df1277bc854e0db5424623890be9a3d74750a03f (diff) |
MirLua:
- minor MT fixes
- enabled chat module
- project cleanup
git-svn-id: http://svn.miranda-ng.org/main/trunk@16289 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/mlua_script.cpp')
-rw-r--r-- | plugins/MirLua/src/mlua_script.cpp | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/plugins/MirLua/src/mlua_script.cpp b/plugins/MirLua/src/mlua_script.cpp index 6a51046a94..f9fb1ac6f3 100644 --- a/plugins/MirLua/src/mlua_script.cpp +++ b/plugins/MirLua/src/mlua_script.cpp @@ -26,35 +26,32 @@ CMLuaScript::~CMLuaScript() mir_free(moduleName);
}
-/*const int CMLuaScript::GetId() const
+bool CMLuaScript::GetScriptEnviroment(lua_State *L, int n)
{
- return id;
-}*/
-
-CMLuaScript* CMLuaScript::GetScriptFromEnviroment(lua_State *L, int n)
-{
- CMLuaScript *script = NULL;
-
- int top = lua_gettop(L);
-
lua_Debug ar; if (lua_getstack(L, 1, &ar) == 0 || lua_getinfo(L, "f", &ar) == 0 || lua_iscfunction(L, -1)) { - top = lua_gettop(L); lua_pop(L, 1); - return script;
+ return false;
}
const char *env = lua_getupvalue(L, n, 1); if (!env || mir_strcmp(env, "_ENV") != 0) { - top = lua_gettop(L); lua_pop(L, 1); - return script; - } + return false; + }
+
+ return true;
+}
+
+CMLuaScript* CMLuaScript::GetScriptFromEnviroment(lua_State *L, int n)
+{
+ if (!GetScriptEnviroment(L, n)) + return NULL; lua_getfield(L, -1, SCRIPT);
- script = (CMLuaScript*)lua_touserdata(L, -1);
+ CMLuaScript *script = (CMLuaScript*)lua_touserdata(L, -1);
lua_pop(L, 3);
return script;
@@ -171,8 +168,8 @@ void CMLuaScript::Unload() lua_setfield(L, -2, moduleName);
lua_pop(L, 1);
- lua_pushnil(L);
- lua_setglobal(L, moduleName);
+ //lua_pushnil(L);
+ //lua_setglobal(L, moduleName);
KillModuleIcons(id);
KillModuleSounds(id);
|