Skip to content

Item

Item metadata helpers for sizing, ownership, persistence, interaction, and world spawning.


Overview

The item meta table wraps a registered or instanced item and exposes helpers for dimensions, quantity, pricing, ownership lookup, item data access, interaction hooks, networking, inventory transfer, persistence, and server-side entity spawning and cleanup.

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

Purpose

Returns a stored data value for this item.

Realm

Shared

Parameters

string key The data key to look up.

any default The fallback value to return when the key is missing.

Returns

any The stored value or the provided default.

Example Usage

  local durability = item:getData("durability", 100)

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

Purpose

Registers a pre-action hook for an item interaction function.

Realm

Shared

Parameters

string name The interaction name to hook.

function func The function to run before the default action logic.

Returns

Example Usage

  item:hook("drop", function(self, data) end)

postHook(name, func)View Source

Purpose

Registers a post-action hook for an item interaction function.

Realm

Shared

Parameters

string name The interaction name to hook.

function func The function to run after the action completes.

Returns

Example Usage

  item:postHook("drop", function(self, result, data) end)

onRegistered()View Source

Purpose

Runs when the item is registered and precaches its model when present.

Realm

Shared

Returns

Example Usage

  item:onRegistered()

print(detail)View Source

Purpose

Prints item information to the framework log output.

Realm

Shared

Parameters

boolean detail Whether to include ownership and grid position details.

Returns

Example Usage

  item:print(true)

printData()View Source

Purpose

Prints the item and each of its stored data entries.

Realm

Shared

Returns

Example Usage

  item:printData()

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

Purpose

Removes the item from its current inventory.

Realm

Server

Parameters

boolean preserveItem Whether the inventory should preserve the item instance after removal.

Returns

Deferred A deferred object that resolves when removal completes.

Example Usage

  item:removeFromInventory()

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

Purpose

Disposes of the item instance from synced runtime storage.

Realm

Server

Returns

Example Usage

  item:destroy()

onDisposed()View Source

Purpose

Hook called after the item is disposed from runtime storage.

Realm

Server

Returns

Example Usage

  function ITEM:onDisposed() end

onDisposed()View Source

Purpose

Hook called after the item is disposed from runtime storage.

Realm

Server

Returns

Example Usage

  function ITEM:onDisposed() end

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

Purpose

Transfers the item into another inventory.

Realm

Server

Parameters

Inventory newInventory The destination inventory.

boolean bBypass Whether to bypass transfer access checks.

Returns

boolean `true` when the transfer is started, otherwise `false`.

Example Usage

  item:transfer(targetInventory)

onInstanced()View Source

Purpose

Hook called when an item instance is first created.

Realm

Server

Returns

Example Usage

  function ITEM:onInstanced() end

onInstanced()View Source

Purpose

Hook called when an item instance is first created.

Realm

Server

Returns

Example Usage

  function ITEM:onInstanced() 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

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

Purpose

Hook called after the item is removed from persistent storage.

Realm

Server

Returns

Example Usage

  function ITEM:onRemoved() end

onRemoved()View Source

Purpose

Hook called after the item is removed from persistent storage.

Realm

Server

Returns

Example Usage

  function ITEM:onRemoved() end

onRestored()View Source

Purpose

Hook called after an item is restored from persistent storage.

Realm

Server

Returns

Example Usage

  function ITEM:onRestored() end

onRestored()View Source

Purpose

Hook called after an item is restored from persistent storage.

Realm

Server

Returns

Example Usage

  function ITEM:onRestored() end

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()