Luanti 5.10.0-dev
 
Loading...
Searching...
No Matches
LuaItemStack Class Reference

#include <l_item.h>

+ Inheritance diagram for LuaItemStack:
+ Collaboration diagram for LuaItemStack:

Public Member Functions

const ItemStackgetItem () const
 
ItemStackgetItem ()
 
- Public Member Functions inherited from IntrusiveReferenceCounted
 IntrusiveReferenceCounted ()=default
 
virtual ~IntrusiveReferenceCounted ()=default
 
void grab () noexcept
 
void drop () noexcept
 

Static Public Member Functions

static int create_object (lua_State *L)
 
static int create (lua_State *L, const ItemStack &item)
 
static void * packIn (lua_State *L, int idx)
 
static void packOut (lua_State *L, void *ptr)
 
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 [] = "ItemStack"
 

Private Member Functions

 LuaItemStack (const ItemStack &item)
 
 ~LuaItemStack ()=default
 

Static Private Member Functions

static int gc_object (lua_State *L)
 
static int mt_tostring (lua_State *L)
 
static int l_is_empty (lua_State *L)
 
static int l_get_name (lua_State *L)
 
static int l_set_name (lua_State *L)
 
static int l_get_count (lua_State *L)
 
static int l_set_count (lua_State *L)
 
static int l_get_wear (lua_State *L)
 
static int l_set_wear (lua_State *L)
 
static int l_get_meta (lua_State *L)
 
static int l_get_metadata (lua_State *L)
 
static int l_set_metadata (lua_State *L)
 
static int l_get_description (lua_State *L)
 
static int l_get_short_description (lua_State *L)
 
static int l_clear (lua_State *L)
 
static int l_replace (lua_State *L)
 
static int l_to_string (lua_State *L)
 
static int l_to_table (lua_State *L)
 
static int l_get_stack_max (lua_State *L)
 
static int l_get_free_space (lua_State *L)
 
static int l_is_known (lua_State *L)
 
static int l_get_definition (lua_State *L)
 
static int l_get_tool_capabilities (lua_State *L)
 
static int l_add_wear (lua_State *L)
 
static int l_add_wear_by_uses (lua_State *L)
 
static int l_get_wear_bar_params (lua_State *L)
 
static int l_add_item (lua_State *L)
 
static int l_item_fits (lua_State *L)
 
static int l_take_item (lua_State *L)
 
static int l_peek_item (lua_State *L)
 
static int l_equals (lua_State *L)
 

Private Attributes

ItemStack m_stack
 

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

◆ LuaItemStack()

LuaItemStack::LuaItemStack ( const ItemStack & item)
private

Referenced by create(), and create_object().

+ Here is the caller graph for this function:

◆ ~LuaItemStack()

LuaItemStack::~LuaItemStack ( )
privatedefault

Member Function Documentation

◆ create()

◆ create_object()

int LuaItemStack::create_object ( lua_State * L)
static

References LuaItemStack(), className, ModApiBase::getGameDef(), NO_MAP_LOCK_REQUIRED, and read_item().

Referenced by Register().

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

◆ gc_object()

int LuaItemStack::gc_object ( lua_State * L)
staticprivate

References IntrusiveReferenceCounted::drop().

Referenced by Register().

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

◆ getItem() [1/2]

ItemStack & LuaItemStack::getItem ( )
inline

References m_stack.

◆ getItem() [2/2]

const ItemStack & LuaItemStack::getItem ( ) const
inline

References m_stack.

Referenced by ItemStackMetaRef::clearMeta(), ItemStackMetaRef::clearToolCapabilities(), ItemStackMetaRef::clearWearBarParams(), ItemStackMetaRef::getmeta(), packIn(), read_item(), ItemStackMetaRef::setToolCapabilities(), and ItemStackMetaRef::setWearBarParams().

+ Here is the caller graph for this function:

◆ l_add_item()

int LuaItemStack::l_add_item ( lua_State * L)
staticprivate

