1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Allow mods to listen to cheat detections using minetest.register_on_cheat()

This commit is contained in:
Perttu Ahola 2013-08-04 00:45:49 +03:00
parent 742614180c
commit 8831669505
7 changed files with 40 additions and 3 deletions

View file

@ -81,6 +81,22 @@ void ScriptApiPlayer::on_leaveplayer(ServerActiveObject *player)
runCallbacks(1, RUN_CALLBACKS_MODE_FIRST);
}
void ScriptApiPlayer::on_cheat(ServerActiveObject *player,
const std::string &cheat_type)
{
SCRIPTAPI_PRECHECKHEADER
// Get minetest.registered_on_cheats
lua_getglobal(L, "minetest");
lua_getfield(L, -1, "registered_on_cheats");
// Call callbacks
objectrefGetOrCreate(player);
lua_newtable(L);
lua_pushlstring(L, cheat_type.c_str(), cheat_type.size());
lua_setfield(L, -2, "type");
runCallbacks(2, RUN_CALLBACKS_MODE_FIRST);
}
void ScriptApiPlayer::on_playerReceiveFields(ServerActiveObject *player,
const std::string &formname,
const std::map<std::string, std::string> &fields)

View file

@ -34,6 +34,7 @@ public:
bool on_respawnplayer(ServerActiveObject *player);
void on_joinplayer(ServerActiveObject *player);
void on_leaveplayer(ServerActiveObject *player);
void on_cheat(ServerActiveObject *player, const std::string &cheat_type);
void on_playerReceiveFields(ServerActiveObject *player,
const std::string &formname,