# Bank Methods to interact with the Bank. - - - ## Bank.IsOpen ```pascal function TRSBank.IsOpen(waitForItems: Boolean = True): Boolean; ``` Returns true if the Bank is visible. **waitForItems** determines if the method waits up to one second for item to appears. There can be a small delay before items are visible. - - - ## Bank.Close ```pascal function TRSBank.Close(PressEscape: Boolean = False): Boolean; ``` Closes the bank, Depending on `PressEscape` the function will either click the button or press backspace. Example: ```pascal WriteLn Bank.Close(); ``` - - - ## Bank.FindItemBoundaries ```pascal function TRSBank.FindItemBoundaries(): TBoxArray; ``` Finds item boundaries. This is an internal function used to retrieve the boxes we search for items in. Example: ```pascal Boxes := Self.FindItemBoundaries(); WriteLn ItemInterface.Find(Item, Boxes); ``` - - - ## Bank.Setup ```pascal procedure Bank.Setup; ``` Initializes Bank variables. ```{note} This is automatically called on the **Bank** variable. ``` - - - ## Bank.Search ```pascal function TRSBank.Search(item: String): Boolean; ``` Searches for an item. Example: ```pascal Bank.Search('logs'); // Search for logs ``` - - - ## Bank.CloseSearch ```pascal function TRSBank.CloseSearch(): Boolean; ``` Closes the bank search if it's open. Example: ```pascal Bank.Search('logs'); // Search for logs Wait(1000); Bank.CloseSearch(); ``` - - - ## Bank.Open() ```pascal function TRSBank.Open(P: TPoint): Boolean; ``` Function to open a bank at a specified **P** TPoint. This function will move the mouse to **P** and if the uptext matches the bank or a banker uptext it will open the bank. Example: ```pascal P := CustomBankFinderFunction(); Bank.Open(P); ``` - - - ## Bank.CountTabs ```pascal function TRSBank.CountTabs: Int32; ``` Counts the existing bank tabs. Example: ```pascal WriteLn Bank.CountTabs; ``` - - - ## Bank.GetCurrentTab ```pascal function TRSBank.GetCurrentTab(): Int32; ``` Get the current active bank tab. Example: ```pascal WriteLn Bank.GetCurrentTab; ``` - - - ## Bank.OpenTab ```pascal function TRSBank.OpenTab(tab: Int32): Boolean; ``` Open the specified bank tab. Example: ```pascal Bank.OpenTab(0); ``` - - - ## Bank._SimplifyItemName ```pascal function TRSBank._SimplifyItemName(item: TRSItem): String; ``` Internal function to get a human like search term for an item. This could be improved for better antiban but I decided to keep it simple since it's not used very frequently. This basically strips the item name from things humans won't usually type when searching, like brackets. It also makes the string lower case because people searching don't usually care about casing. Once that's done wee crop some characters from the final string, because humans don't usually search the full item name, but just enough until it's seen on screen. ```{note} Could be improved to in the future for only using the relevant part of the string. For example, an human searching for 'Amulet of glory(6)' would probably search for 'glory' instead of 'amulet of gl'. ``` Example: ```pascal WriteLn Bank._SimplifyItemName('Amulet of glory(6)'); ``` - - - ## Bank.FindItemTab ```pascal function TRSBank.FindItemTab(Item: TRSItem; OpenTab: Boolean = True): Int32; ``` Find the bank tab of an item just by knowing it's name. This is very useful when you want to support people having items in any tab they want without much hassle for people to setup. By default it will open the banktab if the item is found. This can be changed by setting **OpenTab** to false. The result will be the BankTab of the item. **-1** means we didn't find a BankTab. ```{note} A known limitation of this is that if several items match the sprite of the item (for example multiple charged jewlry) the tab retrieved will be the first one found. If you have 'Games necklace(1)' in tab 1 and 'Games necklace(8)' in tab 5 and search for the latter, you will get tab 1. ``` Example: ```pascal WriteLn Bank.FindItemTab('Molten glass'); ``` - - - ## Bank.FindItem ```pascal function TRSBank.FindItem(Item: TRSItem; out box: TBox): Boolean; function TRSBank.FindItem(out item: TRSBankItem; out box: TBox; attempts: Int32 = 0): Boolean; overload; ``` Finds and returns the bounds of an item in the bank The TRSBankItem version of the method will actually search the bank for the item while the TRSItem will not. Example: ```pascal Bank.FindItem('Coins', Box); Debug(Box); ``` - - - ## Bank.ContainsItem ```pascal function TRSBank.ContainsItem(Item: TRSItem): Boolean; function TRSBank.ContainsItem(out item: TRSBankItem): Boolean; overload; ``` Returns true/false whether a item is found in the bank or not. The TRSBankItem version of the method will actually search the bank for the item while the TRSItem will not. Example: ```pascal WriteLn Bank.ContainsItem('Coins'); ``` - - - ## Bank.DiscoverAll ```pascal function TRSBank.DiscoverAllEx(): array of TRSItemArray; function TRSBank.DiscoverAll(): TRSItemArray; ``` Returns all possible items found visible in the bank. The extended version returns an `array of TRSItemArray` while the other returns a flat `TRSItemArray`. Example: ```pascal if Bank.Open() then WriteLn Bank.DiscoverAll(); ``` - - - ## Bank.Discover ```pascal function TRSBank.Discover(slot: Int32): TRSItemArray; ``` Discovers what item is on the specified bank `slot`. Example: ```pascal if Bank.Open() then WriteLn Bank.Discover(0); ``` - - - ## Bank.ContainsAny ```pascal function TRSBank.ContainsAny(items: TRSItemArray): Boolean; ``` Returns true/false whether any item in **items** is visible in the bank. - - - ## Bank.CountItem ```pascal function TRSBank.CountItem(Item: TRSItem): Int32; ``` Counts the amount of items that share the same sprite in the bank. This are extremely rare but do exist, e.g.: Edible seaweed, seaweed, giant seaweed. Example: ```pascal WriteLn Bank.CountItem('Seaweed'); ``` - - - ## Bank.CountItemStack ```pascal function TRSBank.CountItemStack(Item: TRSItem): Int32; ``` Counts the stack amount of a item in the bank. Example: ```pascal WriteLn Bank.CountItemStack('Coins'); ``` - - - ## Bank.MouseItem ```pascal function TRSBank.MouseItem(Item: TRSItem): Boolean; ``` Moves the mouse to an item. Example: ```pascal Bank.MouseItem('Coins'); ``` - - - ## Bank.ClickItem ```pascal function TRSBank.ClickItem(Item: TRSItem; Option: String = ''): Boolean; ``` Clicks an item in the bank. If an **Option** is specified and it's not in the uptext it will right click the item and look for the **Option**. Example: ```pascal Bank.ClickItem('Coins', 'All'); ``` - - - ## Bank.WithdrawItem ```pascal function TRSBank.WithdrawItem(out item: TRSBankItem; useQuantityButtons: Boolean): Boolean; function TRSBank.WithdrawItem(out item: TRSBankItem; useQuantityButtons: Boolean): Boolean; overload; function TRSBank.WithdrawItem(item: TRSItem; useQuantityButtons: Boolean): Boolean; overload; ``` Finds and withdraws an item. Parameters: - Item TRSItem, TRSBankWithdrawItem or TRSBankItem variable to withdraw. TRSBankItem caches the bank tab and scroll position the item is at for next uses. - useQuantityButtons Determines if to use the 1,5,10,X,ALL `Quantity` buttons. Example: ```pascal var ItemToWithdraw: TRSBankWithdrawItem; ItemToWithdraw.Item := 'Iron full helm'; ItemToWithdraw.Quantity := 5; ItemToWithdraw.Noted := False; Bank.WithdrawItem(ItemToWithdraw, True); // OR you can shorthand by passing an open array. Bank.WithdrawItem(['Iron full helm', 5, False], True); ``` - - - ## Bank.DepositItem ```pascal function TRSBank.DepositItem(Item: TRSBankDepositItem; useQuantityButtons: Boolean): Boolean; deprecated 'Use the TRSBankItem version instead'; function TRSBank.DepositItem(item: TRSBankItem; useQuantityButtons: Boolean): Boolean; overload ``` Deposits the specified **item** into the bank. Example: ```pascal WriteLn BankDepositItem(['Coins', TRSBank.QUANTITY_ALL]); ``` - - - ## Bank.DepositAll ```pascal function TRSBank.DepositAll: Boolean; ``` Depositis your inventory by clicking the deposit inventory button - - - ## var Bank Global Bank variable. - - - ## GameTabs.Open() override; ```pascal function TRSGameTabs.Open(Tab: ERSGameTab): Boolean; override; ``` Overrides {ref}`GameTabs.Open()` to close the bank if the bank open.