References ItemStack::addItem(), ModApiBase::checkObject(), create(), ModApiBase::getGameDef(), m_stack, NO_MAP_LOCK_REQUIRED, and read_item().

+ Here is the call graph for this function:

◆ l_add_wear()

int LuaItemStack::l_add_wear ( lua_State * L)
staticprivate

References ItemStack::addWear(), ModApiBase::checkObject(), ModApiBase::getGameDef(), m_stack, and NO_MAP_LOCK_REQUIRED.

+ Here is the call graph for this function:

◆ l_add_wear_by_uses()

int LuaItemStack::l_add_wear_by_uses ( lua_State * L)
staticprivate

References ItemStack::addWear(), calculateResultWear(), ModApiBase::checkObject(), ModApiBase::getGameDef(), m_stack, NO_MAP_LOCK_REQUIRED, LuaHelper::readParam(), and ItemStack::wear.

+ Here is the call graph for this function:

◆ l_clear()

int LuaItemStack::l_clear ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), ItemStack::clear(), m_stack, and NO_MAP_LOCK_REQUIRED.

+ Here is the call graph for this function:

◆ l_equals()

int LuaItemStack::l_equals ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), className, m_stack, and NO_MAP_LOCK_REQUIRED.

Referenced by Register().

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

◆ l_get_count()

int LuaItemStack::l_get_count ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), ItemStack::count, m_stack, and NO_MAP_LOCK_REQUIRED.

+ Here is the call graph for this function:

◆ l_get_definition()

int LuaItemStack::l_get_definition ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), m_stack, ItemStack::name, and NO_MAP_LOCK_REQUIRED.

+ Here is the call graph for this function:

◆ l_get_description()

int LuaItemStack::l_get_description ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), ItemStack::getDescription(), ModApiBase::getGameDef(), m_stack, and NO_MAP_LOCK_REQUIRED.

+ Here is the call graph for this function:

◆ l_get_free_space()

int LuaItemStack::l_get_free_space ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), ItemStack::freeSpace(), ModApiBase::getGameDef(), m_stack, and NO_MAP_LOCK_REQUIRED.

+ Here is the call graph for this function:

◆ l_get_meta()

int LuaItemStack::l_get_meta ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), ItemStackMetaRef::create(), and NO_MAP_LOCK_REQUIRED.

+ Here is the call graph for this function:

◆ l_get_metadata()

int LuaItemStack::l_get_metadata ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), SimpleMetadata::getString(), log_deprecated(), m_stack, ItemStack::metadata, and NO_MAP_LOCK_REQUIRED.

+ Here is the call graph for this function:

◆ l_get_name()

int LuaItemStack::l_get_name ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), m_stack, ItemStack::name, and NO_MAP_LOCK_REQUIRED.

+ Here is the call graph for this function:

◆ l_get_short_description()

int LuaItemStack::l_get_short_description ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), ModApiBase::getGameDef(), ItemStack::getShortDescription(), m_stack, and NO_MAP_LOCK_REQUIRED.

+ Here is the call graph for this function:

◆ l_get_stack_max()

int LuaItemStack::l_get_stack_max ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), ModApiBase::getGameDef(), ItemStack::getStackMax(), m_stack, and NO_MAP_LOCK_REQUIRED.

+ Here is the call graph for this function:

◆ l_get_tool_capabilities()

int LuaItemStack::l_get_tool_capabilities ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), ModApiBase::getGameDef(), ItemStack::getToolCapabilities(), m_stack, NO_MAP_LOCK_REQUIRED, and push_tool_capabilities().

+ Here is the call graph for this function:

◆ l_get_wear()

int LuaItemStack::l_get_wear ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), m_stack, NO_MAP_LOCK_REQUIRED, and ItemStack::wear.

+ Here is the call graph for this function:

◆ l_get_wear_bar_params()

int LuaItemStack::l_get_wear_bar_params ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), ModApiBase::getGameDef(), ItemStack::getWearBarParams(), m_stack, NO_MAP_LOCK_REQUIRED, and push_wear_bar_params().

