Quantcast
ItemLink from itemID and itemLevel - WoWInterface
Thread Tools Display Modes
05-30-20, 03:00 AM   #1
GreenCoyote
A Murloc Raider
 
GreenCoyote's Avatar
Join Date: Apr 2020
Posts: 5
Unhappy ItemLink from itemID and itemLevel

Hello All!
Iím playing with C_AuctionHouse.GetBrowseResults().
It returns ItemKey whit itemID, itemLevel, itemSuffix, battlePetSpeciesID
I want to get ItemLink for returned items. I tried to get it by GetItemInfo(itemID) and it works fine for many items but for items with different item levels it shows incorrect link. For example, [Hiri'watha Greaves] which item level can be 104,110,116 etc, and itís all different items.

So is there a good way to get item link from ItemKey or from itemID, itemLevel?
I tried to make itemString to give it to GetItemInfo(), but it does not contains itemLevel.
  Reply With Quote
05-30-20, 06:19 AM   #2
Ketho
A Molten Giant
 
Ketho's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2010
Posts: 930
C_AuctionHouse.GetItemSearchResultInfo() returns the item link from a search result, e.g. when shift-clicking an item in the list

This (ugly example with timers) shows how you can get an item link from searching by item ID and level, while standing at the auction house
Lua Code:
  1. function PrintAuctionItemLink(itemID, itemLevel, itemSuffix)
  2.     if AuctionHouseFrame and AuctionHouseFrame:IsShown() then
  3.         local itemKey = C_AuctionHouse.MakeItemKey(itemID, itemLevel, itemSuffix)
  4.         C_AuctionHouse.SearchForItemKeys({itemKey}, {})
  5.  
  6.         C_Timer.After(0.5, function()
  7.             local firstResult = C_AuctionHouse.GetBrowseResults()[1]
  8.             AuctionHouseFrame:SelectBrowseResult(firstResult)
  9.         end)
  10.  
  11.         C_Timer.After(1, function()
  12.             local info = C_AuctionHouse.GetItemSearchResultInfo(itemKey, 1)
  13.             print(info.itemLink, (info.itemLink:gsub("|", "||")))
  14.         end)
  15.     end
  16. end
Code:
/run PrintAuctionItemLink(4711, 54) -- item level 54
> "[Glimmering Cloak]"
> "|cff1eff00|Hitem:4711::::::::120:258:512:53:1:4277:120:::|h[Glimmering Cloak]|h|r"
Code:
/run PrintAuctionItemLink(55582, 116) -- Hiri'watha Greaves, item level 116

As to how you would generate an item link straight from an item ID and level, I have no idea
There is a lot of magic involved, especially with item suffixes

Last edited by Ketho : 05-30-20 at 06:56 AM.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » ItemLink from itemID and itemLevel

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off