summaryrefslogtreecommitdiff
path: root/library/LuaWrapper.cpp
diff options
context:
space:
mode:
authorAlexander Gavrilov2012-04-05 11:59:39 +0400
committerAlexander Gavrilov2012-04-05 11:59:39 +0400
commit3afed43cdb435c788964d983a358d97ee291c2fc (patch)
tree231d57551e1d9ff3ef8dedf7d29a265e23adf6ec /library/LuaWrapper.cpp
parentd1b27418a6a39aa15d51465e61975c5230dcc9d6 (diff)
downloaddfhack-3afed43cdb435c788964d983a358d97ee291c2fc.tar.gz
dfhack-3afed43cdb435c788964d983a358d97ee291c2fc.tar.bz2
dfhack-3afed43cdb435c788964d983a358d97ee291c2fc.tar.xz
Experimental: try wrapping a dfhack api function.
Diffstat (limited to 'library/LuaWrapper.cpp')
-rw-r--r--library/LuaWrapper.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/library/LuaWrapper.cpp b/library/LuaWrapper.cpp
index 818e6b9e..2f3958ef 100644
--- a/library/LuaWrapper.cpp
+++ b/library/LuaWrapper.cpp
@@ -53,7 +53,10 @@ static luaL_Reg no_functions[] = { { NULL, NULL } };
*/
void LuaWrapper::field_error(lua_State *state, int index, const char *err, const char *mode)
{
- lua_getfield(state, UPVAL_METATABLE, "__metatable");
+ if (lua_islightuserdata(state, UPVAL_METATABLE))
+ lua_pushstring(state, "(global)");
+ else
+ lua_getfield(state, UPVAL_METATABLE, "__metatable");
const char *cname = lua_tostring(state, -1);
const char *fname = index ? lua_tostring(state, index) : "*";
luaL_error(state, "Cannot %s field %s.%s: %s.",