From e6acaba732ac8ca3aa05f2295b578803fb5575e7 Mon Sep 17 00:00:00 2001 From: Crum Date: Fri, 15 Dec 2017 21:48:41 -0600 Subject: [PATCH] add GetItemLinkByName function Needed for Merchants.lua skin (buyback) and maybe others. --- !Compatibility/api/wowAPI.lua | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/!Compatibility/api/wowAPI.lua b/!Compatibility/api/wowAPI.lua index ab61f3a..de6f95f 100644 --- a/!Compatibility/api/wowAPI.lua +++ b/!Compatibility/api/wowAPI.lua @@ -3,6 +3,7 @@ local _G = _G local assert = assert local date = date local pairs = pairs +local select = select local tonumber = tonumber local type = type local unpack = unpack @@ -357,4 +358,16 @@ function GetThreatStatus(currentThreat, maxThreat) else return 0, threatPercent end +end + +-- Credits: @Shagu - pfUI +-- https://github.com/shagu/pfUI/blob/7999f612ad464261306bbf6f309bb63b54bd44af/api/api.lua#L123 +function GetItemLinkByName(name) + for itemID = 1, 25818 do + local itemName, itemLink, itemQuality = GetItemInfo(itemID) + if itemName and itemName == name then + local hex = select(4, GetItemQualityColor(tonumber(itemQuality))) + return hex.. "|H"..itemLink.."|h["..itemName.."]|h|r" + end + end end \ No newline at end of file