From 13888623a5a7f6fa9f532570c1b733f0fcdf2a64 Mon Sep 17 00:00:00 2001 From: Simon Robertshaw Date: Mon, 20 Aug 2012 15:00:32 +0100 Subject: [PATCH] TPT: Error reporting in other things besides just step functions (No error reporting in graphics or part update to prevent massive spam) fixes #134 --- src/cat/LuaScriptInterface.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp index aa534f37d..a338802c9 100644 --- a/src/cat/LuaScriptInterface.cpp +++ b/src/cat/LuaScriptInterface.cpp @@ -814,7 +814,7 @@ int luacon_elementwrite(lua_State* l){ return 0; } int luacon_keyevent(int key, int modifier, int event){ - int i = 0, kpcontinue = 1; + int i = 0, kpcontinue = 1, callret; char tempkey[] = {key, 0}; if(keypress_function_count){ for(i = 0; i < keypress_function_count && kpcontinue; i++){ @@ -823,7 +823,11 @@ int luacon_keyevent(int key, int modifier, int event){ lua_pushinteger(luacon_ci->l, key); lua_pushinteger(luacon_ci->l, modifier); lua_pushinteger(luacon_ci->l, event); - lua_pcall(luacon_ci->l, 4, 1, 0); + callret = lua_pcall(luacon_ci->l, 4, 1, 0); + if (callret) + { + luacon_ci->Log(CommandInterface::LogError, luacon_geterror()); + } if(lua_isboolean(luacon_ci->l, -1)){ kpcontinue = lua_toboolean(luacon_ci->l, -1); } @@ -833,7 +837,7 @@ int luacon_keyevent(int key, int modifier, int event){ return kpcontinue; } int luacon_mouseevent(int mx, int my, int mb, int event, int mouse_wheel){ - int i = 0, mpcontinue = 1; + int i = 0, mpcontinue = 1, callret; if(mouseclick_function_count){ for(i = 0; i < mouseclick_function_count && mpcontinue; i++){ lua_rawgeti(luacon_ci->l, LUA_REGISTRYINDEX, mouseclick_functions[i]); @@ -842,7 +846,11 @@ int luacon_mouseevent(int mx, int my, int mb, int event, int mouse_wheel){ lua_pushinteger(luacon_ci->l, mb); lua_pushinteger(luacon_ci->l, event); lua_pushinteger(luacon_ci->l, mouse_wheel); - lua_pcall(luacon_ci->l, 5, 1, 0); + callret = lua_pcall(luacon_ci->l, 5, 1, 0); + if (callret) + { + luacon_ci->Log(CommandInterface::LogError, luacon_geterror()); + } if(lua_isboolean(luacon_ci->l, -1)){ mpcontinue = lua_toboolean(luacon_ci->l, -1); } @@ -874,8 +882,7 @@ int luacon_step(int mx, int my, int selectl, int selectr, int bsx, int bsy){ callret = lua_pcall(luacon_ci->l, 0, 0, 0); if (callret) { - // failed, TODO: better error reporting - luacon_ci->Log(CommandInterface::LogError, luacon_geterror());//("%s\n",luacon_geterror()); + luacon_ci->Log(CommandInterface::LogError, luacon_geterror()); } } }