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) |
Inventory Tabs
| Tab ID | Name | Description |
|---|---|---|
1 | Equip | Equipment items (includes potentials and star count) |
2 | Use | Consumable items (potions, scrolls, etc.) |
3 | Etc | Miscellaneous items (quest items, materials) |
4 | Setup | Setup items |
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 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
-- 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