]> git.lizzy.rs Git - dragonfireclient.git/blob - src/script/common/c_content.h
9b87962971dee5b732992efdca1d2b505e803a9e
[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 #ifndef C_CONTENT_H_
29 #define C_CONTENT_H_
30
31 extern "C" {
32 #include <lua.h>
33 }
34
35 #include <iostream>
36 #include <vector>
37
38 #include "irrlichttypes_bloated.h"
39 #include "util/string.h"
40 #include "itemgroup.h"
41 #include "itemdef.h"
42 #include "c_types.h"
43
44 namespace Json { class Value; }
45
46 struct MapNode;
47 class INodeDefManager;
48 struct PointedThing;
49 struct ItemStack;
50 struct ItemDefinition;
51 struct ToolCapabilities;
52 struct ObjectProperties;
53 struct SimpleSoundSpec;
54 struct ServerSoundParams;
55 class Inventory;
56 struct NodeBox;
57 struct ContentFeatures;
58 struct TileDef;
59 class Server;
60 struct DigParams;
61 struct HitParams;
62 struct EnumString;
63 struct NoiseParams;
64 class Schematic;
65
66
67 ContentFeatures    read_content_features     (lua_State *L, int index);
68 void               push_content_features     (lua_State *L,
69                                               const ContentFeatures &c);
70
71 void               push_nodebox              (lua_State *L,
72                                               const NodeBox &box);
73 void               push_box                  (lua_State *L,
74                                               const std::vector<aabb3f> &box);
75
76 void               push_palette              (lua_State *L,
77                                               const std::vector<video::SColor> *palette);
78
79 TileDef            read_tiledef              (lua_State *L, int index,
80                                               u8 drawtype);
81
82 void               read_soundspec            (lua_State *L, int index,
83                                               SimpleSoundSpec &spec);
84 NodeBox            read_nodebox              (lua_State *L, int index);
85
86 void               read_server_sound_params  (lua_State *L, int index,
87                                               ServerSoundParams &params);
88
89 void               push_dig_params           (lua_State *L,
90                                               const DigParams &params);
91 void               push_hit_params           (lua_State *L,
92                                               const HitParams &params);
93
94 ItemStack          read_item                 (lua_State *L, int index, IItemDefManager *idef);
95
96 struct TileAnimationParams read_animation_definition(lua_State *L, int index);
97
98 ToolCapabilities   read_tool_capabilities    (lua_State *L, int table);
99 void               push_tool_capabilities    (lua_State *L,
100                                               const ToolCapabilities &prop);
101
102 void read_item_definition (lua_State *L, int index, const ItemDefinition &default_def,
103                 ItemDefinition &def);
104 void               push_item_definition      (lua_State *L,
105                                               const ItemDefinition &i);
106 void               push_item_definition_full (lua_State *L,
107                                               const ItemDefinition &i);
108
109 void               read_object_properties    (lua_State *L, int index,
110                                               ObjectProperties *prop,
111                                               IItemDefManager *idef);
112 void               push_object_properties    (lua_State *L,
113                                               ObjectProperties *prop);
114
115 void               push_inventory_list       (lua_State *L,
116                                               Inventory *inv,
117                                               const char *name);
118 void               read_inventory_list       (lua_State *L, int tableindex,
119                                               Inventory *inv, const char *name,
120                                               Server *srv, int forcesize=-1);
121
122 MapNode            readnode                  (lua_State *L, int index,
123                                               INodeDefManager *ndef);
124 void               pushnode                  (lua_State *L, const MapNode &n,
125                                               INodeDefManager *ndef);
126
127 NodeBox            read_nodebox              (lua_State *L, int index);
128
129 void               read_groups               (lua_State *L, int index,
130                                               ItemGroupList &result);
131
132 void               push_groups               (lua_State *L,
133                                               const ItemGroupList &groups);
134
135 //TODO rename to "read_enum_field"
136 int                getenumfield              (lua_State *L, int table,
137                                               const char *fieldname,
138                                               const EnumString *spec,
139                                               int default_);
140
141 bool               getflagsfield             (lua_State *L, int table,
142                                               const char *fieldname,
143                                               FlagDesc *flagdesc,
144                                               u32 *flags, u32 *flagmask);
145
146 bool               read_flags                (lua_State *L, int index,
147                                               FlagDesc *flagdesc,
148                                               u32 *flags, u32 *flagmask);
149
150 void               push_flags_string         (lua_State *L, FlagDesc *flagdesc,
151                                               u32 flags, u32 flagmask);
152
153 u32                read_flags_table          (lua_State *L, int table,
154                                               FlagDesc *flagdesc, u32 *flagmask);
155
156 void               push_items                (lua_State *L,
157                                               const std::vector<ItemStack> &items);
158
159 std::vector<ItemStack> read_items            (lua_State *L,
160                                               int index,
161                                               Server* srv);
162
163 void               read_soundspec            (lua_State *L,
164                                               int index,
165                                               SimpleSoundSpec &spec);
166 void               push_soundspec            (lua_State *L,
167                                               const SimpleSoundSpec &spec);
168
169 bool               string_to_enum            (const EnumString *spec,
170                                               int &result,
171                                               const std::string &str);
172
173 bool               read_noiseparams          (lua_State *L, int index,
174                                               NoiseParams *np);
175 void               push_noiseparams          (lua_State *L, NoiseParams *np);
176
177 void               luaentity_get             (lua_State *L,u16 id);
178
179 bool               push_json_value           (lua_State *L,
180                                               const Json::Value &value,
181                                               int nullindex);
182 void               read_json_value           (lua_State *L, Json::Value &root,
183                                               int index, u8 recursion = 0);
184
185 void               push_pointed_thing        (lua_State *L, const PointedThing &pointed, bool csm = false);
186
187 void               push_objectRef            (lua_State *L, const u16 id);
188
189 extern struct EnumString es_TileAnimationType[];
190
191 #endif /* C_CONTENT_H_ */