3 Copyright (C) 2020 system32
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation; either version 2.1 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License along
16 with this program; if not, write to the Free Software Foundation, Inc.,
17 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #include "lua_api/l_base.h"
21 #include "client/clientobject.h"
22 #include "client/content_cao.h"
24 class ClientObjectRef : public ModApiBase
27 ClientObjectRef(ClientActiveObject *object);
29 ~ClientObjectRef() = default;
31 static void Register(lua_State *L);
33 static void create(lua_State *L, ClientActiveObject *object);
35 static ClientObjectRef *checkobject(lua_State *L, int narg);
38 ClientActiveObject *m_object = nullptr;
39 static const char className[];
40 static luaL_Reg methods[];
42 static ClientActiveObject *get_cao(ClientObjectRef *ref);
43 static GenericCAO *get_generic_cao(ClientObjectRef *ref, lua_State *L);
45 static int gc_object(lua_State *L);
48 // returns: {x=num, y=num, z=num}
49 static int l_get_pos(lua_State *L);
52 static int l_get_velocity(lua_State *L);
54 // get_acceleration(self)
55 static int l_get_acceleration(lua_State *L);
58 static int l_get_rotation(lua_State *L);
61 static int l_is_player(lua_State *L);
64 static int l_get_name(lua_State *L);
67 static int l_get_attach(lua_State *L);
70 static int l_get_nametag(lua_State *L);
73 static int l_get_item_textures(lua_State *L);
76 static int l_get_max_hp(lua_State *L);