Inventory¶
Methods to interact with the inventory gametab.
TInventory¶
Main record responsible with handling the inventory gametab.
Inventory.SetupGameTab¶
procedure TInventory.SetupGameTab();
Internal method used to setup the TInventory coordinates.
This is automatically called for you on the Inventory variable.
Inventory.IsOpen¶
function TInventory.IsOpen(): Boolean;
Returns true/false if the inventory is open.
Example:
WriteLn Inventory.IsOpen();
Inventory.Open¶
function TInventory.Open(): Boolean;
Attempts to open the inventory gametab.
Example:
WriteLn Inventory.Open();
Inventory.IsFull¶
function TInventory.IsFull(): Boolean;
Returns true/false if the inventory is full.
Example:
WriteLn Inventory.IsFull();
Inventory.IsSelected¶
function TInventory.IsSelected(slot: TBox): Boolean;
function TInventory.IsSelected(slot: Integer): Boolean; overload;
Returns true/false if the specified slot or item is currently selected.
Example:
WriteLn Inventory.IsSelected('Vial');
Inventory.GetSelected¶
function TInventory.GetSelected(): Integer;
Returns the selected slot number if any. -1 is returned if no selected slot is found.
Example:
WriteLn Inventory.GetSelected();
Inventory.Select¶
function TInventory.Select(slot: Integer; wait: Boolean = False): Boolean;
function TInventory.Select(item: TItem; wait: Boolean = False): Boolean; overload;
Attempts to select the specified slot or item.
If wait is set to true we wait for confirmation that we succeeded.
Example:
WriteLn Inventory.Select('Coins');
Inventory.Combine¶
function TInventory.Combine(slotA, slotB: Integer): Boolean;
function TInventory.Combine(itemA, itemB: TItem): Boolean; overload;
Attempts to combine 2 slots or 2 items.
Example:
WriteLn Inventory.Combine('Coins', 'Asgarnian ale');
Slots.RandomPattern¶
function TInventory.RandomPattern(): TIntegerArray;
Returns a random pattern of inventory slots.
Here is example code to generate and visually debug patterns:
{$I WaspLib/main.simba}
var
img, pimg: TImage;
slots: TBoxArray;
tpa: TPointArray;
pattern: TIntegerArray;
i: Integer;
a, b: TPoint;
begin
img := Target.GetImage();
img.DrawColor := $00FFFF;
slots := Inventory.Slots.Boxes();
for i := 0 to High(slots) do
img.DrawBox(slots[i]);
while True do
begin
pimg := img.Copy();
pimg.DrawColor := $0000FF;
pattern := Inventory.RandomPattern();
b := slots[pattern[0]].RandomPointCenter();
for i := 0 to High(pattern)-1 do
begin
a := b;
b := slots[pattern[i+1]].RandomPointCenter();
pimg.DrawLine(a, b);
pimg.Show();
Sleep(50);
end;
end;
end.
Inventory.Drop¶
function TInventory.Drop(slots: TIntegerArray; attempts: Integer = 5): Boolean;
function TInventory.Drop(items: TItemArray; pattern: TIntegerArray = []): Boolean; overload;
Attempts to drop the specified slots or items.
Example:
WriteLn Inventory.Drop('Oak logs');
Inventory.ShiftDrop¶
function TInventory.ShiftDrop(slots: TIntegerArray; attempts: Integer = 5): Boolean;
function TInventory.ShiftDrop(slots, pattern: TIntegerArray): Boolean; overload;
function TInventory.ShiftDrop(items: TItemArray; pattern: TIntegerArray): Boolean; overload;
Attempts to shift drop the specified slots or items. You can optionally specify a “drop” pattern.
If we determine that we can’t shift drop because the setting is off, TInventory.Drop() is used as a fallback.
Example:
WriteLn Inventory.ShiftDrop('Maple logs');
Inventory variable¶
Global TInventory variable.