]> git.lizzy.rs Git - dragonfireclient.git/blob - src/script/lua_api/l_nodemeta.h
Move scriptapi to separate folder (by sapier)
[dragonfireclient.git] / src / script / lua_api / l_nodemeta.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 #ifndef L_NODEMETA_H_
20 #define L_NODEMETA_H_
21
22 extern "C" {
23 #include <lua.h>
24 #include <lauxlib.h>
25 }
26
27 #include "environment.h"
28 #include "nodemetadata.h"
29
30 /*
31         NodeMetaRef
32 */
33
34 class NodeMetaRef
35 {
36 private:
37         v3s16 m_p;
38         ServerEnvironment *m_env;
39
40         static const char className[];
41         static const luaL_reg methods[];
42
43         static NodeMetaRef *checkobject(lua_State *L, int narg);
44
45         static NodeMetadata* getmeta(NodeMetaRef *ref, bool auto_create);
46
47         static void reportMetadataChange(NodeMetaRef *ref);
48
49         // Exported functions
50
51         // garbage collector
52         static int gc_object(lua_State *L);
53
54         // get_string(self, name)
55         static int l_get_string(lua_State *L);
56
57         // set_string(self, name, var)
58         static int l_set_string(lua_State *L);
59
60         // get_int(self, name)
61         static int l_get_int(lua_State *L);
62
63         // set_int(self, name, var)
64         static int l_set_int(lua_State *L);
65
66         // get_float(self, name)
67         static int l_get_float(lua_State *L);
68
69         // set_float(self, name, var)
70         static int l_set_float(lua_State *L);
71
72         // get_inventory(self)
73         static int l_get_inventory(lua_State *L);
74
75         // to_table(self)
76         static int l_to_table(lua_State *L);
77
78         // from_table(self, table)
79         static int l_from_table(lua_State *L);
80
81 public:
82         NodeMetaRef(v3s16 p, ServerEnvironment *env);
83
84         ~NodeMetaRef();
85
86         // Creates an NodeMetaRef and leaves it on top of stack
87         // Not callable from Lua; all references are created on the C side.
88         static void create(lua_State *L, v3s16 p, ServerEnvironment *env);
89
90         static void Register(lua_State *L);
91 };
92
93 #endif //L_NODEMETA_H_