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
"
8
#include "
lua_api/l_metadata.h
"
9
#include "
irrlichttypes_bloated.h
"
10
#include "
nodemetadata.h
"
11
12
class
ServerEnvironment
;
13
class
NodeMetadata
;
14
15
/*
16
NodeMetaRef
17
*/
18
19
class
NodeMetaRef
:
public
MetaDataRef
{
20
private
:
21
bool
m_is_local
=
false
;
22
// Set for server metadata
23
v3s16
m_p
;
24
ServerEnvironment
*
m_env
=
nullptr
;
25
// Set for client metadata
26
IMetadata
*
m_local_meta
=
nullptr
;
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
60
public
:
61
NodeMetaRef
(
v3s16
p
,
ServerEnvironment
*env);
62
NodeMetaRef
(
IMetadata
*meta);
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
};
IMetadata
Definition
metadata.h:14
MetaDataRef
Definition
l_metadata.h:18
NodeMetaRef
Definition
l_nodemeta.h:19
NodeMetaRef::reportMetadataChange
virtual void reportMetadataChange(const std::string *name=nullptr)
Definition
l_nodemeta.cpp:40
NodeMetaRef::className
static const char className[]
Definition
l_nodemeta.h:76
NodeMetaRef::~NodeMetaRef
~NodeMetaRef()=default
NodeMetaRef::createClient
static void createClient(lua_State *L, IMetadata *meta)
Definition
l_nodemeta.cpp:177
NodeMetaRef::methodsClient
static const luaL_Reg methodsClient[]
Definition
l_nodemeta.h:218
NodeMetaRef::handleToTable
virtual void handleToTable(lua_State *L, IMetadata *_meta)
Definition
l_nodemeta.cpp:106
NodeMetaRef::m_env
ServerEnvironment * m_env
Definition
l_nodemeta.h:24
NodeMetaRef::m_is_local
bool m_is_local
Definition
l_nodemeta.h:21
NodeMetaRef::l_mark_as_private
static int l_mark_as_private(lua_State *L)
Definition
l_nodemeta.cpp:78
NodeMetaRef::l_get_inventory
static int l_get_inventory(lua_State *L)
Definition
l_nodemeta.cpp:64
NodeMetaRef::clearMeta
virtual void clearMeta()
Definition
l_nodemeta.cpp:34
NodeMetaRef::RegisterClient
static void RegisterClient(lua_State *L)
Definition
l_nodemeta.cpp:212
NodeMetaRef::create
static void create(lua_State *L, v3s16 p, ServerEnvironment *env)
Definition
l_nodemeta.cpp:168
NodeMetaRef::NodeMetaRef
NodeMetaRef(v3s16 p, ServerEnvironment *env)
Definition
l_nodemeta.cpp:154
NodeMetaRef::m_local_meta
IMetadata * m_local_meta
Definition
l_nodemeta.h:26
NodeMetaRef::getmeta
virtual IMetadata * getmeta(bool auto_create)
Retrieve metadata for a node.
Definition
l_nodemeta.cpp:18
NodeMetaRef::handleFromTable
virtual bool handleFromTable(lua_State *L, int table, IMetadata *_meta)
Definition
l_nodemeta.cpp:125
NodeMetaRef::methodsServer
static const luaL_Reg methodsServer[]
Definition
l_nodemeta.h:193
NodeMetaRef::m_p
v3s16 m_p
Definition
l_nodemeta.h:23
NodeMetadata
Definition
nodemetadata.h:24
ServerEnvironment
Definition
serverenvironment.h:219
ELoginRegister::Register
@ Register
v3s16
core::vector3d< s16 > v3s16
Definition
irr_v3d.h:13
irrlichttypes_bloated.h
table
static const struct table_key table[]
Definition
keycode.cpp:33
l_base.h
l_metadata.h
nodemetadata.h
p
static std::string p(std::string path)
Definition
test_filesys.cpp:53
script
lua_api
l_nodemeta.h
Generated on Fri Nov 1 2024 10:49:00 for Luanti by
1.11.0