Minetest  5.4.0
NodeMetaRef Class Reference

#include <l_nodemeta.h>

+ Inheritance diagram for NodeMetaRef:
+ Collaboration diagram for NodeMetaRef:

Public Member Functions

 NodeMetaRef (v3s16 p, ServerEnvironment *env)
 
 NodeMetaRef (Metadata *meta)
 
 ~NodeMetaRef ()=default
 
- Public Member Functions inherited from MetaDataRef
virtual ~MetaDataRef ()=default
 

Static Public Member Functions

static void create (lua_State *L, v3s16 p, ServerEnvironment *env)
 
static void createClient (lua_State *L, Metadata *meta)
 
static void RegisterCommon (lua_State *L)
 
static void Register (lua_State *L)
 
static void RegisterClient (lua_State *L)
 
- Static Public Member Functions inherited from ModApiBase
static ScriptApiBasegetScriptApiBase (lua_State *L)
 
static ServergetServer (lua_State *L)
 
static ServerInventoryManagergetServerInventoryMgr (lua_State *L)
 
static ClientgetClient (lua_State *L)
 
static GUIEnginegetGuiEngine (lua_State *L)
 
static IGameDefgetGameDef (lua_State *L)
 
static EnvironmentgetEnv (lua_State *L)
 
static std::string getCurrentModPath (lua_State *L)
 
template<typename T >
static T * getScriptApi (lua_State *L)
 
static bool registerFunction (lua_State *L, const char *name, lua_CFunction func, int top)
 
static int l_deprecated_function (lua_State *L, const char *good, const char *bad, lua_CFunction func)
 A wrapper for deprecated functions. More...
 

Private Member Functions

virtual Metadatagetmeta (bool auto_create)
 Retrieve metadata for a node. More...
 
virtual void clearMeta ()
 
virtual void reportMetadataChange (const std::string *name=nullptr)
 
virtual void handleToTable (lua_State *L, Metadata *_meta)
 
virtual bool handleFromTable (lua_State *L, int table, Metadata *_meta)
 

Static Private Member Functions

static NodeMetaRefcheckobject (lua_State *L, int narg)
 
static int gc_object (lua_State *L)
 
static int l_get_inventory (lua_State *L)
 
static int l_mark_as_private (lua_State *L)
 

Private Attributes

v3s16 m_p
 
ServerEnvironmentm_env = nullptr
 
Metadatam_meta = nullptr
 
bool m_is_local = false
 

Static Private Attributes

static const char className [] = "NodeMetaRef"
 
static const luaL_Reg methodsServer []
 
static const luaL_Reg methodsClient []
 

Additional Inherited Members

- Protected Member Functions inherited from LuaHelper
template<>
bool readParam (lua_State *L, int index)
 
- Static Protected Member Functions inherited from MetaDataRef
static MetaDataRefcheckobject (lua_State *L, int narg)
 
static int l_contains (lua_State *L)
 
static int l_get (lua_State *L)
 
static int l_get_string (lua_State *L)
 
static int l_set_string (lua_State *L)
 
static int l_get_int (lua_State *L)
 
static int l_set_int (lua_State *L)
 
static int l_get_float (lua_State *L)
 
static int l_set_float (lua_State *L)
 
static int l_to_table (lua_State *L)
 
static int l_from_table (lua_State *L)
 
static int l_equals (lua_State *L)
 
- Static Protected Member Functions inherited from LuaHelper
static bool isNaN (lua_State *L, int idx)
 
template<typename T >
static T readParam (lua_State *L, int index)
 Read a value using a template type T from Lua State L and index. More...
 
template<typename T >
static T readParam (lua_State *L, int index, const T &default_value)
 Read a value using a template type T from Lua State L and index. More...
 

Constructor & Destructor Documentation

◆ NodeMetaRef() [1/2]

NodeMetaRef::NodeMetaRef ( v3s16  p,
ServerEnvironment env 
)

Referenced by create(), and createClient().

+ Here is the caller graph for this function:

◆ NodeMetaRef() [2/2]

NodeMetaRef::NodeMetaRef ( Metadata meta)

◆ ~NodeMetaRef()

NodeMetaRef::~NodeMetaRef ( )
default

Member Function Documentation

◆ checkobject()

NodeMetaRef * NodeMetaRef::checkobject ( lua_State *  L,
int  narg 
)
staticprivate

References className.

Referenced by l_get_inventory(), and l_mark_as_private().

+ Here is the caller graph for this function:

◆ clearMeta()

void NodeMetaRef::clearMeta ( )
privatevirtual

Implements MetaDataRef.

References ServerEnvironment::getMap(), m_env, m_is_local, m_p, Map::removeNodeMetadata(), and SANITY_CHECK.

+ Here is the call graph for this function:

◆ create()

void NodeMetaRef::create ( lua_State *  L,
v3s16  p,
ServerEnvironment env 
)
static

References NodeMetaRef(), className, and p().

Referenced by ModApiEnvMod::l_get_meta().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ createClient()

void NodeMetaRef::createClient ( lua_State *  L,
Metadata meta 
)
static

