Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
l_playermeta.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// Copyright (C) 2017-8 rubenwardy <rw@rubenwardy.com>
5
6#pragma once
7
8#include "lua_api/l_base.h"
11#include "inventory.h"
12
14
16{
17private:
19 std::string m_name;
20
21 static const luaL_Reg methods[];
22
23 virtual IMetadata *getmeta(bool auto_create);
24
25 virtual void clearMeta();
26
27 virtual void reportMetadataChange(const std::string *name = nullptr);
28
29public:
30 PlayerMetaRef(ServerEnvironment *env, std::string_view name) :
31 m_env(env), m_name(name)
32 {
33 assert(m_env);
34 assert(!m_name.empty());
35 }
36 ~PlayerMetaRef() = default;
37
38 // Creates an PlayerMetaRef and leaves it on top of stack
39 // Not callable from Lua; all references are created on the C side.
40 static void create(lua_State *L, ServerEnvironment *env, std::string_view name);
41
42 static void Register(lua_State *L);
43
44 static const char className[];
45};
Definition metadata.h:14
Definition l_metadata.h:18
Definition l_playermeta.h:16
PlayerMetaRef(ServerEnvironment *env, std::string_view name)
Definition l_playermeta.h:30
static void create(lua_State *L, ServerEnvironment *env, std::string_view name)
Definition l_playermeta.cpp:37
virtual void clearMeta()
Definition l_playermeta.cpp:24
virtual void reportMetadataChange(const std::string *name=nullptr)
Definition l_playermeta.cpp:30
std::string m_name
Definition l_playermeta.h:19
ServerEnvironment * m_env
Definition l_playermeta.h:18
static const char className[]
Definition l_playermeta.h:44
~PlayerMetaRef()=default
virtual IMetadata * getmeta(bool auto_create)
Definition l_playermeta.cpp:17
static const luaL_Reg methods[]
Definition l_playermeta.h:51
Definition serverenvironment.h:219