]> git.lizzy.rs Git - dragonfireclient.git/blob - src/script/lua_api/l_object.h
Add API function to invoke player respawn
[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 #pragma once
21
22 #include "lua_api/l_base.h"
23 #include "irrlichttypes.h"
24
25 class ServerActiveObject;
26 class LuaEntitySAO;
27 class PlayerSAO;
28 class RemotePlayer;
29
30 /*
31         ObjectRef
32 */
33
34 class ObjectRef : public ModApiBase {
35 public:
36         ObjectRef(ServerActiveObject *object);
37
38         ~ObjectRef() = default;
39
40         // Creates an ObjectRef and leaves it on top of stack
41         // Not callable from Lua; all references are created on the C side.
42         static void create(lua_State *L, ServerActiveObject *object);
43
44         static void set_null(lua_State *L);
45
46         static void Register(lua_State *L);
47
48         static ObjectRef *checkobject(lua_State *L, int narg);
49
50         static ServerActiveObject* getobject(ObjectRef *ref);
51 private:
52         ServerActiveObject *m_object = nullptr;
53         static const char className[];
54         static luaL_Reg methods[];
55
56
57         static LuaEntitySAO* getluaobject(ObjectRef *ref);
58
59         static PlayerSAO* getplayersao(ObjectRef *ref);
60
61         static RemotePlayer *getplayer(ObjectRef *ref);
62
63         // Exported functions
64
65         // garbage collector
66         static int gc_object(lua_State *L);
67
68         // remove(self)
69         static int l_remove(lua_State *L);
70
71         // get_pos(self)
72         static int l_get_pos(lua_State *L);
73
74         // set_pos(self, pos)
75         static int l_set_pos(lua_State *L);
76
77         // move_to(self, pos, continuous)
78         static int l_move_to(lua_State *L);
79
80         // punch(self, puncher, time_from_last_punch, tool_capabilities, dir)
81         static int l_punch(lua_State *L);
82
83         // right_click(self, clicker)
84         static int l_right_click(lua_State *L);
85
86         // set_hp(self, hp, reason)
87         static int l_set_hp(lua_State *L);
88
89         // get_hp(self)
90         static int l_get_hp(lua_State *L);
91
92         // get_inventory(self)
93         static int l_get_inventory(lua_State *L);
94
95         // get_wield_list(self)
96         static int l_get_wield_list(lua_State *L);
97
98         // get_wield_index(self)
99         static int l_get_wield_index(lua_State *L);
100
101         // get_wielded_item(self)
102         static int l_get_wielded_item(lua_State *L);
103
104         // set_wielded_item(self, item)
105         static int l_set_wielded_item(lua_State *L);
106
107         // set_armor_groups(self, groups)
108         static int l_set_armor_groups(lua_State *L);
109
110         // get_armor_groups(self)
111         static int l_get_armor_groups(lua_State *L);
112
113         // set_physics_override(self, override_table)
114         static int l_set_physics_override(lua_State *L);
115
116         // get_physics_override(self)
117         static int l_get_physics_override(lua_State *L);
118
119         // set_animation(self, frame_range, frame_speed, frame_blend, frame_loop)
120         static int l_set_animation(lua_State *L);
121
122         // set_animation_frame_speed(self, frame_speed)
123         static int l_set_animation_frame_speed(lua_State *L);
124
125         // get_animation(self)
126         static int l_get_animation(lua_State *L);
127
128         // set_bone_position(self, bone, position, rotation)
129         static int l_set_bone_position(lua_State *L);
130
131         // get_bone_position(self, bone)
132         static int l_get_bone_position(lua_State *L);
133
134         // set_attach(self, parent, bone, position, rotation)
135         static int l_set_attach(lua_State *L);
136
137         // get_attach(self)
138         static int l_get_attach(lua_State *L);
139
140         // get_children(self)
141         static int l_get_children(lua_State *L);
142
143         // set_detach(self)
144         static int l_set_detach(lua_State *L);
145
146         // set_properties(self, properties)
147         static int l_set_properties(lua_State *L);
148
149         // get_properties(self)
150         static int l_get_properties(lua_State *L);
151
152         // is_player(self)
153         static int l_is_player(lua_State *L);
154
155         /* LuaEntitySAO-only */
156
157         // set_velocity(self, velocity)
158         static int l_set_velocity(lua_State *L);
159
160         // add_velocity(self, velocity)
161         static int l_add_velocity(lua_State *L);
162
163         // get_velocity(self)
164         static int l_get_velocity(lua_State *L);
165
166         // set_acceleration(self, acceleration)
167         static int l_set_acceleration(lua_State *L);
168
169         // get_acceleration(self)
170         static int l_get_acceleration(lua_State *L);
171
172         // set_rotation(self, rotation)
173         static int l_set_rotation(lua_State *L);
174
175         // get_rotation(self)
176         static int l_get_rotation(lua_State *L);
177
178         // set_yaw(self, yaw)
179         static int l_set_yaw(lua_State *L);
180
181         // get_yaw(self)
182         static int l_get_yaw(lua_State *L);
183
184         // set_texture_mod(self, mod)
185         static int l_set_texture_mod(lua_State *L);
186
187         // l_get_texture_mod(self)
188         static int l_get_texture_mod(lua_State *L);
189
190         // set_sprite(self, start_frame, num_frames, framelength, select_x_by_camera)
191         static int l_set_sprite(lua_State *L);
192
193         // DEPRECATED
194         // get_entity_name(self)
195         static int l_get_entity_name(lua_State *L);
196
197         // get_luaentity(self)
198         static int l_get_luaentity(lua_State *L);
199
200         /* Player-only */
201
202         // get_player_name(self)
203         static int l_get_player_name(lua_State *L);
204
205         // get_fov(self)
206         static int l_get_fov(lua_State *L);
207
208         // get_look_dir(self)
209         static int l_get_look_dir(lua_State *L);
210
211         // DEPRECATED
212         // get_look_pitch(self)
213         static int l_get_look_pitch(lua_State *L);
214
215         // DEPRECATED
216         // get_look_yaw(self)
217         static int l_get_look_yaw(lua_State *L);
218
219         // get_look_pitch2(self)
220         static int l_get_look_vertical(lua_State *L);
221
222         // get_look_yaw2(self)
223         static int l_get_look_horizontal(lua_State *L);
224
225         // set_fov(self, degrees, is_multiplier, transition_time)
226         static int l_set_fov(lua_State *L);
227
228         // set_look_vertical(self, radians)
229         static int l_set_look_vertical(lua_State *L);
230
231         // set_look_horizontal(self, radians)
232         static int l_set_look_horizontal(lua_State *L);
233
234         // DEPRECATED
235         // set_look_pitch(self, radians)
236         static int l_set_look_pitch(lua_State *L);
237
238         // DEPRECATED
239         // set_look_yaw(self, radians)
240         static int l_set_look_yaw(lua_State *L);
241
242         // set_breath(self, breath)
243         static int l_set_breath(lua_State *L);
244
245         // get_breath(self, breath)
246         static int l_get_breath(lua_State *L);
247
248         // DEPRECATED
249         // set_attribute(self, attribute, value)
250         static int l_set_attribute(lua_State *L);
251
252         // DEPRECATED
253         // get_attribute(self, attribute)
254         static int l_get_attribute(lua_State *L);
255
256         // get_meta(self)
257         static int l_get_meta(lua_State *L);
258
259         // set_inventory_formspec(self, formspec)
260         static int l_set_inventory_formspec(lua_State *L);
261
262         // get_inventory_formspec(self)
263         static int l_get_inventory_formspec(lua_State *L);
264
265         // set_formspec_prepend(self, formspec)
266         static int l_set_formspec_prepend(lua_State *L);
267
268         // get_formspec_prepend(self)
269         static int l_get_formspec_prepend(lua_State *L);
270
271         // get_player_control(self)
272         static int l_get_player_control(lua_State *L);
273
274         // get_player_control_bits(self)
275         static int l_get_player_control_bits(lua_State *L);
276
277         // hud_add(self, id, form)
278         static int l_hud_add(lua_State *L);
279
280         // hud_rm(self, id)
281         static int l_hud_remove(lua_State *L);
282
283         // hud_change(self, id, stat, data)
284         static int l_hud_change(lua_State *L);
285
286         // hud_get_next_id(self)
287         static u32 hud_get_next_id(lua_State *L);
288
289         // hud_get(self, id)
290         static int l_hud_get(lua_State *L);
291
292         // hud_set_flags(self, flags)
293         static int l_hud_set_flags(lua_State *L);
294
295         // hud_get_flags()
296         static int l_hud_get_flags(lua_State *L);
297
298         // hud_set_hotbar_itemcount(self, hotbar_itemcount)
299         static int l_hud_set_hotbar_itemcount(lua_State *L);
300
301         // hud_get_hotbar_itemcount(self)
302         static int l_hud_get_hotbar_itemcount(lua_State *L);
303
304         // hud_set_hotbar_image(self, name)
305         static int l_hud_set_hotbar_image(lua_State *L);
306
307         // hud_get_hotbar_image(self)
308         static int l_hud_get_hotbar_image(lua_State *L);
309
310         // hud_set_hotbar_selected_image(self, name)
311         static int l_hud_set_hotbar_selected_image(lua_State *L);
312
313         // hud_get_hotbar_selected_image(self)
314         static int l_hud_get_hotbar_selected_image(lua_State *L);
315
316         // set_sky(self, sky_parameters)
317         static int l_set_sky(lua_State *L);
318
319         // get_sky(self, as_table)
320         static int l_get_sky(lua_State *L);
321
322         // DEPRECATED
323         // get_sky_color(self)
324         static int l_get_sky_color(lua_State* L);
325
326         // set_sun(self, sun_parameters)
327         static int l_set_sun(lua_State *L);
328
329         // get_sun(self)
330         static int l_get_sun(lua_State *L);
331
332         // set_moon(self, moon_parameters)
333         static int l_set_moon(lua_State *L);
334
335         // get_moon(self)
336         static int l_get_moon(lua_State *L);
337
338         // set_stars(self, star_parameters)
339         static int l_set_stars(lua_State *L);
340
341         // get_stars(self)
342         static int l_get_stars(lua_State *L);
343
344         // set_clouds(self, cloud_parameters)
345         static int l_set_clouds(lua_State *L);
346
347         // get_clouds(self)
348         static int l_get_clouds(lua_State *L);
349
350         // override_day_night_ratio(self, type)
351         static int l_override_day_night_ratio(lua_State *L);
352
353         // get_day_night_ratio(self)
354         static int l_get_day_night_ratio(lua_State *L);
355
356         // set_local_animation(self, idle, walk, dig, walk_while_dig, frame_speed)
357         static int l_set_local_animation(lua_State *L);
358
359         // get_local_animation(self)
360         static int l_get_local_animation(lua_State *L);
361
362         // set_eye_offset(self, firstperson, thirdperson)
363         static int l_set_eye_offset(lua_State *L);
364
365         // get_eye_offset(self)
366         static int l_get_eye_offset(lua_State *L);
367
368         // set_nametag_attributes(self, attributes)
369         static int l_set_nametag_attributes(lua_State *L);
370
371         // get_nametag_attributes(self)
372         static int l_get_nametag_attributes(lua_State *L);
373
374         // send_mapblock(pos)
375         static int l_send_mapblock(lua_State *L);
376
377         // set_minimap_modes(self, modes, wanted_mode)
378         static int l_set_minimap_modes(lua_State *L);
379
380         // set_lighting(self, lighting)
381         static int l_set_lighting(lua_State *L);
382         
383         // get_lighting(self)
384         static int l_get_lighting(lua_State *L);
385
386         // respawn(self)
387         static int l_respawn(lua_State *L);
388 };