]> git.lizzy.rs Git - dragonfireclient.git/blob - src/script/common/c_content.h
Add spider
[dragonfireclient.git] / src / script / common / c_content.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
21 /******************************************************************************/
22 /******************************************************************************/
23 /* WARNING!!!! do NOT add this header in any include file or any code file    */
24 /*             not being a script/modapi file!!!!!!!!                         */
25 /******************************************************************************/
26 /******************************************************************************/
27
28 #pragma once
29
30 extern "C" {
31 #include <lua.h>
32 }
33
34 #include <iostream>
35 #include <vector>
36
37 #include "irrlichttypes_bloated.h"
38 #include "util/string.h"
39 #include "itemgroup.h"
40 #include "itemdef.h"
41 #include "c_types.h"
42 // We do a explicit path include because by default c_content.h include src/client/hud.h
43 // prior to the src/hud.h, which is not good on server only build
44 #include "../../hud.h"
45
46 namespace Json { class Value; }
47
48 struct MapNode;
49 class NodeDefManager;
50 struct PointedThing;
51 struct ItemStack;
52 struct ItemDefinition;
53 struct ToolCapabilities;
54 struct ObjectProperties;
55 struct SimpleSoundSpec;
56 struct ServerSoundParams;
57 class Inventory;
58 struct NodeBox;
59 struct ContentFeatures;
60 struct TileDef;
61 class Server;
62 struct DigParams;
63 struct HitParams;
64 struct EnumString;
65 struct NoiseParams;
66 class Schematic;
67 class ServerActiveObject;
68 struct collisionMoveResult;
69
70 extern struct EnumString es_TileAnimationType[];
71
72 void               read_content_features     (lua_State *L, ContentFeatures &f,
73                                               int index);
74 void               push_content_features     (lua_State *L,
75                                               const ContentFeatures &c);
76
77 void               push_nodebox              (lua_State *L,
78                                               const NodeBox &box);
79 void               push_box                  (lua_State *L,
80                                               const std::vector<aabb3f> &box);
81
82 void               push_palette              (lua_State *L,
83                                               const std::vector<video::SColor> *palette);
84
85 TileDef            read_tiledef              (lua_State *L, int index,
86                                               u8 drawtype);
87
88 void               read_soundspec            (lua_State *L, int index,
89                                               SimpleSoundSpec &spec);
90 NodeBox            read_nodebox              (lua_State *L, int index);
91
92 void               read_server_sound_params  (lua_State *L, int index,
93                                               ServerSoundParams &params);
94
95 void               push_dig_params           (lua_State *L,
96                                               const DigParams &params);
97 void               push_hit_params           (lua_State *L,
98                                               const HitParams &params);
99
100 ItemStack          read_item                 (lua_State *L, int index, IItemDefManager *idef);
101
102 struct TileAnimationParams read_animation_definition(lua_State *L, int index);
103 void push_animation_definition(lua_State *L, struct TileAnimationParams anim);
104
105 ToolCapabilities   read_tool_capabilities    (lua_State *L, int table);
106 void               push_tool_capabilities    (lua_State *L,
107                                               const ToolCapabilities &prop);
108
109 void read_item_definition (lua_State *L, int index, const ItemDefinition &default_def,
110                 ItemDefinition &def);
111 void               push_item_definition      (lua_State *L,
112                                               const ItemDefinition &i);
113 void               push_item_definition_full (lua_State *L,
114                                               const ItemDefinition &i);
115
116 void               read_object_properties    (lua_State *L, int index,
117                                               ServerActiveObject *sao,
118                                               ObjectProperties *prop,
119                                               IItemDefManager *idef);
120 void               push_object_properties    (lua_State *L,
121                                               ObjectProperties *prop);
122
123 void               push_inventory                (lua_State *L,
124                                               Inventory *inventory);
125
126 void               push_inventory_list       (lua_State *L,
127                                               Inventory *inv,
128                                               const char *name);
129 void               read_inventory_list       (lua_State *L, int tableindex,
130                                               Inventory *inv, const char *name,
131                                               Server *srv, int forcesize=-1);
132
133 MapNode            readnode                  (lua_State *L, int index,
134                                               const NodeDefManager *ndef);
135 void               pushnode                  (lua_State *L, const MapNode &n,
136                                               const NodeDefManager *ndef);
137
138
139 void               read_groups               (lua_State *L, int index,
140                                               ItemGroupList &result);
141
142 void               push_groups               (lua_State *L,
143                                               const ItemGroupList &groups);
144
145 //TODO rename to "read_enum_field"
146 int                getenumfield              (lua_State *L, int table,
147                                               const char *fieldname,
148                                               const EnumString *spec,
149                                               int default_);
150
151 bool               getflagsfield             (lua_State *L, int table,
152                                               const char *fieldname,
153                                               FlagDesc *flagdesc,
154                                               u32 *flags, u32 *flagmask);
155
156 bool               read_flags                (lua_State *L, int index,
157                                               FlagDesc *flagdesc,
158                                               u32 *flags, u32 *flagmask);
159
160 void               push_flags_string         (lua_State *L, FlagDesc *flagdesc,
161                                               u32 flags, u32 flagmask);
162
163 u32                read_flags_table          (lua_State *L, int table,
164                                               FlagDesc *flagdesc, u32 *flagmask);
165
166 void               push_items                (lua_State *L,
167                                               const std::vector<ItemStack> &items);
168
169 std::vector<ItemStack> read_items            (lua_State *L,
170                                               int index,
171                                               Server* srv);
172
173 void               push_soundspec            (lua_State *L,
174                                               const SimpleSoundSpec &spec);
175
176 bool               string_to_enum            (const EnumString *spec,
177                                               int &result,
178                                               const std::string &str);
179
180 bool               read_noiseparams          (lua_State *L, int index,
181                                               NoiseParams *np);
182 void               push_noiseparams          (lua_State *L, NoiseParams *np);
183
184 void               luaentity_get             (lua_State *L,u16 id);
185
186 bool               push_json_value           (lua_State *L,
187                                               const Json::Value &value,
188                                               int nullindex);
189 void               read_json_value           (lua_State *L, Json::Value &root,
190                                               int index, u8 recursion = 0);
191
192 /*!
193  * Pushes a Lua `pointed_thing` to the given Lua stack.
194  * \param csm If true, a client side pointed thing is pushed
195  * \param hitpoint If true, the exact pointing location is also pushed
196  */
197 void push_pointed_thing(lua_State *L, const PointedThing &pointed, bool csm =
198         false, bool hitpoint = false);
199
200 void push_objectRef            (lua_State *L, const u16 id);
201
202 void read_hud_element          (lua_State *L, HudElement *elem);
203
204 void push_hud_element          (lua_State *L, HudElement *elem);
205
206 bool read_hud_change           (lua_State *L, HudElementStat &stat, HudElement *elem, void **value);
207
208 void push_collision_move_result(lua_State *L, const collisionMoveResult &res);
209
210 void push_physics_override         (lua_State *L, float speed, float jump, float gravity, bool sneak, bool sneak_glitch, bool new_move);