Added ClientObjectRef:get_hp()

master
Elias Fleckenstein 2020-11-26 18:44:29 +01:00
parent fb4d54ee30
commit eaec3645b0
3 changed files with 17 additions and 0 deletions

View File

@ -178,6 +178,11 @@ public:
{
return m_velocity;
}
inline const u16 getHp() const
{
return m_hp;
}
const bool isImmortal();

View File

@ -133,6 +133,14 @@ int ClientObjectRef::l_get_item_textures(lua_State *L)
return 1;
}
int ClientObjectRef::l_get_hp(lua_State *L)
{
ClientObjectRef *ref = checkobject(L, 1);
GenericCAO *gcao = get_generic_cao(ref, L);
lua_pushnumber(L, gcao->getHp());
return 1;
}
int ClientObjectRef::l_get_max_hp(lua_State *L)
{
ClientObjectRef *ref = checkobject(L, 1);
@ -223,5 +231,6 @@ luaL_Reg ClientObjectRef::methods[] = {luamethod(ClientObjectRef, get_pos),
luamethod(ClientObjectRef, get_attach),
luamethod(ClientObjectRef, get_nametag),
luamethod(ClientObjectRef, get_item_textures),
luamethod(ClientObjectRef, get_hp),
luamethod(ClientObjectRef, get_max_hp), luamethod(ClientObjectRef, punch),
luamethod(ClientObjectRef, rightclick), {0, 0}};

View File

@ -77,6 +77,9 @@ private:
static int l_get_item_textures(lua_State *L);
// get_hp(self)
static int l_get_hp(lua_State *L);
// get_max_hp(self)
static int l_get_max_hp(lua_State *L);
// punch(self)