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

Implement on_rightclickplayer callback (#10775)

Co-authored-by: rubenwardy <rw@rubenwardy.com>
This commit is contained in:
JDiaz 2021-01-11 18:03:31 +01:00 committed by GitHub
parent fcb3ed840a
commit 08ee9794fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 28 additions and 4 deletions

View file

@ -77,6 +77,19 @@ bool ScriptApiPlayer::on_punchplayer(ServerActiveObject *player,
return readParam<bool>(L, -1);
}
void ScriptApiPlayer::on_rightclickplayer(ServerActiveObject *player,
ServerActiveObject *clicker)
{
SCRIPTAPI_PRECHECKHEADER
// Get core.registered_on_rightclickplayers
lua_getglobal(L, "core");
lua_getfield(L, -1, "registered_on_rightclickplayers");
// Call callbacks
objectrefGetOrCreate(L, player);
objectrefGetOrCreate(L, clicker);
runCallbacks(2, RUN_CALLBACKS_MODE_FIRST);
}
s32 ScriptApiPlayer::on_player_hpchange(ServerActiveObject *player,
s32 hp_change, const PlayerHPChangeReason &reason)
{

View file

@ -47,6 +47,7 @@ public:
bool on_punchplayer(ServerActiveObject *player, ServerActiveObject *hitter,
float time_from_last_punch, const ToolCapabilities *toolcap,
v3f dir, s16 damage);
void on_rightclickplayer(ServerActiveObject *player, ServerActiveObject *clicker);
s32 on_player_hpchange(ServerActiveObject *player, s32 hp_change,
const PlayerHPChangeReason &reason);
void on_playerReceiveFields(ServerActiveObject *player,