Merge remote branch 'origin/master'
[oweals/minetest.git] / src / scriptapi_types.h
1 /*
2 Minetest-c55
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 #ifndef LUA_TYPES_H_
21 #define LUA_TYPES_H_
22
23 #include <iostream>
24 #include <map>
25 #include <vector>
26
27 #include "irrlichttypes_bloated.h"
28 #include "porting.h"
29 #include "map.h"
30
31 extern "C" {
32 #include <lua.h>
33 }
34
35 std::string        getstringfield_default        (lua_State *L, int table,
36                              const char *fieldname, const std::string &default_);
37 bool               getboolfield_default(lua_State *L, int table,
38                              const char *fieldname, bool default_);
39 float              getfloatfield_default(lua_State *L, int table,
40                              const char *fieldname, float default_);
41 int                getintfield_default           (lua_State *L, int table,
42                              const char *fieldname, int default_);
43
44 bool               getstringfield(lua_State *L, int table,
45                              const char *fieldname, std::string &result);
46 bool               getintfield(lua_State *L, int table,
47                              const char *fieldname, int &result);
48 void               read_groups                   (lua_State *L, int index,
49                              std::map<std::string, int> &result);
50 bool               getboolfield(lua_State *L, int table,
51                              const char *fieldname, bool &result);
52 bool               getfloatfield(lua_State *L, int table,
53                              const char *fieldname, float &result);
54 u32                getflagsfield(lua_State *L, int table,
55                              const char *fieldname, FlagDesc *flagdesc);
56
57 std::string        checkstringfield(lua_State *L, int table,
58                              const char *fieldname);
59
60 void               setintfield(lua_State *L, int table,
61                              const char *fieldname, int value);
62 void               setfloatfield(lua_State *L, int table,
63                              const char *fieldname, float value);
64 void               setboolfield(lua_State *L, int table,
65                              const char *fieldname, bool value);
66
67
68 v3f           checkFloatPos                 (lua_State *L, int index);
69 v3f           check_v3f                     (lua_State *L, int index);
70 v3s16         check_v3s16                   (lua_State *L, int index);
71
72 v3f           read_v3f                      (lua_State *L, int index);
73 v2f           read_v2f                      (lua_State *L, int index);
74 v2s16         read_v2s16                    (lua_State *L, int index);
75 video::SColor readARGB8                     (lua_State *L, int index);
76 aabb3f        read_aabb3f                   (lua_State *L, int index, f32 scale);
77 v3s16         read_v3s16                    (lua_State *L, int index);
78 std::vector<aabb3f>
79               read_aabb3f_vector            (lua_State *L, int index, f32 scale);
80
81 void          push_v3s16                    (lua_State *L, v3s16 p);
82 void          pushFloatPos                  (lua_State *L, v3f p);
83 void          push_v3f                      (lua_State *L, v3f p);
84
85
86 MapNode readnode(lua_State *L, int index, INodeDefManager *ndef);
87 void pushnode(lua_State *L, const MapNode &n, INodeDefManager *ndef);
88
89 #endif /* LUA_TYPES_H_ */