diff options
author | kwolekr <kwolekr@minetest.net> | 2015-08-11 22:27:54 -0400 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2015-08-12 23:56:12 -0400 |
commit | 2b04ab874d75711bc021a0cd8dc7fca68f4e6929 (patch) | |
tree | 04c1e9ad914c8c744cfd1055e2a8f6620d924c8b /src/script/cpp_api/s_entity.cpp | |
parent | 738fbc66d096575bb9a1694056ce2d627a70c03d (diff) | |
download | minetest-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_entity.cpp')
-rw-r--r-- | src/script/cpp_api/s_entity.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/script/cpp_api/s_entity.cpp b/src/script/cpp_api/s_entity.cpp index 08e06ccbc..0d159846a 100644 --- a/src/script/cpp_api/s_entity.cpp +++ b/src/script/cpp_api/s_entity.cpp @@ -91,7 +91,8 @@ void ScriptApiEntity::luaentity_Activate(u16 id, lua_pushvalue(L, object); // self lua_pushlstring(L, staticdata.c_str(), staticdata.size()); lua_pushinteger(L, dtime_s); - // Call with 3 arguments, 0 results + + setOriginFromTable(object); PCALL_RES(lua_pcall(L, 3, 0, m_errorhandler)); } else { lua_pop(L, 1); @@ -135,11 +136,12 @@ std::string ScriptApiEntity::luaentity_GetStaticdata(u16 id) lua_pop(L, 2); // Pop entity and get_staticdata return ""; } - luaL_checktype(L, -1, LUA_TFUNCTION); lua_pushvalue(L, object); // self - // Call with 1 arguments, 1 results + + setOriginFromTable(object); PCALL_RES(lua_pcall(L, 1, 1, m_errorhandler)); + lua_remove(L, object); // Remove object size_t len = 0; @@ -207,8 +209,10 @@ void ScriptApiEntity::luaentity_Step(u16 id, float dtime) luaL_checktype(L, -1, LUA_TFUNCTION); lua_pushvalue(L, object); // self lua_pushnumber(L, dtime); // dtime - // Call with 2 arguments, 0 results + + setOriginFromTable(object); PCALL_RES(lua_pcall(L, 2, 0, m_errorhandler)); + lua_pop(L, 1); // Pop object } @@ -238,8 +242,10 @@ void ScriptApiEntity::luaentity_Punch(u16 id, lua_pushnumber(L, time_from_last_punch); push_tool_capabilities(L, *toolcap); push_v3f(L, dir); - // Call with 5 arguments, 0 results + + setOriginFromTable(object); PCALL_RES(lua_pcall(L, 5, 0, m_errorhandler)); + lua_pop(L, 1); // Pop object } @@ -264,8 +270,10 @@ void ScriptApiEntity::luaentity_Rightclick(u16 id, luaL_checktype(L, -1, LUA_TFUNCTION); lua_pushvalue(L, object); // self objectrefGetOrCreate(L, clicker); // Clicker reference - // Call with 2 arguments, 0 results + + setOriginFromTable(object); PCALL_RES(lua_pcall(L, 2, 0, m_errorhandler)); + lua_pop(L, 1); // Pop object } |