Skip to content

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:

PropertyTypeDescription
idnumberUnique item identifier
positionnumberSlot index in the inventory tab
countnumberItem quantity
namestringReadable item name
tab_idnumberTab identifier (see table below)
potentialstable<string>Array of potential names (Equip only, up to 7)
current_star_countnumberCurrent star force level (Equip only)
max_star_countnumberMaximum star force level (Equip only)
remaining_upgrade_countnumberRemaining scroll upgrade slots (Equip only, nRUC)
current_upgrade_countnumberNumber of successful scroll upgrades applied (Equip only, nCUC)
is_deadbooleanWhether the pet is past its expiration date (Pet items only, false for non-pets)
is_activebooleanWhether the pet is currently active/summoned (Pet items only, false for non-pets)

Inventory Tabs

Tab IDNameDescription
1EquipEquipment items (includes potentials and star count)
2UseConsumable items (potions, scrolls, etc.)
3SetupSetup items (chairs, decorations)
4EtcMiscellaneous items (quest items, materials)
5CashCash 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.

lua
local free_slots = core.inventory.get_free_slots(2) -- Use tab
if free_slots < 5 then
    core.log_warning("Low inventory space!")
end

Item 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.

lua
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))
end

core.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.

lua
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.

lua
if core.inventory.can_equip(1302000) then
    core.input.use_item(1302000)
end

core.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.

lua
local delta = core.inventory.get_item_combat_power(1, 5)
if delta and delta > 0 then
    core.log("Upgrade found: +" .. delta)
end

Item 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).

ParameterTypeDescription
tab_idnumberInventory tab (1=Equip, 2=Use, 3=Setup, 4=Etc, 5=Cash)
old_posnumberSource slot position
new_posnumberDestination slot position (0 to drop/discard)
countnumberAmount to move (optional, defaults to 1)
lua
-- 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

lua
-- 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!")
end

Working with Equipment Potentials

lua
-- 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
end

Inventory Space Monitor

lua
-- 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