lia.item
Item manipulation and helper functions.
If you are looking for the item structure, you can find it in the wiki under items.
Functions
createInv(w, h, id)
Creates a new inventory instance.
Parameters
-
w
Integer
The width of the inventory.
-
h
Integer
The height of the inventory.
-
id
Integer
The ID of the inventory.
Returns
-
any
tab The new inventory instance.
deleteByID(id)
Deletes an item by its ID.
Parameters
-
id
Integer
The ID of the item.
get(identifier)
Retrieves an item table.
Parameters
-
identifier
String
Unique ID of the item
Returns
-
item
Item table
Example Usage
print(lia.item.get("example"))
> "item[example][0]"
getInstancedItemByID(itemID)
Retrieves an instanced item by its ID.
Parameters
-
itemID
Integer
The ID of the item instance.
Returns
-
any
tab The item instance.
getInv(invID)
Retrieves an inventory by its ID.
Parameters
-
invID
Integer
The ID of the inventory.
Returns
-
any
tab The inventory object.
getItemByID(itemID)
Retrieves an item instance by its ID and determines its location.
Parameters
-
itemID
Integer
The ID of the item instance.
Returns
-
any
tab The item instance along with its location.
getItemDataByID(itemID)
Retrieves an item's data by its ID.
Parameters
-
itemID
Integer
The ID of the item instance.
Returns
-
any
tab The item's data.
instance(index, uniqueID, itemData, x, y, callback)
Instantiates an item and adds it to an inventory.
Parameters
-
index
Integer
- The inventory index or unique ID.
-
uniqueID
String
- The unique ID of the item or item data.
-
itemData
Table
The item data.
-
x
Integer
The x-coordinate.
-
y
Integer
The y-coordinate.
-
callback
Function
The callback function.
Returns
-
any
tab A deferred promise.
isItem(object)
Checks if an object is an item.
Parameters
-
object
Table
The object to check.
Returns
-
any
Whether the object is an item.
load(path, baseID, isBaseItem)
Loads an item from a Lua file.
Parameters
-
path
String
The path to the Lua file.
-
baseID
String
The base ID of the item.
-
isBaseItem
Boolean
Whether the item is a base item.
loadFromDir(directory)
Loads items from a directory.
Parameters
-
directory
String
The directory path.
loadItemByID(itemIndex)
Loads an item by its ID.
Parameters
-
itemIndex
The item index or array of indices.
new(uniqueID, id)
Creates a new item instance.
Parameters
-
uniqueID
String
The unique ID of the item.
-
id
Integer
The ID of the item.
Returns
-
any
tab The new item instance.
newInv(owner, invType, callback)
Creates a new inventory.
Parameters
-
owner
Integer
The owner of the inventory.
-
invType
String
The inventory type.
-
callback
Function
The callback function.
register(uniqueID, baseID, isBaseItem, path, luaGenerated)
Registers a new item.
Parameters
-
uniqueID
String
The unique ID of the item.
-
baseID
String
The base ID of the item.
-
isBaseItem
Boolean
Indicates if the item is a base item.
-
path
String
The file path of the item.
-
luaGenerated
Boolean
Indicates if the item is Lua-generated.
Returns
-
any
tab The registered item.
registerInv(invType, w, h)
Registers a new inventory type.
Parameters
-
invType
String
The inventory type.
-
w
Integer
The width of the inventory.
-
h
Integer
The height of the inventory.
restoreInv(invID, w, h, callback)
Restores an inventory with the specified dimensions.
Parameters
-
invID
Integer
The inventory ID.
-
w
Integer
The width of the inventory.
-
h
Integer
The height of the inventory.
-
callback
Function
The callback function.
setItemDataByID(itemID, key, value, receivers, noSave, noCheckEntity)
Sets the data of an item by its ID.
Parameters
-
itemID
Integer
The ID of the item instance.
-
key
String
The data key to set.
-
value
The value to set for the data key.
-
receivers
Table
Optional table of receivers for network updates.
-
noSave
Boolean
Optional flag to skip database saving.
-
noCheckEntity
Boolean
Optional flag to skip entity checks.
Returns
-
any
boolean Success status.
spawn(uniqueID, position, callback, angles, data)
Instances and spawns a given item type.
Parameters
-
uniqueID
String
Unique ID of the item
-
position
Vector
The position in which the item's entity will be spawned
-
callback
Function
default: nil
Function to call when the item entity is created
-
angles
Angle
default: angle_zero
The angles at which the item's entity will spawn
-
data
Table
default: nil
Additional data for this item instance