diff options
author | ShadowNinja <shadowninja@minetest.net> | 2013-11-05 12:06:15 -0500 |
---|---|---|
committer | ShadowNinja <shadowninja@minetest.net> | 2013-11-15 14:13:31 -0500 |
commit | 371b39a09a0bf248d674fae718f5ff369e895b66 (patch) | |
tree | da8bb27e27a9c89eac895d211721de11a3781533 /src/script/common/c_content.cpp | |
parent | 3f519eb72922607329e1e6a48768d84d1f443efc (diff) | |
download | minetest-371b39a09a0bf248d674fae718f5ff369e895b66.tar.gz minetest-371b39a09a0bf248d674fae718f5ff369e895b66.tar.bz2 minetest-371b39a09a0bf248d674fae718f5ff369e895b66.zip |
Pass a errfunc to lua_pcall to get a traceback
Diffstat (limited to 'src/script/common/c_content.cpp')
-rw-r--r-- | src/script/common/c_content.cpp | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/script/common/c_content.cpp b/src/script/common/c_content.cpp index a035b32a2..2ad4c9565 100644 --- a/src/script/common/c_content.cpp +++ b/src/script/common/c_content.cpp @@ -871,6 +871,8 @@ void read_groups(lua_State *L, int index, /******************************************************************************/ void push_items(lua_State *L, const std::vector<ItemStack> &items) { + lua_pushcfunction(L, script_error_handler); + int errorhandler = lua_gettop(L); // Get the table insert function lua_getglobal(L, "table"); lua_getfield(L, -1, "insert"); @@ -883,11 +885,12 @@ void push_items(lua_State *L, const std::vector<ItemStack> &items) lua_pushvalue(L, table_insert); lua_pushvalue(L, table); LuaItemStack::create(L, item); - if(lua_pcall(L, 2, 0, 0)) - script_error(L, "error: %s", lua_tostring(L, -1)); + if(lua_pcall(L, 2, 0, errorhandler)) + script_error(L); } - lua_remove(L, -2); // Remove table lua_remove(L, -2); // Remove insert + lua_remove(L, -2); // Remove table + lua_remove(L, -2); // Remove error handler } /******************************************************************************/ |