Inventory

Methods to interact with the inventory.


Inventory.GetSlotBoxes

function TRSInventory.GetSlotBoxes(): TBoxArray;

Mainly used internally by TRSInventory methods. This function is used to return a TBoxArray of the inventory slots.

Example:

Debug(Inventory.GetSlotBoxes());

Inventory.IsOpen

function TRSInventory.IsOpen(): Boolean;

Returns true if the inventory gametab is open, false if it’s not.

Example:

WriteLn Inventory.IsOpen();

Inventory.Open

function TRSInventory.Open(): Boolean;

Attempts to open the inventory, returns true if it succeeds.

Example:

WriteLn Inventory.Open();

Inventory.PointToSlot

function TRSInventory.PointToSlot(P: TPoint): Int32;

Returns the inventory slot index which contains the TPoint P. Returns -1 if the point does not fall in any slots.

Example:

var P: TPoint;
var Slot: Int32;

P := Inventory.GetSlotBox(15).Middle; // Example point

Slot := Inventory.PointToSlot(P);
WriteLn(Slot); // 15

Inventory.MouseSlot

function TRSInventory.MouseSlot(slot: Int32): Boolean;

Moves the mouse over the slot. Slot is an Integer between 0 and 27.

Example:

if Inventory.HoverSlot(1) then
  WriteLn('Mouse is now over slot #1');

Inventory.ClickSlot

function TRSInventory.ClickSlot(slot: Int32; option: String = ''): Boolean;

Moves the mouse and clicks on the slot. Slot is an Integer between 0 and 27.

If option is empty the slot is left clicked. Else a right click is performed and the option is selected from the choose option menu.

Example:

if Inventory.ClickSlot(1) then
  WriteLn('Left clicked slot #1');
  
if Inventory.ClickSlot(1, 'Drop') then
  WriteLn('Right clicked and selected "Drop" on slot #1', 'Drop');  

Inventory.IsSlotSelected

function TRSInventory.IsSlotSelected(Slot: Int32): Boolean;

Returns True if the slot is selected (white outline).

Example:

if Inventory.IsSlotSelected(1) then
  WriteLn('Slot 1 is selected!');

Inventory.GetSelectedSlot

function TRSInventory.GetSelectedSlot(): Int32;

Returns the index of the selected slot (white outline). -1 is returned if no slot is selected.

Example:

WriteLn(Inventory.GetSelectedSlot());

Inventory.SetSelectedSlot

function TRSInventory.SetSelectedSlot(Slot: Int32): Boolean;

Set the slot as selected (white outline). Slot can be -1 to unselect the currently selected slot.

Example:

WriteLn(Inventory.GetSelectedSlot());

Inventory.RandomPattern

function TRSInventory.RandomPattern(): TIntegerArray;

Returns a random inventory pattern.

Example:

Inventory.ShiftDrop(Inventory.RandomPattern());

Inventory.ErrorPattern

function TRSInventory.ErrorPattern(Pattern: TIntegerArray=DROP_PATTERN_REGULAR; ErrorChance:Int32=5): TIntegerArray;

Returns the passed in pattern slightly modified.

Example:

Inventory.ShiftDrop(Iventory.ErrorPattern(Inventory.RandomPattern()));

Inventory.Count

function TRSInventory.Count(): Int32;
function TRSInventory.CountItem(Item: TRSItem): Int32;
function TRSInventory.CountItems(items: TRSItemArray): Int32;
function TRSInventory.CountItemStack(item: TRSItem): Int32;
function TRSInventory.CountSlotStack(slot: Int32): Int32;

Counts how many items are in the inventory right now or slack amounts.

Example:

WriteLn Inventory.Count();
WriteLn Inventory.CountItem('Shark');
WriteLn Inventory.CountItemStack('Air rune');

Inventory.IsFull

function TRSInventory.IsFull(): Boolean;

Returns true if the inventory is full.

Example:

WriteLn Inventory.IsFull();

Inventory.WaitCount

function TRSInventory.WaitCount(Count: Int32; WaitTime: Int32; Interval: Int32 = -1): Boolean;

Wait WaitTime until the Inventory.Count() matches Count.

Example:

Inventory.WaitCount(28, 5000); //Wait up to 5 seconds to have 28 items in the inventory.

Inventory.RandomSlotNearby