References NodeMetaRef(), and className.

Referenced by ModApiClient::l_get_meta().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ gc_object()

int NodeMetaRef::gc_object ( lua_State *  L)
staticprivate

Referenced by RegisterCommon().

+ Here is the caller graph for this function:

◆ getmeta()

Metadata * NodeMetaRef::getmeta ( bool  auto_create)
privatevirtual

Retrieve metadata for a node.

If auto_create is set and the specified node has no metadata information associated with it yet, the method attempts to attach a new metadata object to the node and returns a pointer to the metadata when successful.

However, it is NOT guaranteed that the method will return a pointer, and NULL may be returned in case of an error regardless of auto_create.

Parameters
refspecifies the node for which the associated metadata is retrieved.
auto_createwhen true, try to create metadata information for the node if it has none.
Returns
pointer to a NodeMetadata object or NULL in case of error.

Implements MetaDataRef.

References ServerEnvironment::getGameDef(), ServerEnvironment::getMap(), Map::getNodeMetadata(), IGameDef::idef(), m_env, m_is_local, m_meta, m_p, and Map::setNodeMetadata().

Referenced by l_get_inventory(), and l_mark_as_private().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleFromTable()

bool NodeMetaRef::handleFromTable ( lua_State *  L,
int  table,
Metadata _meta 
)
privatevirtual

Reimplemented from MetaDataRef.

References NodeMetadata::getInventory(), ModApiBase::getServer(), MetaDataRef::handleFromTable(), read_inventory_list(), and table.

+ Here is the call graph for this function:

◆ handleToTable()

void NodeMetaRef::handleToTable ( lua_State *  L,
Metadata _meta 
)
privatevirtual

Reimplemented from MetaDataRef.

References NodeMetadata::getInventory(), Inventory::getLists(), MetaDataRef::handleToTable(), and push_inventory_list().

+ Here is the call graph for this function:

◆ l_get_inventory()

int NodeMetaRef::l_get_inventory ( lua_State *  L)
staticprivate

References checkobject(), InvRef::createNodeMeta(), getmeta(), m_p, and MAP_LOCK_REQUIRED.

+ Here is the call graph for this function:

◆ l_mark_as_private()

int NodeMetaRef::l_mark_as_private ( lua_State *  L)
staticprivate

References checkobject(), getmeta(), MAP_LOCK_REQUIRED, NodeMetadata::markPrivate(), and reportMetadataChange().

+ Here is the call graph for this function:

◆ Register()

void NodeMetaRef::Register ( lua_State *  L)
static

References methodsServer, and RegisterCommon().

Referenced by ServerScripting::InitializeModApi().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RegisterClient()

void NodeMetaRef::RegisterClient ( lua_State *  L)
static

References methodsClient, and RegisterCommon().

Referenced by ClientScripting::InitializeModApi().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ RegisterCommon()

void NodeMetaRef::RegisterCommon ( lua_State *  L)
static

References className, gc_object(), and MetaDataRef::l_equals().

Referenced by Register(), and RegisterClient().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reportMetadataChange()

void NodeMetaRef::reportMetadataChange ( const std::string *  name = nullptr)
privatevirtual

Reimplemented from MetaDataRef.

References Map::dispatchEvent(), ServerEnvironment::getMap(), NodeMetadata::isPrivate(), m_env, m_is_local, m_meta, m_p, MEET_BLOCK_NODE_METADATA_CHANGED, SANITY_CHECK, and MapEditEvent::type.

Referenced by l_mark_as_private().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ className

const char NodeMetaRef::className = "NodeMetaRef"
staticprivate

◆ m_env

ServerEnvironment* NodeMetaRef::m_env = nullptr
private

◆ m_is_local

bool NodeMetaRef::m_is_local = false
private

◆ m_meta

Metadata* NodeMetaRef::m_meta = nullptr
private

Referenced by getmeta(), and reportMetadataChange().

◆ m_p

v3s16 NodeMetaRef::m_p
private

◆ methodsClient

const luaL_Reg NodeMetaRef::methodsClient
staticprivate
Initial value:
= {
luamethod(MetaDataRef, contains),
luamethod(MetaDataRef, get_string),
luamethod(MetaDataRef, get_float),
luamethod(MetaDataRef, to_table),
{0,0}
}
Definition: l_metadata.h:33
#define luamethod(class, name)
Definition: l_internal.h:31

Referenced by RegisterClient().

◆ methodsServer

const luaL_Reg NodeMetaRef::methodsServer
staticprivate
Initial value:
= {
luamethod(MetaDataRef, contains),
luamethod(MetaDataRef, get_string),
luamethod(MetaDataRef, set_string),
luamethod(MetaDataRef, get_float),
luamethod(MetaDataRef, set_float),
luamethod(MetaDataRef, to_table),
luamethod(MetaDataRef, from_table),
luamethod(NodeMetaRef, get_inventory),
luamethod(NodeMetaRef, mark_as_private),
{0,0}
}
Definition: l_nodemeta.h:34

Referenced by Register().


The documentation for this class was generated from the following files: