summaryrefslogtreecommitdiff
path: root/src/cat/LuaScriptInterface.cpp
diff options
context:
space:
mode:
authorSimon Robertshaw <simon@hardwired.org.uk>2012-08-20 14:00:32 (GMT)
committer Simon Robertshaw <simon@hardwired.org.uk>2012-08-20 14:00:32 (GMT)
commit13888623a5a7f6fa9f532570c1b733f0fcdf2a64 (patch)
treeac3bcdd502d52050ea2a8a96685ec2ffd8524e57 /src/cat/LuaScriptInterface.cpp
parent9c599a7b9f4e5d99e8b0e32bf2fdc6c4177fc09d (diff)
downloadpowder-13888623a5a7f6fa9f532570c1b733f0fcdf2a64.zip
powder-13888623a5a7f6fa9f532570c1b733f0fcdf2a64.tar.gz
TPT: Error reporting in other things besides just step functions (No error reporting in graphics or part update to prevent massive spam) fixes #134
Diffstat (limited to 'src/cat/LuaScriptInterface.cpp')
-rw-r--r--src/cat/LuaScriptInterface.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/cat/LuaScriptInterface.cpp b/src/cat/LuaScriptInterface.cpp
index aa534f3..a338802 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());
}
}
}