Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
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 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 EmergeThreadgetEmergeThread (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 void registerClass (lua_State *L, const char *name, const luaL_Reg *methods, const luaL_Reg *metamethods)
 
template<typename T >
static T * checkObject (lua_State *L, int narg)
 
static int l_deprecated_function (lua_State *L, const char *good, const char *bad, lua_CFunction func)
 A wrapper for deprecated functions.
 

Static Public Attributes

static const char className [] = "InvRef"
 

Static Private Member Functions

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 luaL_Reg methods []
 

Additional Inherited Members

- Protected Member Functions inherited from LuaHelper
template<>
bool readParam (lua_State *L, int index)
 
template<>
s16 readParam (lua_State *L, int index)
 
template<>
int readParam (lua_State *L, int index)
 
template<>
float readParam (lua_State *L, int index)
 
template<>
v2s16 readParam (lua_State *L, int index)
 
template<>
v2f readParam (lua_State *L, int index)
 
template<>
v3f readParam (lua_State *L, int index)
 
template<>
std::string_view readParam (lua_State *L, int index)
 
template<>
std::string readParam (lua_State *L, int index)
 
template<>
std::string_view readParam (lua_State *L, int index)
 Read a string from Lua state L at index without copying it.
 
- Static Protected Member Functions inherited from LuaHelper
template<typename T >
static T readParam (lua_State *L, int index)
 Read a value using a template type T from Lua state L at index.
 
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 at index.
 

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

◆ create()

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

◆ 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(), ModApiBase::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 ModApiBase::checkObject(), InventoryList::containsItem(), getlist(), ModApiBase::getServer(), NO_MAP_LOCK_REQUIRED, read_item(), and LuaHelper::readParam().

+ Here is the call graph for this function:

◆ l_get_list()

int InvRef::l_get_list ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), getinv(), Inventory::getList(), 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 ModApiBase::checkObject(), getinv(), NO_MAP_LOCK_REQUIRED, and push_inventory_lists().

+ Here is the call graph for this function:

◆ l_get_location()

int InvRef::l_get_location ( lua_State * L)
staticprivate

References ModApiBase::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 ModApiBase::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 ModApiBase::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 ModApiBase::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 ModApiBase::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 ModApiBase::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 ModApiBase::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 ModApiBase::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 ModApiBase::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(), ModApiBase::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(), ModApiBase::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 ModApiBase::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(), methods, and ModApiBase::registerClass().

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"
static

Referenced by 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:18
#define luamethod(class, name)
Definition l_internal.h:16

Referenced by Register().


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