summaryrefslogtreecommitdiff
path: root/src/script/cpp_api/s_player.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/script/cpp_api/s_player.cpp')
-rw-r--r--src/script/cpp_api/s_player.cpp16
1 files changed, 16 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)