From b3e393e162df2b7e848638489c4cb473ce65ba70 Mon Sep 17 00:00:00 2001 From: jacob1 Date: Wed, 8 Aug 2012 14:11:24 -0400 Subject: [PATCH] Error reporting in other things besides just step functions --- src/luaconsole.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/src/luaconsole.c b/src/luaconsole.c index 13cdc3b1d..02b851499 100644 --- a/src/luaconsole.c +++ b/src/luaconsole.c @@ -691,7 +691,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++){ @@ -700,7 +700,11 @@ int luacon_keyevent(int key, int modifier, int event){ lua_pushinteger(l, key); lua_pushinteger(l, modifier); lua_pushinteger(l, event); - lua_pcall(l, 4, 1, 0); + callret = lua_pcall(l, 4, 1, 0); + if (callret) + { + printf("In key event: %s\n",luacon_geterror()); + } if(lua_isboolean(l, -1)){ kpcontinue = lua_toboolean(l, -1); } @@ -710,7 +714,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(l, LUA_REGISTRYINDEX, mouseclick_functions[i]); @@ -719,7 +723,11 @@ int luacon_mouseevent(int mx, int my, int mb, int event, int mouse_wheel){ lua_pushinteger(l, mb); lua_pushinteger(l, event); lua_pushinteger(l, mouse_wheel); - lua_pcall(l, 5, 1, 0); + callret = lua_pcall(l, 5, 1, 0); + if (callret) + { + printf("In mouse event: %s\n",luacon_geterror()); + } if(lua_isboolean(l, -1)){ mpcontinue = lua_toboolean(l, -1); } @@ -779,7 +787,7 @@ void lua_hook(lua_State *L, lua_Debug *ar) } int luacon_part_update(int t, int i, int x, int y, int surround_space, int nt) { - int retval = 0; + int retval = 0, callret; if(lua_el_func[t]){ lua_rawgeti(l, LUA_REGISTRYINDEX, lua_el_func[t]); lua_pushinteger(l, i); @@ -787,7 +795,11 @@ int luacon_part_update(int t, int i, int x, int y, int surround_space, int nt) lua_pushinteger(l, y); lua_pushinteger(l, surround_space); lua_pushinteger(l, nt); - lua_pcall(l, 5, 1, 0); + callret = lua_pcall(l, 5, 1, 0); + if (callret) + { + printf("In particle update: %s\n",luacon_geterror()); + } if(lua_isboolean(l, -1)){ retval = lua_toboolean(l, -1); } @@ -797,13 +809,17 @@ int luacon_part_update(int t, int i, int x, int y, int surround_space, int nt) } int luacon_graphics_update(int t, int i, int *pixel_mode, int *cola, int *colr, int *colg, int *colb, int *firea, int *firer, int *fireg, int *fireb) { - int cache = 0; + int cache = 0, callret; lua_rawgeti(l, LUA_REGISTRYINDEX, lua_gr_func[t]); lua_pushinteger(l, i); lua_pushinteger(l, *colr); lua_pushinteger(l, *colg); lua_pushinteger(l, *colb); - lua_pcall(l, 4, 10, 0); + callret = lua_pcall(l, 4, 10, 0); + if (callret) + { + printf("In graphics function: %s\n",luacon_geterror()); + } cache = luaL_optint(l, -10, 0); *pixel_mode = luaL_optint(l, -9, *pixel_mode);