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;

Counts how many items are in the inventory right now.

Example:

WriteLn Inventory.Count();

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.ContainsAny#

function TRSInventory.ContainsAny(items: TRSItemArray): Boolean;

Returns true if the inventory contains any of the items passed in items. It’s the same as TRSInventory.FindItems() but without requiring a Slots parameter.

Example:

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

Inventory.ContainsItem#

function TRSInventory.ContainsItem(item: TRSItem): Boolean;

Returns true if the inventory contains the item passed in item. Same as TRSInventory.FindItem() but without requiring Slots or slot parameter.

Example:

WriteLn Inventory.ContainsItem('Shark');

Inventory.ContainsAll#

function TRSInventory.ContainsAll(items: TRSItemArray): Boolean;

Returns true if the inventory contains all items passed in items.

Example:

WriteLn Inventory.ContainsAll('Shark');

Inventory.CountItem#

function TRSInventory.CountItem(Item: TRSItem): Int32;

Returns the amount of Item in the inventory. Keep in mind this does not count a stack number, but every single item that occupies an inventory slot.

Example:

WriteLn Inventory.CountItem('Shark');

Inventory.CountItemStack#

function TRSInventory.CountItemStack(Item: TRSItem): Int32;

Returns the stack amount of Item in the inventory.

Example:

WriteLn Inventory.CountItemStack('Bronze arrows'); //will print the stack amount
WriteLn Inventory.CountItemStack('Shark'); //will print 0 because sharks are not stackable.

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.ShiftDrop()#

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

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

Example:

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