Minetest 5.9.0-dev
 
Loading...
Searching...
No Matches
l_playermeta.h
Go to the documentation of this file.
1/*
2Minetest
3Copyright (C) 2013 celeron55, Perttu Ahola <celeron55@gmail.com>
4Copyright (C) 2017-8 rubenwardy <rw@rubenwardy.com>
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU Lesser General Public License as published by
8the Free Software Foundation; either version 2.1 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU Lesser General Public License for more details.
15
16You should have received a copy of the GNU Lesser General Public License along
17with this program; if not, write to the Free Software Foundation, Inc.,
1851 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19*/
20
21#pragma once
22
23#include "lua_api/l_base.h"
24#include "lua_api/l_metadata.h"
26#include "inventory.h"
27#include "metadata.h"
28
30{
31private:
32 IMetadata *metadata = nullptr;
33
34 static const luaL_Reg methods[];
35
36 virtual IMetadata *getmeta(bool auto_create);
37
38 virtual void clearMeta();
39
40 virtual void reportMetadataChange(const std::string *name = nullptr);
41
42public:
44 ~PlayerMetaRef() = default;
45
46 // Creates an ItemStackMetaRef and leaves it on top of stack
47 // Not callable from Lua; all references are created on the C side.
48 static void create(lua_State *L, IMetadata *metadata);
49
50 static void Register(lua_State *L);
51
52 static const char className[];
53};
Definition: metadata.h:29
Definition: l_metadata.h:33
Definition: l_playermeta.h:30
static void create(lua_State *L, IMetadata *metadata)
Definition: l_playermeta.cpp:46
virtual void clearMeta()
Definition: l_playermeta.cpp:34
IMetadata * metadata
Definition: l_playermeta.h:32
virtual void reportMetadataChange(const std::string *name=nullptr)
Definition: l_playermeta.cpp:39
static const char className[]
Definition: l_playermeta.h:52
~PlayerMetaRef()=default
virtual IMetadata * getmeta(bool auto_create)
Definition: l_playermeta.cpp:29
PlayerMetaRef(IMetadata *metadata)
Definition: l_playermeta.h:43
static const luaL_Reg methods[]
Definition: l_playermeta.h:34