DirkScripts
Docs
Server
#lib.inventory.useableItem
Register an item as useable with a callback.
lualib.inventory.useableItem('bandage', function(source, item) print(source, 'used', item.name) end)
| Parameter | Type | Required | Description |
|---|---|---|---|
| itemName | string | yes | Item name |
| cb | function | yes | Callback function(source, item) |
| item | table | no | Item data override |
#lib.inventory.canUseItem
Check if an item has a registered use handler.
lualocal canUse = lib.inventory.canUseItem('bandage')
#lib.inventory.addItem
Add an item to an inventory.
lualocal success = lib.inventory.addItem(invId, itemName, count, metadata, slot)
| Parameter | Type | Required | Description |
|---|---|---|---|
| invId | number | string | yes | Player source or stash ID |
| itemName | string | yes | Item name |
| count | number | no | Amount (default 1) |
| metadata | table | no | Item metadata |
| slot | number | no | Target slot |
#lib.inventory.removeItem
Remove an item from an inventory.
lualocal success = lib.inventory.removeItem(invId, itemName, count, metadata, slot)
Parameters match addItem.
#lib.inventory.hasItem
Check if an inventory has an item.
lualocal has = lib.inventory.hasItem(invId, itemName, count, metadata, slot)
#lib.inventory.getItems
Get all items in an inventory.
lualocal items = lib.inventory.getItems(invId)
#lib.inventory.getItemBySlot
Get the item in a specific slot.
lualocal item = lib.inventory.getItemBySlot(invId, slot)
#lib.inventory.getItemByName
Find an item by name in an inventory.
lualocal item = lib.inventory.getItemByName(invId, itemName)
#lib.inventory.getItemByMetadata
Find an item by metadata match.
lualocal item = lib.inventory.getItemByMetadata(invId, metadata)
#lib.inventory.getItemLabel
Get the display label for an item.
lualocal label = lib.inventory.getItemLabel(item)
#lib.inventory.item
Get the full definition of an item.
lualocal itemData = lib.inventory.item(item)
#lib.inventory.canCarryItem
Check if an inventory can hold an item.
lualocal canCarry = lib.inventory.canCarryItem(invId, itemName, count, metadata)
#lib.inventory.get
Get an inventory object.
lualocal inv = lib.inventory.get(invId)
#lib.inventory.clearInventory
Clear all items from an inventory.
lualib.inventory.clearInventory(invId)
#lib.inventory.registerStash
Register a stash inventory.
lualib.inventory.registerStash(invId, data)
| Parameter | Type | Required | Description |
|---|---|---|---|
| invId | string | yes | Stash identifier |
| data | table | yes | Stash options (slots, maxWeight, etc.) |
#lib.inventory.editMetadata
Edit item metadata. Optionally merge instead of replace.
lualib.inventory.editMetadata(itemName, metadata, combine)
| Parameter | Type | Required | Description |
|---|---|---|---|
| itemName | string | yes | Item name |
| metadata | table | yes | New metadata |
| combine | boolean | no | Merge with existing metadata instead of replacing |
#lib.inventory.setMetadata
Set metadata for a specific inventory slot.
lualib.inventory.setMetadata(invId, slot, metadata)
