ab0083124da31bd629e3b2c465d91a3cf40b3bd9
[oweals/minetest.git] / src / script / common / c_converter.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 #ifndef C_CONVERTER_H_
28 #define C_CONVERTER_H_
29
30 #include <vector>
31 #include <map>
32
33 #include "irrlichttypes_bloated.h"
34 #include "common/c_types.h"
35
36 extern "C" {
37 #include <lua.h>
38 }
39
40 std::string        getstringfield_default        (lua_State *L, int table,
41                              const char *fieldname, const std::string &default_);
42 bool               getboolfield_default(lua_State *L, int table,
43                              const char *fieldname, bool default_);
44 float              getfloatfield_default(lua_State *L, int table,
45                              const char *fieldname, float default_);
46 int                getintfield_default           (lua_State *L, int table,
47                              const char *fieldname, int default_);
48
49 bool               getstringfield(lua_State *L, int table,
50                              const char *fieldname, std::string &result);
51 bool               getintfield(lua_State *L, int table,
52                              const char *fieldname, int &result);
53 void               read_groups                   (lua_State *L, int index,
54                              std::map<std::string, int> &result);
55 bool               getboolfield(lua_State *L, int table,
56                              const char *fieldname, bool &result);
57 bool               getfloatfield(lua_State *L, int table,
58                              const char *fieldname, float &result);
59
60 std::string        checkstringfield(lua_State *L, int table,
61                              const char *fieldname);
62
63 void               setintfield(lua_State *L, int table,
64                              const char *fieldname, int value);
65 void               setfloatfield(lua_State *L, int table,
66                              const char *fieldname, float value);
67 void               setboolfield(lua_State *L, int table,
68                              const char *fieldname, bool value);
69
70
71 v3f           checkFloatPos             (lua_State *L, int index);
72 v3f           check_v3f                 (lua_State *L, int index);
73 v3s16         check_v3s16               (lua_State *L, int index);
74
75 v3f           read_v3f                  (lua_State *L, int index);
76 v2f           read_v2f                  (lua_State *L, int index);
77 v2s16         read_v2s16                (lua_State *L, int index);
78 video::SColor readARGB8                 (lua_State *L, int index);
79 aabb3f        read_aabb3f               (lua_State *L, int index, f32 scale);
80 v3s16         read_v3s16                (lua_State *L, int index);
81 std::vector<aabb3f>
82               read_aabb3f_vector        (lua_State *L, int index, f32 scale);
83
84 void          push_v3s16                (lua_State *L, v3s16 p);
85 void          pushFloatPos              (lua_State *L, v3f p);
86 void          push_v3f                  (lua_State *L, v3f p);
87 void          push_v2f                  (lua_State *L, v2f p);
88
89
90
91 void               warn_if_field_exists      (lua_State *L,
92                                               int table,
93                                               const char *fieldname,
94                                               const std::string &message);
95
96 #endif /* C_CONVERTER_H_ */