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