Add player:get_meta(), deprecate player attributes (#7202)
[oweals/minetest.git] / src / script / lua_api / l_metadata.h
1 /*
2 Minetest
3 Copyright (C) 2013-8 celeron55, Perttu Ahola <celeron55@gmail.com>
4 Copyright (C) 2017-8 rubenwardy <rw@rubenwardy.com>
5
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU Lesser General Public License as published by
8 the Free Software Foundation; either version 2.1 of the License, or
9 (at your option) any later version.
10
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 GNU Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #pragma once
22
23 #include "irrlichttypes_bloated.h"
24 #include "lua_api/l_base.h"
25
26 class Metadata;
27
28 /*
29         NodeMetaRef
30 */
31
32 class MetaDataRef : public ModApiBase
33 {
34 public:
35         virtual ~MetaDataRef() = default;
36
37 protected:
38         static MetaDataRef *checkobject(lua_State *L, int narg);
39
40         virtual void reportMetadataChange() {}
41         virtual Metadata *getmeta(bool auto_create) = 0;
42         virtual void clearMeta() = 0;
43
44         virtual void handleToTable(lua_State *L, Metadata *meta);
45         virtual bool handleFromTable(lua_State *L, int table, Metadata *meta);
46
47         // Exported functions
48
49         // get_string(self, name)
50         static int l_get_string(lua_State *L);
51
52         // set_string(self, name, var)
53         static int l_set_string(lua_State *L);
54
55         // get_int(self, name)
56         static int l_get_int(lua_State *L);
57
58         // set_int(self, name, var)
59         static int l_set_int(lua_State *L);
60
61         // get_float(self, name)
62         static int l_get_float(lua_State *L);
63
64         // set_float(self, name, var)
65         static int l_set_float(lua_State *L);
66
67         // to_table(self)
68         static int l_to_table(lua_State *L);
69
70         // from_table(self, table)
71         static int l_from_table(lua_State *L);
72
73         // equals(self, other)
74         static int l_equals(lua_State *L);
75 };