Skip to content

Container

A Container represents an open screen handler session. Returned by inv:open(player, title?).

Metatable name: "container"

type: Player

The player who opened the container. Read-only.

type: Inventory

The backing inventory. Read-only.

Force-closes the container.

container:close()

Registers a click callback and auto-locks the inventory.

  • callback (function or nil) — Click handler, or nil to remove callback and unlock

Callback receives:

ArgumentTypeDescription
playerPlayerPlayer who clicked
slotnumberSlot index (-1 = outside window)
clickTypestringClick type (see below)
slotItemItemStack or nilItem in the clicked slot
cursorItemItemStack or nilItem on cursor

Return false from the callback to cancel the click.

clickType values: "pickup", "quick_move", "swap", "throw", "quick_craft", "pickup_all".

container:onClick(function(player, slot, clickType, slotItem, cursorItem)
if slot == 0 then return false end
end)
container:onClick(nil) -- remove callback and unlock

When onClick(fn) is registered, the inventory is automatically locked:

PxIgnus uses 0-based slot indexing in inv:getItem, inv:setItem, container:onClick callbacks, and chestgui:button. The exception is chestgui:set(row, col, item, callback) which uses 1-based (row, col) for human-readable coordinates (rows 1–6, columns 1–9).

When onClick(fn) is registered, the inventory is automatically locked:

  • removeStack() returns empty (blocks hoppers/take)
  • clear() is a no-op
  • setStack() still works (Lua modifications bypass via unlocked {})

Calling onClick(nil) unlocks the inventory, restoring normal item movement. This prevents item theft when callbacks are active but fail to process (reload, crash).