summaryrefslogtreecommitdiff
path: root/plugins/MirLua/src/environment.cpp
diff options
context:
space:
mode:
authoraunsane <aunsane@gmail.com>2018-07-29 22:59:30 +0300
committeraunsane <aunsane@gmail.com>2018-07-29 23:00:42 +0300
commitd11ddc8ef4b7f55c53abb735bca00e4192533579 (patch)
tree97f3aa2770fc4a10a024b505ed845d954aea4e97 /plugins/MirLua/src/environment.cpp
parentc085ec9744d1012627970e8590939ce661042380 (diff)
MirLua:
- added script table headers - added some logic functions to variables parser
Diffstat (limited to 'plugins/MirLua/src/environment.cpp')
-rw-r--r--plugins/MirLua/src/environment.cpp21
1 files changed, 8 insertions, 13 deletions
diff --git a/plugins/MirLua/src/environment.cpp b/plugins/MirLua/src/environment.cpp
index 517cff243b..24dea9ec58 100644
--- a/plugins/MirLua/src/environment.cpp
+++ b/plugins/MirLua/src/environment.cpp
@@ -154,27 +154,22 @@ wchar_t* CMLuaEnvironment::Error()
return error;
}
-wchar_t* CMLuaEnvironment::Call()
+int CMLuaEnvironment::Call()
{
CreateEnvironmentTable();
- luaM_pcall(L, 0, 1);
-
- wchar_t *result = mir_utf8decodeW(lua_tostring(L, -1));
- lua_pop(L, 1);
-
- return result;
+ return lua_pcall(L, 0, 1, 0);
}
-wchar_t* CMLuaEnvironment::Eval(const wchar_t *script)
+int CMLuaEnvironment::Eval(const wchar_t *script)
{
- if (luaL_loadstring(L, T2Utf(script)))
- return Error();
+ if (int res = luaL_loadstring(L, T2Utf(script)))
+ return res;
return Call();
}
-wchar_t* CMLuaEnvironment::Exec(const wchar_t *path)
+int CMLuaEnvironment::Exec(const wchar_t *path)
{
- if (luaL_loadfile(L, T2Utf(path)))
- return Error();
+ if (int res = luaL_loadfile(L, T2Utf(path)))
+ return res;
return Call();
}