# Bank Methods to interact with the bank interface: ```{figure} ../../images/bank_interface.png ``` - - - ## ERSBankButtons ```pascal ERSBankButtons = enum(WORN, MENU); ``` Enum representing the 2 top buttons of the {ref}`Bank` interface. - - - ## ERSBankArrangement ```pascal ERSBankArrangement = enum(SWAP, INSERT); ``` Enum representing the 2 arrangement buttons of the {ref}`Bank` interface. - - - ## ERSWithdrawMode ```pascal ERSWithdrawMode = enum(ITEM, NOTE); ``` Enum representing the 2 withdraw mode buttons of the {ref}`Bank` interface. - - - ## ERSBankDynamicButtons ```pascal ERSBankDynamicButtons = enum(PLACEHOLDERS, SEARCH, DEPOSIT_INVENTORY, DEPOSIT_WORN); ``` Enum representing the 4 dynamic buttons on the right corner of the {ref}`Bank` interface. These buttons are dynamic because they can be enabled/disabled and shift places. - - - ## ERSBankInteraction ```pascal ERSBankInteraction = enum(WITHDRAW, DEPOSIT); ``` Enum representing 2 core actions you can perform on the {ref}`Bank` interface. - - - ## TBankPosition Helper record to cache items positions on the {ref}`Bank` interface. - - - ## TRSBank Record responsible to handle the {ref}`Bank` interface. - - - ## Bank.FindItemBoundaries ```pascal function TRSBank.FindItemBoundaries(): TBoxArray; ``` Finds item boundaries and returns them as a TBoxArray. You have 2 ways of getting the bank slots, a static one: ```pascal ShowOnTarget(Bank.SlotBoxes); ``` ```{figure} ../../images/bank_static_slots.png The bank static slots. ``` And a dynamic one: ```pascal ShowOnTarget(Self.FindItemBoundaries()); ``` ```{figure} ../../images/bank_item_boundaries.png The bank "dynamic" slots. ``` There are use cases for both, internally, `Bank.FindItemBoundaries` is usually used. - - - ## Bank.SetupInterface ```pascal procedure TRSBank.SetupInterface(); ``` Internal method used to setup the {ref}`TRSBank` coordinates. This is automatically called for you on the {ref}`Bank variable`. - - - ## Bank.UpdateButtons ```pascal procedure TRSBank.UpdateButtons(offset: Integer); ``` Internal helper method used to update the buttons coordinates. All the bank's bottom buttons shift slightly on the X axis depending on how many dynamic buttons are visible. ```{note} This is automatically called for you with {ref}`Bank.IsOpen`. ``` - - - ## Bank.HasJagexAccountAd ```pascal function TRSBank.HasJagexAccountAd(): Boolean; ``` Returns true if the bank has the jagex account ad pop-up. This only ever shows up on non jagex accounts and tries to buy you in with bank space. Example: ```pascal WriteLn Bank.HasJagexAccountAd(); ``` - - - ## Bank.CloseJagexAccountAd ```pascal function TRSBank.CloseJagexAccountAd(): Boolean; ``` Attempts to close the jagex account advert. Returns true on success. Example: ```pascal WriteLn Bank.CloseJagexAccountAd(); ``` - - - ## Bank.IsOpen ```pascal function TRSBank.IsOpen(): Boolean; ``` Returns true if the bank is open. Example: ```pascal WriteLn Bank.IsOpen(); ``` - - - ## Bank.WaitOpen ```pascal function TRSBank.WaitOpen(time: Integer; interval: Integer = -1): Boolean; ``` Returns true if the bank is open within `time` milliseconds. ## Example: ```pascal WriteLn Bank.WaitOpen(); ``` - - - ## Bank.Close ```pascal function TRSBank.Close(escape: Boolean): Boolean; function TRSBank.Close(escapeProbability: Single = 0): Boolean; overload; ``` Closes the bank, Depending on `escape` or `escapeProbability the function will either click the button or press escape key. Example: ```pascal WriteLn Bank.Close(); ``` - - - ## Bank.Tabs You can access the bank tabs coordinates via the `TRSBank.Tabs` variable. Example: ```pascal ShowOnTarget(Bank.Tabs); ``` ```{figure} ../../images/bank_tabs.png The bank interface. ``` - - - ### Bank.CountTabs ```pascal function TRSBank.CountTabs: Integer; ``` Counts the existing bank tabs. Example: ```pascal WriteLn Bank.CountTabs(); ``` - - - ### Bank.GetCurrentTab ```pascal function TRSBank.GetCurrentTab(): Integer; ``` Get the current active bank tab. Example: ```pascal tab := Bank.GetCurrentTab(); WritLn tab; ShowOnTarget(Bank.Tabs[tab]); ``` - - - ### Bank.OpenTab ```pascal function TRSBank.OpenTab(tab: Integer): Boolean; ``` Opens the specified bank tab. Example: ```pascal WriteLn Bank.OpenTab(0); ``` - - - ## Bank.SetArrangement ```pascal function TRSBank.SetArrangement(arrangement: ERSBankArrangement): Boolean; ``` Attempts to set the bank arrangement to `arrangement`, returns true if we succeed. Example: ```pascal WriteLn Bank.SetArrangement(ERSBankArrangement.INSERT); ``` - - - ## Bank.SetWithdrawMode ```pascal function TRSBank.SetWithdrawMode(noted: Boolean): Boolean; ``` Attempts to set the bank withdraw mode to noted if `noted` is true or to item if it's false, returns true if we succeed. Example: ```pascal WriteLn Bank.SetWithdrawMode(True); ``` - - - ## Bank.SetQuantity ```pascal function TRSBank.SetQuantity(quantity: ERSItemQuantity): Boolean; ``` Attempts to set the bank quantity to `quantity`, returns true if we succeed. Example: ```pascal WriteLn Bank.SetQuantity(ERSItemQuantity.FIVE); ``` - - - ## Bank.IsSearchOpen ```pascal function TRSBank.IsSearchOpen(): Boolean; ``` Checks if the bank search is currently open. Example: ```pascal WriteLn Bank.IsSearchOpen(); ``` - - - ## Bank.WaitSearchOpen ```pascal function TRSBank.WaitSearchOpen(time: Integer = 600): Boolean; ``` Waits `time` milliseconds for the bank search to be open. Example: ```pascal WriteLn Bank.WaitSearchOpen(); ``` - - - ## Bank.OpenSearch ```pascal function TRSBank.OpenSearch(waitTime: Integer = 0): Boolean; ``` Attempts to open the bank search and Waits `waitTime` milliseconds for it to be open. Example: ```pascal WriteLn Bank.OpenSearch(); ``` - - - ## Bank.ClearSearch ```pascal function TRSBank.ClearSearch(): Boolean; ``` Attempts to clear the bank search. Example: ```pascal WriteLn Bank.ClearSearch(); ``` - - - ## 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.HasIncinerator ```pascal function TRSBank.HasIncinerator(): Boolean; ``` Returns true if the bank screen has the incenerator visible. Example: ```pascal if Bank.HasIncenerator() then ShowOnTarget(Self.Incenerator); ``` - - - ## Bank.InceneratorTooltipVisible ```pascal function TRSBank.InceneratorTooltipVisible(): Boolean; ``` Returns true if the incenerator tooltip is visible. This is important to check when you want to interact with the bottom buttons of the bank as the tooltip will cover them. Example: ```pascal WriteLn Bank.InceneratorTooltipVisible(); ``` - - - ## Bank.CloseInceneratorTooltip ```pascal function TRSBank.CloseInceneratorTooltip(): Boolean; ``` Attempts to close the incenerator tooltip. This is important to do when you want to interact with the bottom buttons of the bank as the tooltip will cover them. Example: ```pascal if Bank.InceneratorTooltipVisible() then WriteLn Bank.CloseInceneratorTooltip(); ``` - - - ## Bank.HasPotionStorage ```pascal function TRSBank.HasPotionStorage(): Boolean; ``` Returns True/False if the bank has the potion storage menu available. Example: ```pascal WriteLn Bank.HasPotionStorage(); ``` - - - ## Bank.PotionStorageIsOpen ```pascal function TRSBank.PotionStorageIsOpen(): Boolean; ``` Returns True if the potion storage is currently open. Example: ```pascal WriteLn Bank.PotionStorageIsOpen(); ``` - - - ## Bank._FindTabText ```pascal function TRSBank._FindTabText(tpa: TPointArray; out bounds: TBox): Boolean; ``` Internal helper function help process the tabs text when you search. Example: ```pascal if Bank.Search('logs') then if Bank._FindTabText(Target.FindColor(RSColors.TEXT_LIGHT_YELLOW, 0, bounds), bounds) then ShowOnTarget(bounds); ``` - - - ## Bank.FindTab ```pascal function TRSBank.FindTab(item: TRSItem; openTab: Boolean = True): Integer; ``` Find the bank tab of `item`. ```{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.FindTab('Molten glass'); ``` - - - ## Bank.FindScroll ```pascal function TRSBank.FindScroll(item: TRSItem): Integer; ``` Find the scroll position of the bank where `item` is visible.. ```{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.FindScroll('Molten glass'); ``` - - - ## Bank._InteractionHelper ```pascal function TRSBank._InteractionHelper(mode: ERSBankInteraction; slot: TBox; amount: Integer; useQuantityButton: Boolean): Boolean; ``` Internal helper method to handle both withdrawing and depositing of items. Example: ```pascal if Bank.Items.Find('Abyssal whip', slot) the Bank._InteractionHelper(ERSBankInteraction.WITHDRAW, slot, 1, True); ``` - - - ## Bank.Find ```pascal function TRSBank.Find(item: TRSItem; out data: TBankPosition; attempts: Int32 = 3): Boolean; ``` Attempts to find `item` in the back by whatever means necessary. This will search and scroll the bank until the item is found. By default attempts up to 3 times. Item position data is returned via `data`. - - - ## Bank.Withdraw ```pascal function TRSBank.Withdraw(item: TRSBankItem; useQuantityButton: Boolean = True; useCache: Boolean = True): Boolean; function TRSBank.Withdraw(item: TRSItem; useQuantityButton: Boolean = True; useCache: Boolean = True): Boolean; overload; ``` Attempts to withdraw `item` from the bank. Example: ```pascal WriteLn Bank.Withdraw(item); ``` - - - ## Bank.Deposit ```pascal function TRSBank.Deposit(item: TRSBankItem; useQuantityButton: Boolean = True): Boolean; function TRSBank.Deposit(item: TRSItem; useQuantityButton: Boolean = True): Boolean; overload; ``` Attempts to deposit `item` into the bank. Example: ```pascal WriteLn Bank.Deposit(item); ``` - - - ## Bank.DepositDifferent ```pascal function TRSBank.DepositDifferent(items: TRSItemArray; useQuantityButton: Boolean = True): Boolean; ``` Attempts to deposit all items found that are not the `items` passed as a paremeter. Example: ```pascal WriteLn Bank.DepositDifferent(['Abyssal whip', 'Bandos chestplate', 'Bandos tassets']); ``` - - - ## Bank.IsDepleted ```pascal function TRSBank.IsDepleted(item: TRSBankItem; attempts: Integer = 3): Boolean; ``` Checks if a item is depleted in the bank. This returns true if the `item.Item` quantity in the bank is less than `item.Quantity`. It also sets the `Bank.Depleted` variable to true which you can use in your script for whatever you see fit. Example: ```pascal WriteLn Bank.IsDepleted(item); ``` - - - ## Bank.Hover ```pascal function TRSBank.Hover(walk: Boolean = True): Boolean; ``` Hovers the closest bank that WaspLib is aware of. This assumes that {ref}`Map` is being used and setup. It's possible to use this with other systems but you need to configure it all manually. It will always hover the closest bank {ref}`TRSObject` or {ref}`TRSNPC` on your loaded map. If you are too far, it will attempt to walk closer to it. - - - ## Bank.Open ```pascal function TRSBank.Open(walk: Boolean = True): Boolean; ``` Opens the bank for you. This assumes that {ref}`Map` is being used and setup. It's possible to use this with other systems but you need to configure it all manually. It will always use the closest bank {ref}`TRSObject` or {ref}`TRSNPC` WaspLib is aware of on your loaded map. If you are too far, it will attempt to walk closer to it. Example: ```pascal {$I WaspLib/osrs.simba} begin Map.Setup([ERSChunk.VARROCK]); Bank.Open(); end. ``` ```{figure} ../../images/bankopen.gif ``` - - - ## Bank variable Global {ref}`TRSBank` variable.