]> git.lizzy.rs Git - dragonfireclient.git/blob - src/script/lua_api/l_object.h
a75c59fd9333a662e1b6567040d56498d8cd6ea3
[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         // returns: {x=num, y=num, z=num}
73         static int l_get_pos(lua_State *L);
74
75         // set_pos(self, pos)
76         static int l_set_pos(lua_State *L);
77
78         // move_to(self, pos, continuous=false)
79         static int l_move_to(lua_State *L);
80
81         // punch(self, puncher, time_from_last_punch, tool_capabilities, dir)
82         static int l_punch(lua_State *L);
83
84         // right_click(self, clicker); clicker = an another ObjectRef
85         static int l_right_click(lua_State *L);
86
87         // set_hp(self, hp)
88         // hp = number of hitpoints (2 * number of hearts)
89         // returns: nil
90         static int l_set_hp(lua_State *L);
91
92         // get_hp(self)
93         // returns: number of hitpoints (2 * number of hearts)
94         // 0 if not applicable to this type of object
95         static int l_get_hp(lua_State *L);
96
97         // get_inventory(self)
98         static int l_get_inventory(lua_State *L);
99
100         // get_wield_list(self)
101         static int l_get_wield_list(lua_State *L);
102
103         // get_wield_index(self)
104         static int l_get_wield_index(lua_State *L);
105
106         // get_wielded_item(self)
107         static int l_get_wielded_item(lua_State *L);
108
109         // set_wielded_item(self, itemstack or itemstring or table or nil)
110         static int l_set_wielded_item(lua_State *L);
111
112         // set_armor_groups(self, groups)
113         static int l_set_armor_groups(lua_State *L);
114
115         // get_armor_groups(self)
116         static int l_get_armor_groups(lua_State *L);
117
118         // set_physics_override(self, physics_override_speed, physics_override_jump,
119         //                      physics_override_gravity, sneak, sneak_glitch, new_move)
120         static int l_set_physics_override(lua_State *L);
121
122         // get_physics_override(self)
123         static int l_get_physics_override(lua_State *L);
124
125         // set_animation(self, frame_range, frame_speed, frame_blend, frame_loop)
126         static int l_set_animation(lua_State *L);
127
128         // set_animation_frame_speed(self, frame_speed)
129         static int l_set_animation_frame_speed(lua_State *L);
130
131         // get_animation(self)
132         static int l_get_animation(lua_State *L);
133
134         // set_bone_position(self, std::string bone, v3f position, v3f rotation)
135         static int l_set_bone_position(lua_State *L);
136
137         // get_bone_position(self, bone)
138         static int l_get_bone_position(lua_State *L);
139
140         // set_attach(self, parent, bone, position, rotation)
141         static int l_set_attach(lua_State *L);
142
143         // get_attach(self)
144         static int l_get_attach(lua_State *L);
145
146         // set_detach(self)
147         static int l_set_detach(lua_State *L);
148
149         // set_properties(self, properties)
150         static int l_set_properties(lua_State *L);
151
152         // get_properties(self)
153         static int l_get_properties(lua_State *L);
154
155         // is_player(self)
156         static int l_is_player(lua_State *L);
157
158         /* LuaEntitySAO-only */
159
160         // set_velocity(self, {x=num, y=num, z=num})
161         static int l_set_velocity(lua_State *L);
162
163         // add_velocity(self, {x=num, y=num, z=num})
164         static int l_add_velocity(lua_State *L);
165
166         // get_velocity(self)
167         static int l_get_velocity(lua_State *L);
168
169         // set_acceleration(self, {x=num, y=num, z=num})
170         static int l_set_acceleration(lua_State *L);
171
172         // get_acceleration(self)
173         static int l_get_acceleration(lua_State *L);
174
175         // set_rotation(self, {x=num, y=num, z=num})
176         static int l_set_rotation(lua_State *L);
177
178         // get_rotation(self)
179         static int l_get_rotation(lua_State *L);
180
181         // set_yaw(self, radians)
182         static int l_set_yaw(lua_State *L);
183
184         // get_yaw(self)
185         static int l_get_yaw(lua_State *L);
186
187         // set_texture_mod(self, mod)
188         static int l_set_texture_mod(lua_State *L);
189
190         // l_get_texture_mod(self)
191         static int l_get_texture_mod(lua_State *L);
192
193         // set_sprite(self, p={x=0,y=0}, num_frames=1, framelength=0.2,
194         //           select_horiz_by_yawpitch=false)
195         static int l_set_sprite(lua_State *L);
196
197         // DEPRECATED
198         // get_entity_name(self)
199         static int l_get_entity_name(lua_State *L);
200
201         // get_luaentity(self)
202         static int l_get_luaentity(lua_State *L);
203
204         /* Player-only */
205
206         // is_player_connected(self)
207         static int l_is_player_connected(lua_State *L);
208
209         // get_player_name(self)
210         static int l_get_player_name(lua_State *L);
211
212         // get_player_velocity(self)
213         static int l_get_player_velocity(lua_State *L);
214
215         // add_player_velocity(self, {x=num, y=num, z=num})
216         static int l_add_player_velocity(lua_State *L);
217
218         // get_fov(self)
219         static int l_get_fov(lua_State *L);
220
221         // get_look_dir(self)
222         static int l_get_look_dir(lua_State *L);
223
224         // DEPRECATED
225         // get_look_pitch(self)
226         static int l_get_look_pitch(lua_State *L);
227
228         // DEPRECATED
229         // get_look_yaw(self)
230         static int l_get_look_yaw(lua_State *L);
231
232         // get_look_pitch2(self)
233         static int l_get_look_vertical(lua_State *L);
234
235         // get_look_yaw2(self)
236         static int l_get_look_horizontal(lua_State *L);
237
238         // set_fov(self, degrees, is_multiplier)
239         static int l_set_fov(lua_State *L);
240
241         // set_look_vertical(self, radians)
242         static int l_set_look_vertical(lua_State *L);
243
244         // set_look_horizontal(self, radians)
245         static int l_set_look_horizontal(lua_State *L);
246
247         // DEPRECATED
248         // set_look_pitch(self, radians)
249         static int l_set_look_pitch(lua_State *L);
250
251         // DEPRECATED
252         // set_look_yaw(self, radians)
253         static int l_set_look_yaw(lua_State *L);
254
255         // set_breath(self, breath)
256         static int l_set_breath(lua_State *L);
257
258         // get_breath(self, breath)
259         static int l_get_breath(lua_State *L);
260
261         // set_attribute(self, attribute, value)
262         static int l_set_attribute(lua_State *L);
263
264         // get_attribute(self, attribute)
265         static int l_get_attribute(lua_State *L);
266
267         // get_meta(self)
268         static int l_get_meta(lua_State *L);
269
270         // set_inventory_formspec(self, formspec)
271         static int l_set_inventory_formspec(lua_State *L);
272
273         // get_inventory_formspec(self) -> formspec
274         static int l_get_inventory_formspec(lua_State *L);
275
276         // set_formspec_prepend(self, formspec)
277         static int l_set_formspec_prepend(lua_State *L);
278
279         // get_formspec_prepend(self) -> formspec
280         static int l_get_formspec_prepend(lua_State *L);
281
282         // get_player_control(self)
283         static int l_get_player_control(lua_State *L);
284
285         // get_player_control_bits(self)
286         static int l_get_player_control_bits(lua_State *L);
287
288         // hud_add(self, id, form)
289         static int l_hud_add(lua_State *L);
290
291         // hud_rm(self, id)
292         static int l_hud_remove(lua_State *L);
293
294         // hud_change(self, id, stat, data)
295         static int l_hud_change(lua_State *L);
296
297         // hud_get_next_id(self)
298         static u32 hud_get_next_id(lua_State *L);
299
300         // hud_get(self, id)
301         static int l_hud_get(lua_State *L);
302
303         // hud_set_flags(self, flags)
304         static int l_hud_set_flags(lua_State *L);
305
306         // hud_get_flags()
307         static int l_hud_get_flags(lua_State *L);
308
309         // hud_set_hotbar_itemcount(self, hotbar_itemcount)
310         static int l_hud_set_hotbar_itemcount(lua_State *L);
311
312         // hud_get_hotbar_itemcount(self)
313         static int l_hud_get_hotbar_itemcount(lua_State *L);
314
315         // hud_set_hotbar_image(self, name)
316         static int l_hud_set_hotbar_image(lua_State *L);
317
318         // hud_get_hotbar_image(self)
319         static int l_hud_get_hotbar_image(lua_State *L);
320
321         // hud_set_hotbar_selected_image(self, name)
322         static int l_hud_set_hotbar_selected_image(lua_State *L);
323
324         // hud_get_hotbar_selected_image(self)
325         static int l_hud_get_hotbar_selected_image(lua_State *L);
326
327         // set_sky({base_color=, type=, textures=, clouds=, sky_colors={}})
328         static int l_set_sky(lua_State *L);
329
330         // get_sky(self)
331         static int l_get_sky(lua_State *L);
332
333         // get_sky_color(self)
334         static int l_get_sky_color(lua_State* L);
335
336         // set_sun(self, {visible, texture=, tonemap=, sunrise=, rotation=, scale=})
337         static int l_set_sun(lua_State *L);
338
339         // get_sun(self)
340         static int l_get_sun(lua_State *L);
341
342         // set_moon(self, {visible, texture=, tonemap=, rotation, scale=})
343         static int l_set_moon(lua_State *L);
344
345         // get_moon(self)
346         static int l_get_moon(lua_State *L);
347
348         // set_stars(self, {visible, count=, starcolor=, rotation, scale=})
349         static int l_set_stars(lua_State *L);
350
351         // get_stars(self)
352         static int l_get_stars(lua_State *L);
353
354         // set_clouds(self, {density=, color=, ambient=, height=, thickness=, speed=})
355         static int l_set_clouds(lua_State *L);
356
357         // get_clouds(self)
358         static int l_get_clouds(lua_State *L);
359
360         // override_day_night_ratio(self, type)
361         static int l_override_day_night_ratio(lua_State *L);
362
363         // get_day_night_ratio(self)
364         static int l_get_day_night_ratio(lua_State *L);
365
366         // set_local_animation(self, {stand/idle}, {walk}, {dig}, {walk+dig}, frame_speed)
367         static int l_set_local_animation(lua_State *L);
368
369         // get_local_animation(self)
370         static int l_get_local_animation(lua_State *L);
371
372         // set_eye_offset(self, v3f first pv, v3f third pv)
373         static int l_set_eye_offset(lua_State *L);
374
375         // get_eye_offset(self)
376         static int l_get_eye_offset(lua_State *L);
377
378         // set_nametag_attributes(self, attributes)
379         static int l_set_nametag_attributes(lua_State *L);
380
381         // get_nametag_attributes(self)
382         static int l_get_nametag_attributes(lua_State *L);
383
384         // send_mapblock(pos)
385         static int l_send_mapblock(lua_State *L);
386 };