emptySlots
emptySlots: (Inventory) -> numberFree inventory slots, out of 28.
- Returns
28minus the number of occupied slots.
player:inventory()| Method | Returns | Description |
|---|---|---|
emptySlots() | number | Free inventory slots, out of 28. |
isFull() | boolean | Whether all 28 slots are occupied. |
contains(number) | boolean | Whether any inventory slot holds at least one item of itemId. |
containsName(string) | boolean | Whether the inventory holds an item whose whole name matches, ignoring case: | separates alternatives and * is any run of characters. F… |
itemAmount(number) | number | Total quantity of itemId held, counting stack sizes. |
itemAmountName(string) | number | Total quantity held of every item whose name matches. |
foodAmount(number?) | number | Total quantity of edible food carried that heals at least minHeal at the current Hitpoints level. Noted food is excluded: it still carrie… |
prayerDoses() | number | Total prayer-restore doses carried, doses multiplied by quantity. |
cureAmount() | number | How many carried potions cure poison or venom: items, not doses, so a 4-dose antidote counts 1. |
totalHeal() | number | Hitpoints all the carried food would heal: heal at the current Hitpoints level times bites left, over every stack. Noted food and Hitpoints… |
totalPrayerRestore() | number | Prayer points all the carried potions would restore: points per dose times doses, over every stack. Noted potions do not count. |
search() | ContainerQuery | Open a query over the inventory's items. |
lootingBag() | RememberedItems? | The looting bag's contents as this account last saw them. |
interact(number, string | { string }) | boolean | Interact with the first item of itemId. |
interactName(string, string | { string }) | boolean | Interact with the first item whose whole name matches. |
interactAny({ number }, string | { string }) | boolean | Interact with the first of itemIds that is carried and offers one of options. |
select(number) | boolean | Select an item as the source of a following target action. |
target(number, number?) | boolean | Apply an already-selected source to an inventory item. |
useOnItem(number, number) | boolean | Use one inventory item on another: select, then target, together in one tick. |
useOnNpc(number, NPC | number) | boolean | Use an inventory item on an NPC: select, then target the NPC. |
useOnObject(number, TileObject | number) | boolean | Use an inventory item on a scene object: select, then target it. |
useOnPlayer(number, Player) | boolean | Use an inventory item on a player: select, then use it on the player, together in one tick. |
useOnGroundItem(number, TileItem) | boolean | Use an inventory item on a ground item: select, then use it on that stack (its id and its tile), together in one tick. |
| Method | Returns | Description |
|---|---|---|
PlayerDomain.inventory | Inventory | The 28-slot inventory. |
emptySlotsemptySlots: (Inventory) -> numberFree inventory slots, out of 28.
28 minus the number of occupied slots.isFullisFull: (Inventory) -> booleanWhether all 28 slots are occupied.
containscontains: (Inventory, number) -> booleanWhether any inventory slot holds at least one item of itemId.
itemIdcontainsNamecontainsName: (Inventory, string) -> booleanWhether the inventory holds an item whose whole name matches, ignoring case: | separates alternatives and * is any run of characters. For part of a name, use search():containing(text).
name"Shark|Manta ray" or "Prayer potion(*)".itemAmountitemAmount: (Inventory, number) -> numberTotal quantity of itemId held, counting stack sizes.
itemId0 when the item is absent.itemAmountNameitemAmountName: (Inventory, string) -> numberTotal quantity held of every item whose name matches.
namecontainsName.foodAmountfoodAmount: (Inventory, number?) -> numberTotal quantity of edible food carried that heals at least minHeal at the current Hitpoints level. Noted food is excluded: it still carries heal data but cannot be eaten.
minHealprayerDosesprayerDoses: (Inventory) -> numberTotal prayer-restore doses carried, doses multiplied by quantity.
Noted potions are excluded, for the same reason as foodAmount.
cureAmountcureAmount: (Inventory) -> numberHow many carried potions cure poison or venom: items, not doses, so a 4-dose antidote counts 1.
Exactly the list consumables:curePoison() drinks from, so this counts what that would actually find.
totalHealtotalHeal: (Inventory) -> numberHitpoints all the carried food would heal: heal at the current Hitpoints level times bites left, over every stack. Noted food and Hitpoints-boosting potions (Saradomin brew) do not count.
totalPrayerRestoretotalPrayerRestore: (Inventory) -> numberPrayer points all the carried potions would restore: points per dose times doses, over every stack. Noted potions do not count.
searchsearch: (Inventory) -> ContainerQueryOpen a query over the inventory's items.
ContainerQuery snapshot; see ids, named and first.lootingBaglootingBag: (Inventory) -> RememberedItems?The looting bag's contents as this account last saw them.
nil until the bag has been checked or filled with Bento running. live while its check view or the bank's view of it is open.
interactinteract: (Inventory, number, string | { string }) -> booleanInteract with the first item of itemId.
itemIdoptions"Eat"), or options to try in order; the first the item exposes wins, counting sub-menu options as well as top-level ones.false when the item is absent or no listed option resolves.interactNameinteractName: (Inventory, string, string | { string }) -> booleanInteract with the first item whose whole name matches.
namecontainsName.options"Eat"), or options to try in order.false when no item matches or no listed option resolves.interactAnyinteractAny: (Inventory, { number }, string | { string }) -> booleanInteract with the first of itemIds that is carried and offers one of options.
It takes each id's first slot, and matches option names ignoring case and markup.
itemIdsoptionsselectselect: (Inventory, number) -> booleanSelect an item as the source of a following target action.
Pairs with target: select the source, then target what it is used on. useOnItem, useOnNpc and useOnObject do both halves for you.
itemIdfalse when the item is absent.-- Use a knife on logs: select the source, then target what it is used on.
if inventory:select(KNIFE) then
inventory:target(LOGS)
end
-- The same in one call.
inventory:useOnItem(KNIFE, LOGS)targettarget: (Inventory, number, number?) -> booleanApply an already-selected source to an inventory item.
Uses what this plugin selected (select(id), magic:select(spell)) on the item in that slot when the slot holds itemId, once per selection.
itemIdslotfalse when the item is absent from that slot, or nothing is selected.useOnItemuseOnItem: (Inventory, number, number) -> booleanUse one inventory item on another: select, then target, together in one tick.
useOnItem(a, a) targets a second slot, never the source's own. It takes the first slot holding each id.
sourceItemIdtargetItemIdfalse when either item is absent.useOnNpcuseOnNpc: (Inventory, number, NPC | number) -> booleanUse an inventory item on an NPC: select, then target the NPC.
Takes an NPC (the top level or the boat the player stands in; false for one outside the top level and the boat the player stands in, one that is gone, or once another NPC has taken its index) or an NPC id (the nearest NPC with it); the select and the use together in one tick.
sourceItemIdnpcNPC (the top level or the boat the player stands in), or an NPC id.false when the item is absent or the NPC is gone.useOnObjectuseOnObject: (Inventory, number, TileObject | number) -> booleanUse an inventory item on a scene object: select, then target it.
Takes a TileObject (the top level on the player's plane, or the deck of the boat the player stands in; false for one outside the top level and the boat the player stands in, removed, of a reloaded scene, or under a bridge) or an object id (the nearest object with it); the select and the use together in one tick.
sourceItemIdobjectTileObject (the top level or the boat the player stands in), or an object id.false when the item is absent or the object is gone.useOnPlayeruseOnPlayer: (Inventory, number, Player) -> booleanUse an inventory item on a player: select, then use it on the player, together in one tick.
sourceItemIdplayerPlayer (top-level world view).false when the item is absent, or the player is gone or in another world view.useOnGroundItemuseOnGroundItem: (Inventory, number, TileItem) -> booleanUse an inventory item on a ground item: select, then use it on that stack (its id and its tile), together in one tick.
sourceItemIditemTileItem (the top level or the boat the player stands in).false when the item is absent, or the stack is gone or outside the top level and the boat the player stands in.