+ Here is the call graph for this function:

◆ l_is_empty()

int LuaItemStack::l_is_empty ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), ItemStack::empty(), m_stack, and NO_MAP_LOCK_REQUIRED.

+ Here is the call graph for this function:

◆ l_is_known()

int LuaItemStack::l_is_known ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), ModApiBase::getGameDef(), ItemStack::isKnown(), m_stack, and NO_MAP_LOCK_REQUIRED.

+ Here is the call graph for this function:

◆ l_item_fits()

int LuaItemStack::l_item_fits ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), create(), ModApiBase::getGameDef(), ItemStack::itemFits(), m_stack, NO_MAP_LOCK_REQUIRED, and read_item().

+ Here is the call graph for this function:

◆ l_peek_item()

int LuaItemStack::l_peek_item ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), create(), m_stack, NO_MAP_LOCK_REQUIRED, and ItemStack::peekItem().

+ Here is the call graph for this function:

◆ l_replace()

int LuaItemStack::l_replace ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), ModApiBase::getGameDef(), m_stack, NO_MAP_LOCK_REQUIRED, and read_item().

+ Here is the call graph for this function:

◆ l_set_count()

int LuaItemStack::l_set_count ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), ItemStack::clear(), ItemStack::count, m_stack, and NO_MAP_LOCK_REQUIRED.

+ Here is the call graph for this function:

◆ l_set_metadata()

int LuaItemStack::l_set_metadata ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), log_deprecated(), m_stack, ItemStack::metadata, NO_MAP_LOCK_REQUIRED, and ItemStackMetadata::setString().

+ Here is the call graph for this function:

◆ l_set_name()

int LuaItemStack::l_set_name ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), ItemStack::clear(), ItemStack::empty(), m_stack, ItemStack::name, and NO_MAP_LOCK_REQUIRED.

+ Here is the call graph for this function:

◆ l_set_wear()

int LuaItemStack::l_set_wear ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), ItemStack::clear(), m_stack, NO_MAP_LOCK_REQUIRED, and ItemStack::wear.

+ Here is the call graph for this function:

◆ l_take_item()

int LuaItemStack::l_take_item ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), create(), m_stack, NO_MAP_LOCK_REQUIRED, and ItemStack::takeItem().

+ Here is the call graph for this function:

◆ l_to_string()

int LuaItemStack::l_to_string ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), ItemStack::getItemString(), m_stack, and NO_MAP_LOCK_REQUIRED.

+ Here is the call graph for this function:

◆ l_to_table()

int LuaItemStack::l_to_table ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), ItemStack::count, ItemStack::empty(), SimpleMetadata::getString(), SimpleMetadata::getStrings(), m_stack, ItemStack::metadata, ItemStack::name, NO_MAP_LOCK_REQUIRED, and ItemStack::wear.

+ Here is the call graph for this function:

◆ mt_tostring()

int LuaItemStack::mt_tostring ( lua_State * L)
staticprivate

References ModApiBase::checkObject(), ItemStack::getItemString(), and m_stack.

Referenced by Register().

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

◆ packIn()

void * LuaItemStack::packIn ( lua_State * L,
int idx )
static

References ModApiBase::checkObject(), getItem(), and idx.

Referenced by Register().

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

◆ packOut()

void LuaItemStack::packOut ( lua_State * L,
void * ptr )
static

References create().

Referenced by Register().

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

◆ Register()

void LuaItemStack::Register ( lua_State * L)
static

References className, create_object(), gc_object(), l_equals(), methods, mt_tostring(), packIn(), packOut(), ModApiBase::registerClass(), and script_register_packer().

Referenced by ServerScripting::InitializeAsync(), ClientScripting::InitializeModApi(), EmergeScripting::InitializeModApi(), and ServerScripting::InitializeModApi().

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

Member Data Documentation

◆ className

const char LuaItemStack::className = "ItemStack"
static

◆ m_stack

◆ methods

const luaL_Reg LuaItemStack::methods
staticprivate

Referenced by Register().


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