aboutsummaryrefslogtreecommitdiff
path: root/src/shared/lua_api/common.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/lua_api/common.cpp')
-rw-r--r--src/shared/lua_api/common.cpp15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/shared/lua_api/common.cpp b/src/shared/lua_api/common.cpp
index 1ee4b72..9b833fe 100644
--- a/src/shared/lua_api/common.cpp
+++ b/src/shared/lua_api/common.cpp
@@ -5,6 +5,7 @@ extern "C" {
#include <lualib.h>
}
+#include <stdlib.h>
#include "common.hpp"
//Expose things to the lua state
@@ -236,6 +237,9 @@ int popvector2i(lua_State* L, long* a, long* b){
return 0;
}
+//When crashy is enabled, errors that usually get caught by errfunc crash instead
+//Useful for testing
+bool crashy = false;
//errfunc("mssg",false)
int errfunc(lua_State *L){
printf("Error function called\n");
@@ -268,9 +272,18 @@ int errfunc(lua_State *L){
printf("--------------------------\n");
lua_call(L,1,0);//error,{debug}
lua_pop(L,1);
- printf("Returning");
+ printf("Returning:");
+ printf("crashy is %d", crashy);
+ if(crashy){
+ exit(-1);
+ }
return 1;
}
void pusherrorfunc(lua_State *L){
lua_pushcfunction(L,errfunc);
}
+int make_crashy(lua_State *L){
+ crashy = true;
+ printf("Setting crashy to %d\n",crashy);
+ return 0;
+}