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)

Inventory Tabs

Tab IDNameDescription
1EquipEquipment items (includes potentials and star count)
2UseConsumable items (potions, scrolls, etc.)
3EtcMiscellaneous items (quest items, materials)
4SetupSetup items
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 equip items (tab_id=1) including potentials and star count fields.


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=3).


core.inventory.get_setup_items() -> table<item>

Returns all setup items (tab_id=4).


core.inventory.get_cash_items() -> table<item>

Returns all cash items (tab_id=5).

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