function TRSInventory.RandomSlotNearby(Slot: Int32; Slots: TIntegerArray): Int32;

Randomly returns one of the Slots weighted towards Slot by distance.

Example:

var Slot: Int32;

Slot := Inventory.RandomSlotNearby(0, [0..27]);
WriteLn('This slot is likely nearby slot 0');
WriteLn(Slot);

Inventory.FindItems

function TRSInventory.FindItems(Items: TRSItemArray; out Slots: TIntegerArray): Boolean;

Attempts to find the items passed in Items. The function returns true if any item is found and the slots of the found items will be returned in Slots.

Example:

var
  slots: TIntegerArray;
begin
  if Inventory.FindItems(['Shark', 'Lobster'], slots) then
    WriteLn('The slots that have sharks and lobsters are: ', slots);
end;

Inventory.FindItem

function TRSInventory.FindItem(Item: TRSItem; out Slots: TIntegerArray): Boolean;
function TRSInventory.FindItem(item: TRSItem; out slot: Int32): Boolean; overload;

Attempts to find the item passed in Item. The function returns true if the item was found can be used to return a single slot or all slots containing the item.

Example:

var
  slots: TIntegerArray;
  slot: Int32;
begin
  if Inventory.FindItem('Shark', slots) then
    WriteLn('The slots that have sharks are: ', slots);

  if Inventory.FindItem('Shark', slot) then
    WriteLn('The first slot that has a shark is: ', slot);
end;

Inventory.Contains

function TRSInventory.ContainsAny(items: TRSItemArray): Boolean;
function TRSInventory.ContainsItem(item: TRSItem): Boolean;
function TRSInventory.ContainsAll(items: TRSItemArray): Boolean;

Returns true if the inventory contains an item or items.

Example:

WriteLn Inventory.ContainsAny(['Shark', 'Lobster']);
WriteLn Inventory.ContainsItem('Shark');
WriteLn Inventory.ContainsAll(['Shark', 'Lobster', 'Tuna']);

Inventory.Discover

function TRSInventory.DiscoverAllEx(): array of TRSItemArray;
function TRSInventory.DiscoverAll(): TRSItemArray;
function TRSInventory.Discover(slot: Int32): TRSItemArray;

Returns possible items found in the inventory, either in a single slot or all of them. The extended version returns an array of TRSItemArray while the others return a flat TRSItemArray.

Example:

if Inventory.Open() then
  WriteLn Inventory.DiscoverAll();

WriteLn Inventory.Discover(0);

Inventory.MouseItem

function TRSInventory.MouseItem(Item: TRSItem): Boolean;

Hover Item in the inventory.

Example:

if Inventory.MouseItem('Bronze arrows') then
  ChooseOption.Select('Drop');

Inventory.ClickItem

function TRSInventory.ClickItem(Item: TRSItem; Option: String = ''): Boolean;

Clicks Item in the inventory. If Option is specified that option will be selected with right click if it exists.

Example:

WriteLn Inventory.ClickItem('Attack potion(3)');
WriteLn Inventory.ClickItem('Ashes', 'Drop');

Inventory.Use()

function TRSInventory.Use(slot, otherSlot: Int32): Boolean;
function TRSInventory.Use(Item, OtherItem: TRSItem): Boolean; overload;

Use 2 slots or items on one another.

Example:

WriteLn Inventory.Use('Knife', 'Oak logs');

Inventory.Drop

function TRSInventory.RightClickDrop(slots: TIntegerArray): Boolean;
function TRSInventory.RightClickDrop(items: TRSItemArray; pattern: TIntegerArray): Boolean; overload;
function TRSInventory.ShiftDrop(slots: TIntegerArray): Boolean;
function TRSInventory.ShiftDrop(items: TRSItemArray; pattern: TIntegerArray): Boolean; overload;

Right click or shift drops slots or items specified. If items are passed in, you also have to specify a pattern to use.

Shift dropping falls back to right click dropping if TRSInventory.ShiftEnabled is set to false.

Example:

// Right click drop maple & willow logs in the snake pattern
Inventory.RightClickDrop(['Maple logs', 'Willow logs'], DROP_PATTERN_SNAKE);

// Shift drop maple & willow logs in the snake pattern
Inventory.ShiftDrop(['Maple logs', 'Willow logs'], DROP_PATTERN_SNAKE);

var Inventory

Global TRSInventory variable.