Container
A Container represents an open screen handler session. Returned by
inv:open(player, title?).
Metatable name: "container"
Properties
Section titled “Properties”container.player
Section titled “container.player”type: Player
The player who opened the container. Read-only.
container.inventory
Section titled “container.inventory”type: Inventory
The backing inventory. Read-only.
Methods
Section titled “Methods”container:close()
Section titled “container:close()”Force-closes the container.
container:close()container:onClick(callback)
Section titled “container:onClick(callback)”Registers a click callback and auto-locks the inventory.
callback(functionornil) — Click handler, ornilto remove callback and unlock
Callback receives:
| Argument | Type | Description |
|---|---|---|
player | Player | Player who clicked |
slot | number | Slot index (-1 = outside window) |
clickType | string | Click type (see below) |
slotItem | ItemStack or nil | Item in the clicked slot |
cursorItem | ItemStack or nil | Item 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 endend)container:onClick(nil) -- remove callback and unlockWhen onClick(fn) is registered, the inventory is automatically locked:
Slot indexing
Section titled “Slot indexing”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).
Auto-Locking
Section titled “Auto-Locking”When onClick(fn) is registered, the inventory is automatically locked:
removeStack()returns empty (blocks hoppers/take)clear()is a no-opsetStack()still works (Lua modifications bypass viaunlocked {})
Calling onClick(nil) unlocks the inventory, restoring normal item movement. This
prevents item theft when callbacks are active but fail to process (reload, crash).