diff options
Diffstat (limited to 'src/script/cpp_api')
-rw-r--r-- | src/script/cpp_api/s_player.cpp | 16 | ||||
-rw-r--r-- | src/script/cpp_api/s_player.h | 1 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/script/cpp_api/s_player.cpp b/src/script/cpp_api/s_player.cpp index e736d745d..0dbd52527 100644 --- a/src/script/cpp_api/s_player.cpp +++ b/src/script/cpp_api/s_player.cpp @@ -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) diff --git a/src/script/cpp_api/s_player.h b/src/script/cpp_api/s_player.h index 663e3c2ab..c0409a481 100644 --- a/src/script/cpp_api/s_player.h +++ b/src/script/cpp_api/s_player.h @@ -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, |