* `is_player()`: returns true if the object is a player
* `is_local_player()`: returns true if the object is the local player
* `get_attach()`: returns parent or nil if it isn't attached.
-* `get_nametag()`: returns the nametag (string)
-* `get_item_textures()`: returns the textures
-* `get_max_hp()`: returns the maximum heath
+* `get_nametag()`: returns the nametag (deprecated, use get_properties().nametag instead)
+* `get_item_textures()`: returns the textures (deprecated, use get_properties().textures instead)
+* `get_max_hp()`: returns the maximum heath (deprecated, use get_properties().hp_max instead)
+* `get_properties()`: returns object property table
* `punch()`: punches the object
* `rightclick()`: rightclicks the object
* `remove()`: removes the object permanently
#include "lua_api/l_clientobject.h"
#include "l_internal.h"
#include "common/c_converter.h"
+#include "common/c_content.h"
#include "client/client.h"
#include "object_properties.h"
#include "util/pointedthing.h"
int ClientObjectRef::l_get_nametag(lua_State *L)
{
+ log_deprecated(L,"Deprecated call to get_nametag, use get_properties().nametag instead");
ClientObjectRef *ref = checkobject(L, 1);
GenericCAO *gcao = get_generic_cao(ref, L);
ObjectProperties *props = gcao->getProperties();
int ClientObjectRef::l_get_item_textures(lua_State *L)
{
+ log_deprecated(L,"Deprecated call to get_item_textures, use get_properties().textures instead");
ClientObjectRef *ref = checkobject(L, 1);
GenericCAO *gcao = get_generic_cao(ref, L);
ObjectProperties *props = gcao->getProperties();
return 1;
}
-int ClientObjectRef::l_get_hp(lua_State *L)
+int ClientObjectRef::l_get_max_hp(lua_State *L)
{
+ log_deprecated(L,"Deprecated call to get_max_hp, use get_properties().hp_max instead");
ClientObjectRef *ref = checkobject(L, 1);
GenericCAO *gcao = get_generic_cao(ref, L);
- lua_pushnumber(L, gcao->getHp());
+ ObjectProperties *props = gcao->getProperties();
+ lua_pushnumber(L, props->hp_max);
return 1;
}
-int ClientObjectRef::l_get_max_hp(lua_State *L)
+int ClientObjectRef::l_get_properties(lua_State *L)
{
ClientObjectRef *ref = checkobject(L, 1);
GenericCAO *gcao = get_generic_cao(ref, L);
- ObjectProperties *props = gcao->getProperties();
- lua_pushnumber(L, props->hp_max);
+ ObjectProperties *prop = gcao->getProperties();
+ push_object_properties(L, prop);
+ 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;
}
luamethod(ClientObjectRef, get_attach),
luamethod(ClientObjectRef, get_nametag),
luamethod(ClientObjectRef, get_item_textures),
+ luamethod(ClientObjectRef, get_properties),
luamethod(ClientObjectRef, get_hp),
luamethod(ClientObjectRef, get_max_hp), luamethod(ClientObjectRef, punch),
luamethod(ClientObjectRef, rightclick), {0, 0}};