Inventory
Provides access to inventory items and slot information. For item usage, see Input.
Item Object Structure
All item-returning functions provide objects with the following properties:
| Property | Type | Description |
|---|---|---|
id | number | Unique item identifier |
position | number | Slot index in the inventory tab |
count | number | Item quantity |
name | string | Readable item name |
tab_id | number | Tab identifier (see table below) |
potentials | table<string> | Array of potential names (Equip only, up to 7) |
current_star_count | number | Current star force level (Equip only) |
max_star_count | number | Maximum star force level (Equip only) |
remaining_upgrade_count | number | Remaining scroll upgrade slots (Equip only, nRUC) |
current_upgrade_count | number | Number of successful scroll upgrades applied (Equip only, nCUC) |
is_dead | boolean | Whether the pet is past its expiration date (Pet items only, false for non-pets) |
is_active | boolean | Whether the pet is currently active/summoned (Pet items only, false for non-pets) |
Inventory Tabs
| Tab ID | Name | Description |
|---|---|---|
1 | Equip | Equipment items (includes potentials and star count) |
2 | Use | Consumable items (potions, scrolls, etc.) |
3 | Setup | Setup items (chairs, decorations) |
4 | Etc | Miscellaneous items (quest items, materials) |
5 | Cash | Cash shop items |
Functions
Slot Management
core.inventory.get_total_slots(tab_id: number) -> number
Returns total slots in the specified tab.
core.inventory.get_free_slots(tab_id: number) -> number
Returns free slots in the specified tab.
Usage
Always check free slots before looting to avoid inventory overflow.
local free_slots = core.inventory.get_free_slots(2) -- Use tab
if free_slots < 5 then
core.log_warning("Low inventory space!")
endItem Queries
core.inventory.has_item(item_id: number) -> boolean
Returns true if the item exists in any inventory tab.
Performance Note
This is the fastest way to check item existence. Use this before attempting to use items.
Retrieving Items
core.inventory.get_all_items() -> table<item>
Returns all items across all tabs. Equip items include potentials and star count fields.
core.inventory.get_equip_items() -> table<item>
Returns all unequipped equip items in your inventory (tab_id=1) including potentials and star count fields. These are equips sitting in your bag, not currently worn.
core.inventory.get_equipped_items() -> table<item>
Returns all items currently worn by the character. These have negative position values representing equipment slots (e.g. -1 = hat, -5 = top, -7 = shoes, etc.). Includes potentials and star count fields.
local equipped = core.inventory.get_equipped_items()
for _, item in ipairs(equipped) do
core.log(string.format("Slot %d: %s [%d★]",
item.position, item.name, item.current_star_count))
endcore.inventory.get_use_items() -> table<item>
Returns all use items (tab_id=2).
core.inventory.get_etc_items() -> table<item>
Returns all etc items (tab_id=4).
core.inventory.get_setup_items() -> table<item>
Returns all setup items (tab_id=3).
core.inventory.get_cash_items() -> table<item>
Returns all cash items (tab_id=5).
core.inventory.get_required_level(item_id: number) -> number | nil
Returns the required level to equip/use the specified item. Returns nil if item info is unavailable.
local level = core.inventory.get_required_level(1002140)
core.log("Required level: " .. tostring(level))core.inventory.can_equip(item_id: number) -> boolean | nil
Returns true if the current character meets all requirements to equip/use the specified item (level, job, stats, etc.). Returns nil if item info or character context is unavailable.
if core.inventory.can_equip(1302000) then
core.input.use_item(1302000)
endcore.inventory.get_item_combat_power(tab_id: number, position: number) -> number | nil
Returns the estimated combat power change from equipping the item at position in the specified inventory tab. Positive values indicate the item is stronger than the currently equipped item for that slot, negative values indicate it is weaker, and nil is returned if the item or character context is unavailable.
local delta = core.inventory.get_item_combat_power(1, 5)
if delta and delta > 0 then
core.log("Upgrade found: +" .. delta)
endItem Movement
core.inventory.change_slot_position(tab_id: number, old_pos: number, new_pos: number, count?: number)
Sends a request to move an item from one slot position to another within the same inventory tab. Can also be used to equip items by moving them to equipped slots (negative positions).
| Parameter | Type | Description |
|---|---|---|
tab_id | number | Inventory tab (1=Equip, 2=Use, 3=Setup, 4=Etc, 5=Cash) |
old_pos | number | Source slot position |
new_pos | number | Destination slot position (0 to drop/discard) |
count | number | Amount to move (optional, defaults to 1) |
-- Equip an item from equip tab slot 5 to hat slot (-1)
core.inventory.change_slot_position(1, 5, -1)
-- Move a use item from slot 3 to slot 10
core.inventory.change_slot_position(2, 3, 10)
-- Drop 100 etc items from slot 2
core.inventory.change_slot_position(4, 2, 0, 100)Examples
Basic Item Check
-- Check if player has red potions
local RED_POTION = 2000000
if core.inventory.has_item(RED_POTION) then
local free_slots = core.inventory.get_free_slots(2)
core.log("Red potions found. Free use slots: " .. free_slots)
else
core.log_warning("Out of red potions!")
endWorking with Equipment Potentials
-- Find all equipment with potentials
local equips = core.inventory.get_equip_items()
for _, item in ipairs(equips) do
if item.potentials and #item.potentials > 0 then
core.log(item.name .. " [" .. item.current_star_count .. "★]")
for i, potential in ipairs(item.potentials) do
core.log(" Line " .. i .. ": " .. potential)
end
end
endInventory Space Monitor
-- Monitor inventory space across all tabs
local function check_inventory_space()
local tabs = {
{id = 1, name = "Equip"},
{id = 2, name = "Use"},
{id = 3, name = "Etc"},
{id = 4, name = "Setup"},
{id = 5, name = "Cash"}
}
for _, tab in ipairs(tabs) do
local total = core.inventory.get_total_slots(tab.id)
local free = core.inventory.get_free_slots(tab.id)
local used = total - free
local percent = math.floor((used / total) * 100)
local status = percent > 80 and "[!]" or "[OK]"
core.log(string.format("%s %s: %d/%d (%d%%)",
status, tab.name, used, total, percent))
end
end