diff options
author | aunsane <aunsane@gmail.com> | 2017-10-05 21:24:06 +0300 |
---|---|---|
committer | aunsane <aunsane@gmail.com> | 2017-10-05 21:24:29 +0300 |
commit | 4989d780b22b6a40866c417c16dda0ae55d46dad (patch) | |
tree | 8aa483b5a82a3dc6cf19f85912e62e51f0c2b6b6 /plugins/MirLua/src/mlua.cpp | |
parent | 07af3bc24151d8aee445da24eddbac5ac1592c03 (diff) |
MirLua: simplified print
m_json reworked Encode
Diffstat (limited to 'plugins/MirLua/src/mlua.cpp')
-rw-r--r-- | plugins/MirLua/src/mlua.cpp | 20 |
1 files changed, 5 insertions, 15 deletions
diff --git a/plugins/MirLua/src/mlua.cpp b/plugins/MirLua/src/mlua.cpp index 4dc3a2775a..d3ded45a40 100644 --- a/plugins/MirLua/src/mlua.cpp +++ b/plugins/MirLua/src/mlua.cpp @@ -38,24 +38,14 @@ static int mlua_print(lua_State *L) data.AppendFormat("%s", lua_toboolean(L, i) ? "true" : "false");
break;
case LUA_TNUMBER:
- case LUA_TSTRING:
data.AppendFormat("%s", lua_tostring(L, i));
+ case LUA_TSTRING:
+ data.AppendFormat("'%s'", lua_tostring(L, i));
break;
default:
- if (lua_getmetatable(L, 1))
- {
- if (lua_getfield(L, -1, "__tostring") == LUA_TFUNCTION)
- {
- lua_pushvalue(L, 1);
- if (luaM_pcall(L, 1, 1) == LUA_OK)
- {
- data.AppendFormat("%s", lua_tostring(L, -1));
- lua_pop(L, 2);
- break;
- }
- lua_pop(L, 2);
- }
- lua_pop(L, 1);
+ if (luaL_callmeta(L, i, "__tostring")) {
+ data.AppendFormat("[[%s]]", lua_tostring(L, i));
+ break;
}
data.AppendFormat("%s(0x%p)", luaL_typename(L, i), lua_topointer(L, i));
break;
|