# Shop Methods to interact with the shop interface. ```{figure} ../../images/shop_interface.png ``` ```{note} Credits to GodTierKappa a.k.a. jacz24 ``` - - - ## EShopQuantity ```pascal EShopQuantity = enum(ONE, FIVE, TEN, FIFTY); ``` Enum representing the shop quantity buttons. - - - ## TShop Main record to interact with the {ref}`Shop` interface. - - - ## Shop.FindItemBoundaries ```pascal function TShop.FindItemBoundaries(): TBoxArray; ``` Finds item boundaries and returns them as a TBoxArray. You have 2 ways of getting the shop item slots, a static one: ```pascal ShowOnTarget(Shop.SlotBoxes); ``` ```{figure} ../../images/shop_static_slots.png The shop static slots. ``` And a dynamic one: ```pascal ShowOnTarget(Shop.FindItemBoundaries()); ``` ```{figure} ../../images/shop_item_boundaries.png The shop "dynamic" slots. ``` There are use cases for both, internally, `Shop.FindItemBoundaries` is usually used. - - - ## Shop.SetupInterface ```pascal procedure TShop.SetupInterface(); ``` Internal method used to setup the {ref}`TShop` coordinates. This is automatically called for you on the {ref}`Shop variable`. - - - ## Shop.IsOpen ```pascal function TShop.IsOpen(): Boolean; ``` Returns true if the shop interface is open. Example: ```pascal WriteLn Shop.IsOpen(); ``` - - - ## Shop.WaitOpen ```pascal function TShop.WaitOpen(time: Integer = 600; interval: Integer = -1): Boolean; ``` Returns true if the shop opens within `time` milliseconds. Example: ```pascal WriteLn Shop.WaitOpen(); ``` - - - ## Shop.Close ```pascal function TShop.Close(escape: Boolean): Boolean; function TShop.Close(escapeProbability: Double = BioHash): Boolean; overload; ``` Closes the {ref}`Shop` interface, depending on `escape` the function will either press escape or click the close button. Example: ```pascal WriteLn Shop.Close(); ``` - - - ## Shop.Buy ```pascal function TShop.Buy( item: TItem; quantity: EShopQuantity = EShopQuantity.ONE ): Boolean; ``` Attempts to buy the specified item from the shop. With the proper quantity button enabled. Example: ```pascal WriteLn Shop.Buy('Gold ore', EShopQuantity.FIFTY); ``` - - - ## Shop.Sell ```pascal function TShop.Sell( item: TItem; quantity: EShopQuantity = EShopQuantity.ONE ): Boolean; ``` Attempts to sell the specified item to the shop from your inventory. With the proper quantity button enabled. Example: ```pascal WriteLn Shop.Sell('Bones', EShopQuantity.FIVE); ``` - - - ## Shop.GetPrice ```pascal function TShop.GetPrice(item: TItem): Integer; ``` Returns the price of an item in the shop by examining it. Example: ```pascal WriteLn Shop.GetPrice('Gold ore'); ``` - - - ## Shop.SetQuantity ```pascal function TShop.SetQuantity(quantity: EShopQuantity): Boolean; ``` Sets the shop quantity button (1, 5, 10, or 50). Example: ```pascal WriteLn Shop.SetQuantity(EShopQuantity.TEN); ``` - - - ## Shop.Hover ```pascal function TShop.Hover(obj: TObject; walk: Boolean = True): Boolean; function TShop.Hover(npc: TEntity; walk: Boolean = True): Boolean; overload; ``` 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. If you are too far, it will attempt to walk closer to it. - - - ## Shop.Open ```pascal function TShop.Open(obj: TObject; walk: Boolean = True): Boolean; function TShop.Open(npc: TEntity; walk: Boolean = True): Boolean; overload; ``` Opens the shop for you. This assumes that {ref}`Map` is being used and setup. Example: ```pascal {$I WaspLib/main.simba} begin Map.Setup([Map.Setup([EChunk.BLAST_FURNACE])); Shop.Open(TEntity.Create(Map.Walker, MapNPCs.GetByName('Ordan', 1)[0])); end. ``` - - - ## Shop variable Global {ref}`TShop` variable.