3 Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
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.
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.
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.
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 /******************************************************************************/
37 #include "irrlichttypes_bloated.h"
38 #include "util/string.h"
39 #include "itemgroup.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"
46 namespace Json { class Value; }
52 struct ItemDefinition;
53 struct ToolCapabilities;
54 struct ObjectProperties;
55 struct SimpleSoundSpec;
56 struct ServerSoundParams;
60 struct ContentFeatures;
68 class ServerActiveObject;
69 struct collisionMoveResult;
71 extern struct EnumString es_TileAnimationType[];
73 void read_content_features (lua_State *L, ContentFeatures &f,
75 void push_content_features (lua_State *L,
76 const ContentFeatures &c);
78 void push_nodebox (lua_State *L,
80 void push_box (lua_State *L,
81 const std::vector<aabb3f> &box);
83 void push_palette (lua_State *L,
84 const std::vector<video::SColor> *palette);
86 TileDef read_tiledef (lua_State *L, int index,
89 void read_soundspec (lua_State *L, int index,
90 SimpleSoundSpec &spec);
91 NodeBox read_nodebox (lua_State *L, int index);
93 void read_server_sound_params (lua_State *L, int index,
94 ServerSoundParams ¶ms);
96 void push_dig_params (lua_State *L,
97 const DigParams ¶ms);
98 void push_hit_params (lua_State *L,
99 const HitParams ¶ms);
101 ItemStack read_item (lua_State *L, int index, IItemDefManager *idef);
103 struct TileAnimationParams read_animation_definition(lua_State *L, int index);
105 ToolCapabilities read_tool_capabilities (lua_State *L, int table);
106 void push_tool_capabilities (lua_State *L,
107 const ToolCapabilities &prop);
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);
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);
123 void push_inventory_list (lua_State *L,
124 const InventoryList &invlist);
125 void push_inventory_lists (lua_State *L,
126 const Inventory &inv);
127 void read_inventory_list (lua_State *L, int tableindex,
128 Inventory *inv, const char *name,
129 IGameDef *gdef, int forcesize=-1);
131 MapNode readnode (lua_State *L, int index,
132 const NodeDefManager *ndef);
133 void pushnode (lua_State *L, const MapNode &n,
134 const NodeDefManager *ndef);
137 void read_groups (lua_State *L, int index,
138 ItemGroupList &result);
140 void push_groups (lua_State *L,
141 const ItemGroupList &groups);
143 //TODO rename to "read_enum_field"
144 int getenumfield (lua_State *L, int table,
145 const char *fieldname,
146 const EnumString *spec,
149 bool getflagsfield (lua_State *L, int table,
150 const char *fieldname,
152 u32 *flags, u32 *flagmask);
154 bool read_flags (lua_State *L, int index,
156 u32 *flags, u32 *flagmask);
158 void push_flags_string (lua_State *L, FlagDesc *flagdesc,
159 u32 flags, u32 flagmask);
161 u32 read_flags_table (lua_State *L, int table,
162 FlagDesc *flagdesc, u32 *flagmask);
164 void push_items (lua_State *L,
165 const std::vector<ItemStack> &items);
167 std::vector<ItemStack> read_items (lua_State *L,
171 void push_soundspec (lua_State *L,
172 const SimpleSoundSpec &spec);
174 bool string_to_enum (const EnumString *spec,
176 const std::string &str);
178 bool read_noiseparams (lua_State *L, int index,
180 void push_noiseparams (lua_State *L, NoiseParams *np);
182 void luaentity_get (lua_State *L,u16 id);
184 bool push_json_value (lua_State *L,
185 const Json::Value &value,
187 void read_json_value (lua_State *L, Json::Value &root,
188 int index, u8 recursion = 0);
191 * Pushes a Lua `pointed_thing` to the given Lua stack.
192 * \param csm If true, a client side pointed thing is pushed
193 * \param hitpoint If true, the exact pointing location is also pushed
195 void push_pointed_thing(lua_State *L, const PointedThing &pointed, bool csm =
196 false, bool hitpoint = false);
198 void push_objectRef (lua_State *L, const u16 id);
200 void read_hud_element (lua_State *L, HudElement *elem);
202 void push_hud_element (lua_State *L, HudElement *elem);
204 bool read_hud_change (lua_State *L, HudElementStat &stat, HudElement *elem, void **value);
206 void push_collision_move_result(lua_State *L, const collisionMoveResult &res);