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 /******************************************************************************/
30 #include <unordered_map>
32 #include "irrlichttypes_bloated.h"
33 #include "common/c_types.h"
39 std::string getstringfield_default(lua_State *L, int table,
40 const char *fieldname, const std::string &default_);
41 bool getboolfield_default(lua_State *L, int table,
42 const char *fieldname, bool default_);
43 float getfloatfield_default(lua_State *L, int table,
44 const char *fieldname, float default_);
45 int getintfield_default(lua_State *L, int table,
46 const char *fieldname, int default_);
49 bool getintfield(lua_State *L, int table,
50 const char *fieldname, T &result)
52 lua_getfield(L, table, fieldname);
54 if (lua_isnumber(L, -1)){
55 result = lua_tointeger(L, -1);
63 bool getv3intfield(lua_State *L, int index,
64 const char *fieldname, T &result)
66 lua_getfield(L, index, fieldname);
68 if (lua_istable(L, -1)) {
69 got |= getintfield(L, -1, "x", result.X);
70 got |= getintfield(L, -1, "y", result.Y);
71 got |= getintfield(L, -1, "z", result.Z);
77 v3s16 getv3s16field_default(lua_State *L, int table,
78 const char *fieldname, v3s16 default_);
79 bool getstringfield(lua_State *L, int table,
80 const char *fieldname, std::string &result);
81 size_t getstringlistfield(lua_State *L, int table,
82 const char *fieldname,
83 std::vector<std::string> *result);
84 void read_groups(lua_State *L, int index,
85 std::unordered_map<std::string, int> &result);
86 bool getboolfield(lua_State *L, int table,
87 const char *fieldname, bool &result);
88 bool getfloatfield(lua_State *L, int table,
89 const char *fieldname, float &result);
90 std::string checkstringfield(lua_State *L, int table,
91 const char *fieldname);
93 void setstringfield(lua_State *L, int table,
94 const char *fieldname, const char *value);
95 void setintfield(lua_State *L, int table,
96 const char *fieldname, int value);
97 void setfloatfield(lua_State *L, int table,
98 const char *fieldname, float value);
99 void setboolfield(lua_State *L, int table,
100 const char *fieldname, bool value);
102 v3f checkFloatPos (lua_State *L, int index);
103 v3f check_v3f (lua_State *L, int index);
104 v3s16 check_v3s16 (lua_State *L, int index);
106 v3f read_v3f (lua_State *L, int index);
107 v2f read_v2f (lua_State *L, int index);
108 v2s16 read_v2s16 (lua_State *L, int index);
109 v2s32 read_v2s32 (lua_State *L, int index);
110 video::SColor read_ARGB8 (lua_State *L, int index);
111 bool read_color (lua_State *L, int index,
112 video::SColor *color);
114 aabb3f read_aabb3f (lua_State *L, int index, f32 scale);
115 v3s16 read_v3s16 (lua_State *L, int index);
116 std::vector<aabb3f> read_aabb3f_vector (lua_State *L, int index, f32 scale);
117 size_t read_stringlist (lua_State *L, int index,
118 std::vector<std::string> *result);
120 void push_float_string (lua_State *L, float value);
121 void push_v3_float_string(lua_State *L, v3f p);
122 void push_v2_float_string(lua_State *L, v2f p);
123 void push_v2s16 (lua_State *L, v2s16 p);
124 void push_v2s32 (lua_State *L, v2s32 p);
125 void push_v3s16 (lua_State *L, v3s16 p);
126 void push_aabb3f (lua_State *L, aabb3f box);
127 void push_ARGB8 (lua_State *L, video::SColor color);
128 void pushFloatPos (lua_State *L, v3f p);
129 void push_v3f (lua_State *L, v3f p);
130 void push_v2f (lua_State *L, v2f p);
132 void warn_if_field_exists(lua_State *L, int table,
133 const char *fieldname,
134 const std::string &message);
136 size_t write_array_slice_float(lua_State *L, int table_index, float *data,
137 v3u16 data_size, v3u16 slice_offset, v3u16 slice_size);
138 size_t write_array_slice_u16(lua_State *L, int table_index, u16 *data,
139 v3u16 data_size, v3u16 slice_offset, v3u16 slice_size);