Item¶
Item metadata helpers for sizing, ownership, persistence, interaction, and world spawning.
Overview
isRotated()View Source
Purpose
Returns whether the item is marked as rotated in its stored data.
Realm
Shared
Returns
boolean `true` when the item is rotated, otherwise `false`.
Example Usage
if item:isRotated() then
print("Item is rotated")
end
getWidth()View Source
Purpose
Returns the item's effective width, accounting for rotation.
Realm
Shared
Returns
number The width used for inventory placement.
Example Usage
local width = item:getWidth()
getHeight()View Source
Purpose
Returns the item's effective height, accounting for rotation.
Realm
Shared
Returns
number The height used for inventory placement.
Example Usage
local height = item:getHeight()
getQuantity()View Source
Purpose
Returns the current quantity for this item instance.
Realm
Shared
Returns
number The item quantity, or `maxQuantity` for non-instanced items.
Example Usage
local quantity = item:getQuantity()
tostring()View Source
Purpose
Builds a debug-friendly string representation of the item.
Realm
Shared
Returns
string A formatted identifier containing the item unique ID and instance ID.
Example Usage
print(item:tostring())
getID()View Source
Purpose
Returns the numeric instance ID of this item.
Realm
Shared
Returns
number The item instance ID.
Example Usage
local id = item:getID()
getModel()View Source
Purpose
Returns the model path assigned to this item.
Realm
Shared
Returns
string The item model path.
Example Usage
local model = item:getModel()
getSkin()View Source
Purpose
Returns the skin index used by this item.
Realm
Shared
Returns
number The configured skin index.
Example Usage
local skin = item:getSkin()
getBodygroups()View Source
Purpose
Returns the bodygroups configured for this item.
Realm
Shared
Returns
table A bodygroup mapping table, or an empty table when unset.
Example Usage
local bodygroups = item:getBodygroups()
getPrice()View Source
Purpose
Returns the price of the item, using `calcPrice` when available.
Realm
Shared
Returns
number The resolved price, or `0` when no price is set.
Example Usage
local price = item:getPrice()
call(method, client, entity)View Source
Purpose
Calls an item method while temporarily setting `self.player` and `self.entity`.
Realm
Shared
Parameters
string method The item method name to invoke.
Player client optional The player context for the call.
Entity entity optional The entity context for the call.
Returns
any Returns whatever values the called method returns.
Example Usage
item:call("onUse", client, entity, extraData)
getOwner()View Source
Purpose
Attempts to find the player that currently owns this item.
Realm
Shared
Returns
Player|nil The owning player when found.
Example Usage
local owner = item:getOwner()
getData(key, default)View Source
getAllData()View Source
Purpose
Returns all stored data for this item, including synced entity data.
Realm
Shared
Returns
table A merged table of item data values.
Example Usage
local data = item:getAllData()
hook(name, func)View Source
postHook(name, func)View Source
onRegistered()View Source
print(detail)View Source
printData()View Source
getName()View Source
Purpose
Returns the configured display name of the item.
Realm
Shared
Returns
string The item name.
Example Usage
local name = item:getName()
getDesc()View Source
Purpose
Returns the configured description of the item.
Realm
Shared
Returns
string The item description.
Example Usage
local desc = item:getDesc()
removeFromInventory(preserveItem)View Source
delete()View Source
Purpose
Deletes the item from runtime state and the database.
Realm
Server
Returns
Deferred A promise chain for the database delete operation.
Example Usage
item:delete()
remove()View Source
Purpose
Removes the item's entity, inventory entry, and database record.
Realm
Server
Returns
Deferred A deferred object that resolves before the delete finishes.
Example Usage
item:remove()
destroy()View Source
onDisposed()View Source
onDisposed()View Source
getEntity()View Source
Purpose
Finds the spawned world entity that belongs to this item instance.
Realm
Server
Returns
Entity|nil The world entity for this item, if one exists.
Example Usage
local ent = item:getEntity()
spawn(position, angles)View Source
Purpose
Spawns this item into the world at a position or for a player.
Realm
Server
Parameters
Vector|table|Player position A world position, encoded position data, or a player drop source.
Angle|Vector|table angles optional Optional angles for the spawned entity.
Returns
Entity|nil The spawned `lia_item` entity when successful.
Example Usage
local ent = item:spawn(client)
transfer(newInventory, bBypass)View Source
onInstanced()View Source
onInstanced()View Source
onSync(recipient)View Source
Purpose
Hook called after the item is synced to one or more clients.
Realm
Server
Parameters
Player|table recipient optional The sync recipient, or `nil` when broadcasted.
Returns
Example Usage
function ITEM:onSync(recipient) end
onSync(recipient)View Source
Purpose
Hook called after the item is synced to one or more clients.
Realm
Server
Parameters
Player|table recipient optional The sync recipient, or `nil` when broadcasted.
Returns
Example Usage
function ITEM:onSync(recipient) end
onRemoved()View Source
onRemoved()View Source
onRestored()View Source
onRestored()View Source
sync(recipient)View Source
Purpose
Syncs this item instance to clients over the network.
Realm
Server
Parameters
Player|table recipient optional The recipient to send to, or `nil` to broadcast.
Returns
Example Usage
item:sync(client)
setData(key, value, receivers, noSave, noCheckEntity)View Source
Purpose
Sets a stored data value, syncs it, and optionally saves it.
Realm
Server
Parameters
string key The data key to set.
any value The value to store.
Player|table receivers optional Optional recipients for the data update net message.
boolean noSave Whether to skip database persistence.
boolean noCheckEntity Whether to skip updating the spawned entity netvars.
Returns
Example Usage
item:setData("durability", 75)
addQuantity(quantity, receivers, noCheckEntity)View Source
Purpose
Increases the item's quantity by the provided amount.
Realm
Server
Parameters
number quantity The amount to add.
Player|table receivers optional Optional recipients for the quantity update.
boolean noCheckEntity Whether to skip updating the spawned entity netvars.
Returns
Example Usage
item:addQuantity(5)
setQuantity(quantity, receivers, noCheckEntity)View Source
Purpose
Sets the item's quantity, syncs it, and saves it.
Realm
Server
Parameters
number quantity The new quantity value.
Player|table receivers optional Optional recipients for the quantity update.
boolean noCheckEntity Whether to skip updating the spawned entity netvars.
Returns
Example Usage
item:setQuantity(10)
interact(action, client, entity, data)View Source
Purpose
Runs an item interaction action for a player.
Realm
Server
Parameters
string action The action identifier to execute.
Player client The player interacting with the item.
Entity entity optional The item world entity involved in the interaction.
any data Additional action-specific payload.
Returns
boolean `true` when the action was handled, otherwise `false`.
Example Usage
item:interact("use", client, entity)
getCategory()View Source
Purpose
Returns the item's category, defaulting to the localized misc category.
Realm
Shared
Returns
string The resolved item category name.
Example Usage
local category = item:getCategory()