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.
22 #include "lua_api/l_base.h"
23 #include "lua_api/l_metadata.h"
24 #include "irrlichttypes_bloated.h"
26 class ServerEnvironment;
33 class NodeMetaRef : public MetaDataRef {
36 ServerEnvironment *m_env;
38 static const char className[];
39 static const luaL_reg methods[];
41 static NodeMetaRef *checkobject(lua_State *L, int narg);
44 * Retrieve metadata for a node.
45 * If @p auto_create is set and the specified node has no metadata information
46 * associated with it yet, the method attempts to attach a new metadata object
47 * to the node and returns a pointer to the metadata when successful.
49 * However, it is NOT guaranteed that the method will return a pointer,
50 * and @c NULL may be returned in case of an error regardless of @p auto_create.
52 * @param ref specifies the node for which the associated metadata is retrieved.
53 * @param auto_create when true, try to create metadata information for the node if it has none.
54 * @return pointer to a @c NodeMetadata object or @c NULL in case of error.
56 virtual Metadata* getmeta(bool auto_create);
57 virtual void clearMeta();
59 virtual void reportMetadataChange();
61 virtual void handleToTable(lua_State *L, Metadata *_meta);
62 virtual bool handleFromTable(lua_State *L, int table, Metadata *_meta);
67 static int gc_object(lua_State *L);
69 // get_inventory(self)
70 static int l_get_inventory(lua_State *L);
73 NodeMetaRef(v3s16 p, ServerEnvironment *env);
77 // Creates an NodeMetaRef and leaves it on top of stack
78 // Not callable from Lua; all references are created on the C side.
79 static void create(lua_State *L, v3s16 p, ServerEnvironment *env);
81 static void Register(lua_State *L);
84 #endif /* L_NODEMETA_H_ */