1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-10 19:32:10 +00:00

SAPI: Track last executed mod and include in error messages

This commit is contained in:
kwolekr 2015-08-11 22:27:54 -04:00
parent 738fbc66d0
commit 2b04ab874d
19 changed files with 231 additions and 45 deletions

View file

@ -32,7 +32,7 @@ void ScriptApiPlayer::on_newplayer(ServerActiveObject *player)
lua_getfield(L, -1, "registered_on_newplayers");
// Call callbacks
objectrefGetOrCreate(L, player);
script_run_callbacks(L, 1, RUN_CALLBACKS_MODE_FIRST);
runCallbacks(1, RUN_CALLBACKS_MODE_FIRST);
}
void ScriptApiPlayer::on_dieplayer(ServerActiveObject *player)
@ -44,7 +44,7 @@ void ScriptApiPlayer::on_dieplayer(ServerActiveObject *player)
lua_getfield(L, -1, "registered_on_dieplayers");
// Call callbacks
objectrefGetOrCreate(L, player);
script_run_callbacks(L, 1, RUN_CALLBACKS_MODE_FIRST);
runCallbacks(1, RUN_CALLBACKS_MODE_FIRST);
}
bool ScriptApiPlayer::on_punchplayer(ServerActiveObject *player,
@ -65,7 +65,7 @@ bool ScriptApiPlayer::on_punchplayer(ServerActiveObject *player,
push_tool_capabilities(L, *toolcap);
push_v3f(L, dir);
lua_pushnumber(L, damage);
script_run_callbacks(L, 6, RUN_CALLBACKS_MODE_OR);
runCallbacks(6, RUN_CALLBACKS_MODE_OR);
return lua_toboolean(L, -1);
}
@ -96,7 +96,7 @@ bool ScriptApiPlayer::on_respawnplayer(ServerActiveObject *player)
lua_getfield(L, -1, "registered_on_respawnplayers");
// Call callbacks
objectrefGetOrCreate(L, player);
script_run_callbacks(L, 1, RUN_CALLBACKS_MODE_OR);
runCallbacks(1, RUN_CALLBACKS_MODE_OR);
bool positioning_handled_by_some = lua_toboolean(L, -1);
return positioning_handled_by_some;
}
@ -113,7 +113,7 @@ bool ScriptApiPlayer::on_prejoinplayer(
lua_getfield(L, -1, "registered_on_prejoinplayers");
lua_pushstring(L, name.c_str());
lua_pushstring(L, ip.c_str());
script_run_callbacks(L, 2, RUN_CALLBACKS_MODE_OR);
runCallbacks(2, RUN_CALLBACKS_MODE_OR);
if (lua_isstring(L, -1)) {
reason->assign(lua_tostring(L, -1));
return true;
@ -130,7 +130,7 @@ void ScriptApiPlayer::on_joinplayer(ServerActiveObject *player)
lua_getfield(L, -1, "registered_on_joinplayers");
// Call callbacks
objectrefGetOrCreate(L, player);
script_run_callbacks(L, 1, RUN_CALLBACKS_MODE_FIRST);
runCallbacks(1, RUN_CALLBACKS_MODE_FIRST);
}
void ScriptApiPlayer::on_leaveplayer(ServerActiveObject *player)
@ -142,7 +142,7 @@ void ScriptApiPlayer::on_leaveplayer(ServerActiveObject *player)
lua_getfield(L, -1, "registered_on_leaveplayers");
// Call callbacks
objectrefGetOrCreate(L, player);
script_run_callbacks(L, 1, RUN_CALLBACKS_MODE_FIRST);
runCallbacks(1, RUN_CALLBACKS_MODE_FIRST);
}
void ScriptApiPlayer::on_cheat(ServerActiveObject *player,
@ -158,7 +158,7 @@ void ScriptApiPlayer::on_cheat(ServerActiveObject *player,
lua_newtable(L);
lua_pushlstring(L, cheat_type.c_str(), cheat_type.size());
lua_setfield(L, -2, "type");
script_run_callbacks(L, 2, RUN_CALLBACKS_MODE_FIRST);
runCallbacks(2, RUN_CALLBACKS_MODE_FIRST);
}
void ScriptApiPlayer::on_playerReceiveFields(ServerActiveObject *player,
@ -185,7 +185,7 @@ void ScriptApiPlayer::on_playerReceiveFields(ServerActiveObject *player,
lua_pushlstring(L, value.c_str(), value.size());
lua_settable(L, -3);
}
script_run_callbacks(L, 3, RUN_CALLBACKS_MODE_OR_SC);
runCallbacks(3, RUN_CALLBACKS_MODE_OR_SC);
}
ScriptApiPlayer::~ScriptApiPlayer()