Minetest  5.4.0
InvRef Class Reference

#include <l_inventory.h>

+ Inheritance diagram for InvRef:
+ Collaboration diagram for InvRef:

Public Member Functions

 InvRef (const InventoryLocation &loc)
 
 ~InvRef ()=default
 

Static Public Member Functions

static void create (lua_State *L, const InventoryLocation &loc)
 
static void createPlayer (lua_State *L, RemotePlayer *player)
 
static void createNodeMeta (lua_State *L, v3s16 p)
 
static void Register (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...
 

Static Private Member Functions

static InvRefcheckobject (lua_State *L, int narg)
 
static Inventorygetinv (lua_State *L, InvRef *ref)
 
static InventoryListgetlist (lua_State *L, InvRef *ref, const char *listname)
 
static void reportInventoryChange (lua_State *L, InvRef *ref)
 
static int gc_object (lua_State *L)
 
static int l_is_empty (lua_State *L)
 
static int l_get_size (lua_State *L)
 
static int l_get_width (lua_State *L)
 
static int l_set_size (lua_State *L)
 
static int l_set_width (lua_State *L)
 
static int l_get_stack (lua_State *L)
 
static int l_set_stack (lua_State *L)
 
static int l_get_list (lua_State *L)
 
static int l_set_list (lua_State *L)
 
static int l_get_lists (lua_State *L)
 
static int l_set_lists (lua_State *L)
 
static int l_add_item (lua_State *L)
 
static int l_room_for_item (lua_State *L)
 
static int l_contains_item (lua_State *L)
 
static int l_remove_item (lua_State *L)
 
static int l_get_location (lua_State *L)
 

Private Attributes

InventoryLocation m_loc
 

Static Private Attributes

static const char className [] = "InvRef"
 
static const luaL_Reg methods []
 

Additional Inherited Members

- Protected Member Functions inherited from LuaHelper
template<>
bool readParam (lua_State *L, int index)
 
- 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

◆ InvRef()

InvRef::InvRef ( const InventoryLocation loc)

Referenced by create().

+ Here is the caller graph for this function:

◆ ~InvRef()

InvRef::~InvRef ( )
default

Member Function Documentation

◆ checkobject()

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

References className.

Referenced by l_add_item(), l_contains_item(), l_get_list(), l_get_lists(), l_get_location(), l_get_size(), l_get_stack(), l_get_width(), l_is_empty(), l_remove_item(), l_room_for_item(), l_set_list(), l_set_lists(), l_set_size(), l_set_stack(), and l_set_width().

+ Here is the caller graph for this function:

◆ create()

void InvRef::create ( lua_State *  L,
const InventoryLocation loc 
)
static

◆ createNodeMeta()

void InvRef::createNodeMeta ( lua_State *  L,
v3s16  p 
)
static

References create(), p(), and InventoryLocation::setNodeMeta().

Referenced by NodeMetaRef::l_get_inventory().

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

◆ createPlayer()

void InvRef::createPlayer ( lua_State *  L,
RemotePlayer player 
)
static

References create(), Player::getName(), NO_MAP_LOCK_REQUIRED, and InventoryLocation::setPlayer().

+ Here is the call graph for this function:

◆ gc_object()

int InvRef::gc_object ( lua_State *  L)
staticprivate

Referenced by Register().

+ Here is the caller graph for this function:

◆ getinv()

Inventory * InvRef::getinv ( lua_State *  L,
InvRef ref 
)
staticprivate

References ServerInventoryManager::getInventory(), ModApiBase::getServerInventoryMgr(), and m_loc.

Referenced by getlist(), l_get_list(), l_get_lists(), l_set_list(), l_set_lists(), l_set_size(), and l_set_width().

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

◆ getlist()

InventoryList * InvRef::getlist ( lua_State *  L,
InvRef ref,
const char *  listname 
)
staticprivate

References getinv(), Inventory::getList(), and NO_MAP_LOCK_REQUIRED.

Referenced by l_add_item(), l_contains_item(), l_get_size(), l_get_stack(), l_get_width(), l_is_empty(), l_remove_item(), l_room_for_item(), and l_set_stack().

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

◆ l_add_item()

int InvRef::l_add_item ( lua_State *  L)
staticprivate

References InventoryList::addItem(), checkobject(), ItemStack::count, LuaItemStack::create(), getlist(), ModApiBase::getServer(), NO_MAP_LOCK_REQUIRED, read_item(), and reportInventoryChange().

+ Here is the call graph for this function:

◆ l_contains_item()

int InvRef::l_contains_item ( lua_State *  L)
staticprivate

References checkobject(), InventoryList::containsItem(), getlist(), ModApiBase::getServer(), NO_MAP_LOCK_REQUIRED, and read_item().

+ Here is the call graph for this function:

◆ l_get_list()

int InvRef::l_get_list ( lua_State *  L)
staticprivate

References checkobject(), getinv(), NO_MAP_LOCK_REQUIRED, and push_inventory_list().

+ Here is the call graph for this function:

◆ l_get_lists()

int InvRef::l_get_lists ( lua_State *  L)
staticprivate

References checkobject(), getinv(), Inventory::getLists(), NO_MAP_LOCK_REQUIRED, and push_inventory_list().

+ Here is the call graph for this function:

◆ l_get_location()

int InvRef::l_get_location ( lua_State *  L)
staticprivate

References checkobject(), InventoryLocation::CURRENT_PLAYER, InventoryLocation::DETACHED, m_loc, InventoryLocation::name, NO_MAP_LOCK_REQUIRED, InventoryLocation::NODEMETA, InventoryLocation::p, InventoryLocation::PLAYER, push_v3s16(), InventoryLocation::type, and InventoryLocation::UNDEFINED.

+ Here is the call graph for this function:

◆ l_get_size()

int InvRef::l_get_size ( lua_State *  L)
staticprivate

References checkobject(), getlist(), InventoryList::getSize(), and NO_MAP_LOCK_REQUIRED.

+ Here is the call graph for this function:

◆ l_get_stack()

int InvRef::l_get_stack ( lua_State *  L)
staticprivate

References checkobject(), LuaItemStack::create(), InventoryList::getItem(), getlist(), InventoryList::getSize(), and NO_MAP_LOCK_REQUIRED.

+ Here is the call graph for this function:

◆ l_get_width()

int InvRef::l_get_width ( lua_State *  L)
staticprivate

References checkobject(), getlist(), InventoryList::getWidth(), and NO_MAP_LOCK_REQUIRED.

+ Here is the call graph for this function:

◆ l_is_empty()

int InvRef::l_is_empty ( lua_State *  L)
staticprivate

References checkobject(), getlist(), InventoryList::getUsedSlots(), and NO_MAP_LOCK_REQUIRED.

+ Here is the call graph for this function:

◆ l_remove_item()

int InvRef::l_remove_item ( lua_State *  L)
staticprivate

References checkobject(), LuaItemStack::create(), ItemStack::empty(), getlist(), ModApiBase::getServer(), NO_MAP_LOCK_REQUIRED, read_item(), InventoryList::removeItem(), and reportInventoryChange().

+ Here is the call graph for this function:

◆ l_room_for_item()

int InvRef::l_room_for_item ( lua_State *  L)
staticprivate

References checkobject(), getlist(), ModApiBase::getServer(), NO_MAP_LOCK_REQUIRED, read_item(), and InventoryList::roomForItem().

+ Here is the call graph for this function:

◆ l_set_list()

int InvRef::l_set_list ( lua_State *  L)
staticprivate

References checkobject(), getinv(), Inventory::getList(), ModApiBase::getServer(), InventoryList::getSize(), NO_MAP_LOCK_REQUIRED, read_inventory_list(), and reportInventoryChange().

+ Here is the call graph for this function:

◆ l_set_lists()

int InvRef::l_set_lists ( lua_State *  L)
staticprivate

References checkobject(), Inventory::clear(), getinv(), ModApiBase::getServer(), NO_MAP_LOCK_REQUIRED, and read_inventory_list().

+ Here is the call graph for this function:

◆ l_set_size()

int InvRef::l_set_size ( lua_State *  L)
staticprivate

References Inventory::addList(), checkobject(), Inventory::deleteList(), getinv(), Inventory::getList(), NO_MAP_LOCK_REQUIRED, reportInventoryChange(), and InventoryList::setSize().

+ Here is the call graph for this function:

◆ l_set_stack()

int InvRef::l_set_stack ( lua_State *  L)
staticprivate

References InventoryList::changeItem(), checkobject(), getlist(), ModApiBase::getServer(), InventoryList::getSize(), NO_MAP_LOCK_REQUIRED, read_item(), and reportInventoryChange().

+ Here is the call graph for this function:

◆ l_set_width()

int InvRef::l_set_width ( lua_State *  L)
staticprivate

References checkobject(), getinv(), Inventory::getList(), NO_MAP_LOCK_REQUIRED, reportInventoryChange(), and InventoryList::setWidth().

+ Here is the call graph for this function:

◆ Register()

void InvRef::Register ( lua_State *  L)
static

References className, gc_object(), and methods.

Referenced by ServerScripting::InitializeModApi().

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

◆ reportInventoryChange()

void InvRef::reportInventoryChange ( lua_State *  L,
InvRef ref 
)
staticprivate

References ModApiBase::getServerInventoryMgr(), m_loc, and ServerInventoryManager::setInventoryModified().

Referenced by l_add_item(), l_remove_item(), l_set_list(), l_set_size(), l_set_stack(), and l_set_width().

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

Member Data Documentation

◆ className

const char InvRef::className = "InvRef"
staticprivate

Referenced by checkobject(), create(), and Register().

◆ m_loc

InventoryLocation InvRef::m_loc
private

◆ methods

const luaL_Reg InvRef::methods
staticprivate
Initial value:
= {
luamethod(InvRef, is_empty),
luamethod(InvRef, get_size),
luamethod(InvRef, set_size),
luamethod(InvRef, get_width),
luamethod(InvRef, set_width),
luamethod(InvRef, get_stack),
luamethod(InvRef, set_stack),
luamethod(InvRef, get_list),
luamethod(InvRef, set_list),
luamethod(InvRef, get_lists),
luamethod(InvRef, set_lists),
luamethod(InvRef, add_item),
luamethod(InvRef, room_for_item),
luamethod(InvRef, contains_item),
luamethod(InvRef, remove_item),
luamethod(InvRef, get_location),
{0,0}
}
Definition: l_inventory.h:33
#define luamethod(class, name)
Definition: l_internal.h:31

Referenced by Register().


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