# Anvil Anvil interface. ```{figure} ../../images/anvil_interface.png ``` - - - ## TRSAnvil Main record to interact with the {ref}`Anvil` interface. - - - ## Anvil.GetSlotBoxes ```pascal function TRSAnvil.GetSlotBoxes(): TBoxArray; ``` Returns `Anvil.SlotBoxes` that have "smithable" items. To see `Anvil.SlotBoxes` you can run this: ```pascal {$I WaspLib/osrs.simba} begin ShowOnTarget(Anvil.SlotBoxes); end. ``` And it should look something like this: ```{figure} ../../images/anvil_slotboxes.png ``` `Anvil.GetSlotBoxes` filters out the slots that are unavailable: ```pascal {$I WaspLib/osrs.simba} begin ShowOnTarget(Anvil.GetSlotBoxes()); end. ``` ```{figure} ../../images/anvil_getslotboxes.png ``` One thing you might notice from the rune 2h sword, is that our slot boxes are smaller than the actual click boxes of the slot. This is on purpose and there's 2 reasons for it: - Simplifies code because the slot sizes are not always equal, the size used is the smallest one anvil slots can have (limbs and bolts). - From previous click accuracy tests, we concluded humans tend to focus the click towards the center of what they are trying to click, close to a gaussian distribution, so using the whole click box is a little bit pointless. - - - ## Anvil.SetupInterface ```pascal procedure TRSAnvil.SetupInterface; ``` Initializes {ref}`Anvil` variables. ```{note} This is automatically called for you on the {ref}`Anvil variable`. ``` - - - ## Anvil.IsOpen ```pascal function TRSAnvil.IsOpen(): Boolean; ``` Returns true if the {ref}`Anvil` is open. Example: ```pascal WriteLn Anvil.IsOpen(); ``` - - - ## Anvil.WaitOpen ```pascal function TRSAnvil.WaitOpen(time: Integer; interval: Integer = -1): Boolean; ``` Returns true if the {ref}`Anvil` is open within `time` milliseconds. ## Example: ```pascal WriteLn Anvil.WaitOpen(); ``` - - - ## Anvil.SetQuantity ```pascal function TRSAnvil.SetQuantity(value: Integer): Boolean; ``` Attempts to enable the quantity button for the given `value`. This is probably more complex than most people would think it is because buttons are not always visible depending on the amount of metal bars your have in your {ref}`Inventory`. ## Example: ```pascal WriteLn Anvil.SetQuantity(QUANTITY_ALL); ``` - - - ## Anvil.CanSmith ```pascal function TRSAnvil.CanSmith(item: TRSItem): Boolean; ``` Checks if the specified `item` is currently available to smith. ## Example: ```pascal WriteLn Anvil.CanSmith('Rune 2h sword'); ``` - - - ## Anvil.Smith ```pascal function TRSAnvil.Smith(item: TRSItem; quantity: Integer = QUANTITY_ALL; keyboardProbability: Single = -1): Boolean; ``` Attempts to smith the specified `item` with the specified `quantity`. ## Example: ```pascal WriteLn Anvil.Smith('Rune 2h sword'); ``` - - - ## Anvil.Hover ```pascal function TRSAnvil.Hover(walk: Boolean = True): Boolean; ``` Hovers the closest anvil 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 anvil {ref}`TRSObject` on your loaded map. If you are too far, it will attempt to walk closer to it by default unless you set the `walk` parameter to `False`. - - - ## Anvil.Open ```pascal function TRSAnvil.Open(constref obj: TRSObject; walk: Boolean = True): Boolean; function TRSAnvil.Open(walk: Boolean = True): Boolean; ``` Opens the anvil for you. This assumes that {ref}`Map` is being used and is set up. It's possible to use this with other systems but you need to configure it all manually. It will always use the closest anvil {ref}`RSObject` WaspLib is aware of on your loaded map. If you are too far, it will attempt to walk closer to it by default unless you set the `walk` parameter to `False`. Example: ```pascal {$I WaspLib/osrs.simba} begin Map.Setup([ERSChunk.VARROCK]); Anvil.Open(); end. ``` ```{figure} ../../images/anvilopen.gif ``` - - - ## Anvil variable Global {ref}`TRSAnvil` variable.