aboutsummaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_base.h
diff options
context:
space:
mode:
authorkwolekr <kwolekr@minetest.net>2015-08-11 22:27:54 -0400
committerkwolekr <kwolekr@minetest.net>2015-08-12 23:56:12 -0400
commit2b04ab874d75711bc021a0cd8dc7fca68f4e6929 (patch)
tree04c1e9ad914c8c744cfd1055e2a8f6620d924c8b /src/script/cpp_api/s_base.h
parent738fbc66d096575bb9a1694056ce2d627a70c03d (diff)
downloadminetest-2b04ab874d75711bc021a0cd8dc7fca68f4e6929.tar.gz
minetest-2b04ab874d75711bc021a0cd8dc7fca68f4e6929.tar.bz2
minetest-2b04ab874d75711bc021a0cd8dc7fca68f4e6929.zip
SAPI: Track last executed mod and include in error messages
Diffstat (limited to 'src/script/cpp_api/s_base.h')
-rw-r--r--src/script/cpp_api/s_base.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/script/cpp_api/s_base.h b/src/script/cpp_api/s_base.h
index 0c2dfafd1..d653b5bac 100644
--- a/src/script/cpp_api/s_base.h
+++ b/src/script/cpp_api/s_base.h
@@ -34,6 +34,7 @@ extern "C" {
#include "common/c_internal.h"
#define SCRIPTAPI_LOCK_DEBUG
+#define SCRIPTAPI_DEBUG
#define SCRIPT_MOD_NAME_FIELD "current_mod_name"
// MUST be an invalid mod name so that mods can't
@@ -47,6 +48,12 @@ extern "C" {
} \
} while (0)
+#define runCallbacks(nargs, mode) \
+ runCallbacksRaw((nargs), (mode), __FUNCTION__)
+
+#define setOriginFromTable(index) \
+ setOriginFromTableRaw(index, __FUNCTION__)
+
class Server;
class Environment;
class GUIEngine;
@@ -61,12 +68,19 @@ public:
std::string *error=NULL);
bool loadScript(const std::string &script_path, std::string *error=NULL);
+ void runCallbacksRaw(int nargs,
+ RunCallbacksMode mode, const char *fxn);
+
/* object */
void addObjectReference(ServerActiveObject *cobj);
void removeObjectReference(ServerActiveObject *cobj);
Server* getServer() { return m_server; }
+ std::string getOrigin() { return m_last_run_mod; }
+ void setOriginDirect(const char *origin);
+ void setOriginFromTableRaw(int index, const char *fxn);
+
protected:
friend class LuaABM;
friend class InvRef;
@@ -95,6 +109,7 @@ protected:
void objectrefGet(lua_State *L, u16 id);
JMutex m_luastackmutex;
+ std::string m_last_run_mod;
// Stack index of Lua error handler
int m_errorhandler;
bool m_secure;