Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
l_nodemeta.h
Go to the documentation of this file.
1// Luanti
2// SPDX-License-Identifier: LGPL-2.1-or-later
3// Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4
5#pragma once
6
7#include "lua_api/l_base.h"
10#include "nodemetadata.h"
11
13class NodeMetadata;
14
15/*
16 NodeMetaRef
17*/
18
19class NodeMetaRef : public MetaDataRef {
20private:
21 bool m_is_local = false;
22 // Set for server metadata
25 // Set for client metadata
27
28 static const luaL_Reg methodsServer[];
29 static const luaL_Reg methodsClient[];
30
44 virtual IMetadata* getmeta(bool auto_create);
45 virtual void clearMeta();
46
47 virtual void reportMetadataChange(const std::string *name = nullptr);
48
49 virtual void handleToTable(lua_State *L, IMetadata *_meta);
50 virtual bool handleFromTable(lua_State *L, int table, IMetadata *_meta);
51
52 // Exported functions
53
54 // get_inventory(self)
55 static int l_get_inventory(lua_State *L);
56
57 // mark_as_private(self, <string> or {<string>, <string>, ...})
58 static int l_mark_as_private(lua_State *L);
59
60public:
63
64 ~NodeMetaRef() = default;
65
66 // Creates an NodeMetaRef and leaves it on top of stack
67 // Not callable from Lua; all references are created on the C side.
68 static void create(lua_State *L, v3s16 p, ServerEnvironment *env);
69
70 // Client-sided version of the above
71 static void createClient(lua_State *L, IMetadata *meta);
72
73 static void Register(lua_State *L);
74 static void RegisterClient(lua_State *L);
75
76 static const char className[];
77};
Definition metadata.h:14
Definition l_metadata.h:18
Definition l_nodemeta.h:19
virtual void reportMetadataChange(const std::string *name=nullptr)
Definition l_nodemeta.cpp:40
static const char className[]
Definition l_nodemeta.h:76
~NodeMetaRef()=default
static void createClient(lua_State *L, IMetadata *meta)
Definition l_nodemeta.cpp:177
static const luaL_Reg methodsClient[]
Definition l_nodemeta.h:218
virtual void handleToTable(lua_State *L, IMetadata *_meta)
Definition l_nodemeta.cpp:106
ServerEnvironment * m_env
Definition l_nodemeta.h:24
bool m_is_local
Definition l_nodemeta.h:21
static int l_mark_as_private(lua_State *L)
Definition l_nodemeta.cpp:78
static int l_get_inventory(lua_State *L)
Definition l_nodemeta.cpp:64
virtual void clearMeta()
Definition l_nodemeta.cpp:34
static void RegisterClient(lua_State *L)
Definition l_nodemeta.cpp:212
static void create(lua_State *L, v3s16 p, ServerEnvironment *env)
Definition l_nodemeta.cpp:168
NodeMetaRef(v3s16 p, ServerEnvironment *env)
Definition l_nodemeta.cpp:154
IMetadata * m_local_meta
Definition l_nodemeta.h:26
virtual IMetadata * getmeta(bool auto_create)
Retrieve metadata for a node.
Definition l_nodemeta.cpp:18
virtual bool handleFromTable(lua_State *L, int table, IMetadata *_meta)
Definition l_nodemeta.cpp:125
static const luaL_Reg methodsServer[]
Definition l_nodemeta.h:193
v3s16 m_p
Definition l_nodemeta.h:23
Definition nodemetadata.h:24
Definition serverenvironment.h:219
core::vector3d< s16 > v3s16
Definition irr_v3d.h:13
static const struct table_key table[]
Definition keycode.cpp:33
static std::string p(std::string path)
Definition test_filesys.cpp:53