]> git.lizzy.rs Git - dragonfireclient.git/blob - src/script/lua_api/l_object.h
Revert "Add a Lua call to do damages / heals" ok @ShadowNinja
[dragonfireclient.git] / src / script / lua_api / l_object.h
1 /*
2 Minetest
3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
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.
9
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.
14
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.
18 */
19
20 #ifndef L_OBJECT_H_
21 #define L_OBJECT_H_
22
23 #include "lua_api/l_base.h"
24 #include "irrlichttypes.h"
25
26 class ServerActiveObject;
27 class LuaEntitySAO;
28 class PlayerSAO;
29 class Player;
30
31 /*
32         ObjectRef
33 */
34
35 class ObjectRef : public ModApiBase {
36 private:
37         ServerActiveObject *m_object;
38
39         static const char className[];
40         static const luaL_reg methods[];
41 public:
42         static ObjectRef *checkobject(lua_State *L, int narg);
43
44         static ServerActiveObject* getobject(ObjectRef *ref);
45 private:
46         static LuaEntitySAO* getluaobject(ObjectRef *ref);
47
48         static PlayerSAO* getplayersao(ObjectRef *ref);
49
50         static Player* getplayer(ObjectRef *ref);
51
52         // Exported functions
53
54         // garbage collector
55         static int gc_object(lua_State *L);
56
57         // remove(self)
58         static int l_remove(lua_State *L);
59
60         // getpos(self)
61         // returns: {x=num, y=num, z=num}
62         static int l_getpos(lua_State *L);
63
64         // setpos(self, pos)
65         static int l_setpos(lua_State *L);
66
67         // moveto(self, pos, continuous=false)
68         static int l_moveto(lua_State *L);
69
70         // punch(self, puncher, time_from_last_punch, tool_capabilities, dir)
71         static int l_punch(lua_State *L);
72
73         // right_click(self, clicker); clicker = an another ObjectRef
74         static int l_right_click(lua_State *L);
75
76         // set_hp(self, hp)
77         // hp = number of hitpoints (2 * number of hearts)
78         // returns: nil
79         static int l_set_hp(lua_State *L);
80
81         // get_hp(self)
82         // returns: number of hitpoints (2 * number of hearts)
83         // 0 if not applicable to this type of object
84         static int l_get_hp(lua_State *L);
85
86         // get_inventory(self)
87         static int l_get_inventory(lua_State *L);
88
89         // get_wield_list(self)
90         static int l_get_wield_list(lua_State *L);
91
92         // get_wield_index(self)
93         static int l_get_wield_index(lua_State *L);
94
95         // get_wielded_item(self)
96         static int l_get_wielded_item(lua_State *L);
97
98         // set_wielded_item(self, itemstack or itemstring or table or nil)
99         static int l_set_wielded_item(lua_State *L);
100
101         // set_armor_groups(self, groups)
102         static int l_set_armor_groups(lua_State *L);
103
104         // set_physics_override(self, physics_override_speed, physics_override_jump,
105         //                      physics_override_gravity, sneak, sneak_glitch)
106         static int l_set_physics_override(lua_State *L);
107
108         // set_animation(self, frame_range, frame_speed, frame_blend)
109         static int l_set_animation(lua_State *L);
110
111         // set_bone_position(self, std::string bone, v3f position, v3f rotation)
112         static int l_set_bone_position(lua_State *L);
113
114         // set_attach(self, parent, bone, position, rotation)
115         static int l_set_attach(lua_State *L);
116
117         // set_detach(self)
118         static int l_set_detach(lua_State *L);
119
120         // set_properties(self, properties)
121         static int l_set_properties(lua_State *L);
122
123         /* LuaEntitySAO-only */
124
125         // setvelocity(self, {x=num, y=num, z=num})
126         static int l_setvelocity(lua_State *L);
127
128         // getvelocity(self)
129         static int l_getvelocity(lua_State *L);
130
131         // setacceleration(self, {x=num, y=num, z=num})
132         static int l_setacceleration(lua_State *L);
133
134         // getacceleration(self)
135         static int l_getacceleration(lua_State *L);
136
137         // setyaw(self, radians)
138         static int l_setyaw(lua_State *L);
139
140         // getyaw(self)
141         static int l_getyaw(lua_State *L);
142
143         // settexturemod(self, mod)
144         static int l_settexturemod(lua_State *L);
145
146         // setsprite(self, p={x=0,y=0}, num_frames=1, framelength=0.2,
147         //           select_horiz_by_yawpitch=false)
148         static int l_setsprite(lua_State *L);
149
150         // DEPRECATED
151         // get_entity_name(self)
152         static int l_get_entity_name(lua_State *L);
153
154         // get_luaentity(self)
155         static int l_get_luaentity(lua_State *L);
156
157         /* Player-only */
158
159         // is_player(self)
160         static int l_is_player(lua_State *L);
161
162         // is_player_connected(self)
163         static int l_is_player_connected(lua_State *L);
164
165         // get_player_name(self)
166         static int l_get_player_name(lua_State *L);
167
168         // get_look_dir(self)
169         static int l_get_look_dir(lua_State *L);
170
171         // get_look_pitch(self)
172         static int l_get_look_pitch(lua_State *L);
173
174         // get_look_yaw(self)
175         static int l_get_look_yaw(lua_State *L);
176
177         // set_look_pitch(self, radians)
178         static int l_set_look_pitch(lua_State *L);
179
180         // set_look_yaw(self, radians)
181         static int l_set_look_yaw(lua_State *L);
182
183         // set_breath(self, breath)
184         static int l_set_breath(lua_State *L);
185
186         // get_breath(self, breath)
187         static int l_get_breath(lua_State *L);
188
189         // set_inventory_formspec(self, formspec)
190         static int l_set_inventory_formspec(lua_State *L);
191
192         // get_inventory_formspec(self) -> formspec
193         static int l_get_inventory_formspec(lua_State *L);
194
195         // get_player_control(self)
196         static int l_get_player_control(lua_State *L);
197
198         // get_player_control_bits(self)
199         static int l_get_player_control_bits(lua_State *L);
200
201         // hud_add(self, id, form)
202         static int l_hud_add(lua_State *L);
203
204         // hud_rm(self, id)
205         static int l_hud_remove(lua_State *L);
206
207         // hud_change(self, id, stat, data)
208         static int l_hud_change(lua_State *L);
209
210         // hud_get_next_id(self)
211         static u32 hud_get_next_id(lua_State *L);
212
213         // hud_get(self, id)
214         static int l_hud_get(lua_State *L);
215
216         // hud_set_flags(self, flags)
217         static int l_hud_set_flags(lua_State *L);
218
219         // hud_get_flags()
220         static int l_hud_get_flags(lua_State *L);
221
222         // hud_set_hotbar_itemcount(self, hotbar_itemcount)
223         static int l_hud_set_hotbar_itemcount(lua_State *L);
224
225         // hud_set_hotbar_image(self, name)
226         static int l_hud_set_hotbar_image(lua_State *L);
227
228         // hud_set_hotbar_selected_image(self, name)
229         static int l_hud_set_hotbar_selected_image(lua_State *L);
230
231         // set_sky(self, type, list)
232         static int l_set_sky(lua_State *L);
233
234         // override_day_night_ratio(self, type, list)
235         static int l_override_day_night_ratio(lua_State *L);
236
237         // set_local_animation(self, {stand/idle}, {walk}, {dig}, {walk+dig}, frame_speed)
238         static int l_set_local_animation(lua_State *L);
239
240         // set_eye_offset(self, v3f first pv, v3f third pv)
241         static int l_set_eye_offset(lua_State *L);
242
243 public:
244         ObjectRef(ServerActiveObject *object);
245
246         ~ObjectRef();
247
248         // Creates an ObjectRef and leaves it on top of stack
249         // Not callable from Lua; all references are created on the C side.
250         static void create(lua_State *L, ServerActiveObject *object);
251
252         static void set_null(lua_State *L);
253
254         static void Register(lua_State *L);
255 };
256
257 #endif /* L_OBJECT_H_ */