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"
44 namespace Json { class Value; }
50 struct ItemDefinition;
51 struct ToolCapabilities;
52 struct ObjectProperties;
53 struct SimpleSoundSpec;
54 struct ServerSoundParams;
57 struct ContentFeatures;
67 ContentFeatures read_content_features (lua_State *L, int index);
68 void push_content_features (lua_State *L,
69 const ContentFeatures &c);
71 void push_nodebox (lua_State *L,
73 void push_box (lua_State *L,
74 const std::vector<aabb3f> &box);
76 void push_palette (lua_State *L,
77 const std::vector<video::SColor> *palette);
79 TileDef read_tiledef (lua_State *L, int index,
82 void read_soundspec (lua_State *L, int index,
83 SimpleSoundSpec &spec);
84 NodeBox read_nodebox (lua_State *L, int index);
86 void read_server_sound_params (lua_State *L, int index,
87 ServerSoundParams ¶ms);
89 void push_dig_params (lua_State *L,
90 const DigParams ¶ms);
91 void push_hit_params (lua_State *L,
92 const HitParams ¶ms);
94 ItemStack read_item (lua_State *L, int index, IItemDefManager *idef);
96 struct TileAnimationParams read_animation_definition(lua_State *L, int index);
98 ToolCapabilities read_tool_capabilities (lua_State *L, int table);
99 void push_tool_capabilities (lua_State *L,
100 const ToolCapabilities &prop);
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);
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);
115 void push_inventory_list (lua_State *L,
118 void read_inventory_list (lua_State *L, int tableindex,
119 Inventory *inv, const char *name,
120 Server *srv, int forcesize=-1);
122 MapNode readnode (lua_State *L, int index,
123 const NodeDefManager *ndef);
124 void pushnode (lua_State *L, const MapNode &n,
125 const NodeDefManager *ndef);
128 void read_groups (lua_State *L, int index,
129 ItemGroupList &result);
131 void push_groups (lua_State *L,
132 const ItemGroupList &groups);
134 //TODO rename to "read_enum_field"
135 int getenumfield (lua_State *L, int table,
136 const char *fieldname,
137 const EnumString *spec,
140 bool getflagsfield (lua_State *L, int table,
141 const char *fieldname,
143 u32 *flags, u32 *flagmask);
145 bool read_flags (lua_State *L, int index,
147 u32 *flags, u32 *flagmask);
149 void push_flags_string (lua_State *L, FlagDesc *flagdesc,
150 u32 flags, u32 flagmask);
152 u32 read_flags_table (lua_State *L, int table,
153 FlagDesc *flagdesc, u32 *flagmask);
155 void push_items (lua_State *L,
156 const std::vector<ItemStack> &items);
158 std::vector<ItemStack> read_items (lua_State *L,
162 void push_soundspec (lua_State *L,
163 const SimpleSoundSpec &spec);
165 bool string_to_enum (const EnumString *spec,
167 const std::string &str);
169 bool read_noiseparams (lua_State *L, int index,
171 void push_noiseparams (lua_State *L, NoiseParams *np);
173 void luaentity_get (lua_State *L,u16 id);
175 bool push_json_value (lua_State *L,
176 const Json::Value &value,
178 void read_json_value (lua_State *L, Json::Value &root,
179 int index, u8 recursion = 0);
182 * Pushes a Lua `pointed_thing` to the given Lua stack.
183 * \param csm If true, a client side pointed thing is pushed
184 * \param hitpoint If true, the exact pointing location is also pushed
186 void push_pointed_thing(lua_State *L, const PointedThing &pointed, bool csm =
187 false, bool hitpoint = false);
189 void push_objectRef (lua_State *L, const u16 id);
191 void read_hud_element (lua_State *L, HudElement *elem);
193 void push_hud_element (lua_State *L, HudElement *elem);
195 HudElementStat read_hud_change (lua_State *L, HudElement *elem, void **value);
197 extern struct EnumString es_TileAnimationType[];