# Data This page is about fetching game data with WaspLib. WaspLib has several tools to get information about items, npcs, weapons, ... - - - ## TItemData Record responsible for providing item information in WaspLib. - - - ## TItemPriceData Record responsible for holding item price data. - - - ## ItemData.GetDefinition ```pascal function TItemData.GetDefinition(id: Integer): TItemDefinition; ``` This is mostly for internal use but you may use it for whatever you wish. This returns the {ref}`TItemDefinition` of an item, read straight from the game cache. Item definitions are items information stored in the game cache, things like: - Item ID - Item name - Item is tradeable - Item is stackable - Item is members - ... Example: ```pascal id := ItemFinder.Database.Get('abyssal whip', 'item', 'id'); def := ItemData.GetDefinition(StrToInt(id)); WriteLn def.Name, ' costs ', def.Cost; ``` - - - ## ItemData.GetTradeableID ```pascal function TItemData.GetTradeableID(item: TItem): String; ``` Mostly for internal use but you may use it as you see fit. Some items in the game have versions of themselves that are not tradeable and can't be used to fetch item prices, such as degraded items, ornamented items, etc. This function checks every id associated with the specified `item` and checks the item definition of each one (check {ref}`ItemData.GetDefinition`) for the tradeable key. The first tradeable id found is returned. Example: ```pascal WriteLn ItemData.GetTradeableID('Rune scimitar'); //rune scimitar has 2 ids and one is not tradeable. ``` - - - ## ItemData.GetPriceData ```pascal function TItemData.GetPriceData(item: TItem): TItemPriceData; ``` Method used to return the price data of the specified `item`. Example: ```pascal var priceData: TItemPriceData; begin priceData := ItemData.GetPriceData('Abyssal whip'); WriteLn('High: ' + ToStr(priceData.high) + ' Low: ' + ToStr(priceData.low)); end; ``` - - - ## ItemData.GetPrice ```pascal function TItemData.GetPrice(item: TItem): Integer; ``` Method used to return the average price of the specified `item`. Example: ```pascal WriteLn ItemData.GetPrice('Abyssal whip'); ``` - - - ## ItemData.GetLowAlch() ```pascal function TItemData.GetLowAlch(item: TItem): Integer; ``` Method used to get the the low alchemy value of an item. Example: ```pascal WriteLn ItemData.GetLowAlch('Magic longbow'); ``` - - - ## ItemData.GetHighAlch() ```pascal function TItemData.GetHighAlch(item: TItem): Integer; ``` Method used to get the the high alchemy value of an item. Example: ```pascal WriteLn ItemData.GetHighAlch('Magic longbow'); ``` - - - ## ItemData variable Global {ref}`TItemData` variable. - - - ## TGearData Type responsible for retrieving gear data. "Gear" refers to as any equippable item in the game. - - - ## GearData.Setup ```pascal procedure TGearData.Setup(); ``` Internal method to setup TGearData, loading `gear.json` out of the item database {ref}`TItemLoader.WriteDatabase` builds from the game cache. - - - ## GearData.GetArray ```pascal function TGearData.GetArray(index: Integer): TJSONItem; function TGearData.GetArray(key: String): TJSONItem; overload; ``` Method to fetch json arrays from gear.json. ```{note} Using this requires knowledge of the structure of gear.json ``` - - - ## GearData.GetItems ```pascal function TGearData.GetItems(key: Integer): TItemArray; function TGearData.GetItems(key: String): TItemArray; overload; ``` Method to fetch items under a key in gear.json. - - - ## GearData variable Global {ref}`TGearData` variable.