mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Add minetest.register_on_player_hpchange
This commit is contained in:
parent
e50aa4ed06
commit
aa13baa30a
5 changed files with 61 additions and 0 deletions
|
@ -69,6 +69,25 @@ bool ScriptApiPlayer::on_punchplayer(ServerActiveObject *player,
|
|||
return lua_toboolean(L, -1);
|
||||
}
|
||||
|
||||
s16 ScriptApiPlayer::on_player_hpchange(ServerActiveObject *player,
|
||||
s16 hp_change)
|
||||
{
|
||||
SCRIPTAPI_PRECHECKHEADER
|
||||
|
||||
// Get core.registered_on_player_hpchange
|
||||
lua_getglobal(L, "core");
|
||||
lua_getfield(L, -1, "registered_on_player_hpchange");
|
||||
lua_remove(L, -2);
|
||||
|
||||
objectrefGetOrCreate(L, player);
|
||||
lua_pushnumber(L, hp_change);
|
||||
if (lua_pcall(L, 2, 1, m_errorhandler))
|
||||
scriptError();
|
||||
hp_change = lua_tointeger(L, -1);
|
||||
lua_pop(L, -1);
|
||||
return hp_change;
|
||||
}
|
||||
|
||||
bool ScriptApiPlayer::on_respawnplayer(ServerActiveObject *player)
|
||||
{
|
||||
SCRIPTAPI_PRECHECKHEADER
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
bool on_punchplayer(ServerActiveObject *player,
|
||||
ServerActiveObject *hitter, float time_from_last_punch,
|
||||
const ToolCapabilities *toolcap, v3f dir, s16 damage);
|
||||
s16 on_player_hpchange(ServerActiveObject *player, s16 hp_change);
|
||||
void on_playerReceiveFields(ServerActiveObject *player,
|
||||
const std::string &formname, const StringMap &fields);
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue