helpers: add GetItemIDFromLink function
This commit is contained in:
+16
-2
@@ -330,6 +330,20 @@ ShaguTweaks.spairs = function(t)
|
||||
return orderedNext, t, nil
|
||||
end
|
||||
|
||||
ShaguTweaks.GetItemIDFromLink = function(itemLink)
|
||||
if not itemLink then
|
||||
return
|
||||
end
|
||||
|
||||
local foundID, _ , itemID = string.find(itemLink, "item:(%d+)")
|
||||
if not foundID then
|
||||
return
|
||||
end
|
||||
|
||||
return tonumber(itemID)
|
||||
end
|
||||
|
||||
|
||||
ShaguTweaks.GetItemCount = function(itemName)
|
||||
local count = 0
|
||||
for bag = 4, 0, -1 do
|
||||
@@ -337,8 +351,8 @@ ShaguTweaks.GetItemCount = function(itemName)
|
||||
local _, itemCount = GetContainerItemInfo(bag, slot)
|
||||
if itemCount then
|
||||
local itemLink = GetContainerItemLink(bag,slot)
|
||||
local _, _, itemParse = strfind(itemLink, "(%d+):")
|
||||
local queryName = GetItemInfo(itemParse)
|
||||
local itemID = ShaguTweaks.GetItemIDFromLink(itemLink)
|
||||
local queryName = GetItemInfo(itemID)
|
||||
if queryName and queryName ~= "" then
|
||||
if queryName == itemName then
|
||||
count = count + itemCount
|
||||
|
||||
+3
-2
@@ -1,5 +1,6 @@
|
||||
local _G = ShaguTweaks.GetGlobalEnv()
|
||||
local T = ShaguTweaks.T
|
||||
local GetItemIDFromLink = ShaguTweaks.GetItemIDFromLink
|
||||
|
||||
local module = ShaguTweaks:register({
|
||||
title = T["Sell Junk"],
|
||||
@@ -85,8 +86,8 @@ module.enable = function(self)
|
||||
|
||||
-- get value
|
||||
local _, icount = GetContainerItemInfo(bag, slot)
|
||||
local _, _, id = string.find(GetContainerItemLink(bag, slot), "item:(%d+):%d+:%d+:%d+")
|
||||
local price = ShaguTweaks.SellValueDB[tonumber(id)] or 0
|
||||
local itemID = GetItemIDFromLink(GetContainerItemLink(bag, slot))
|
||||
local price = ShaguTweaks.SellValueDB[itemID] or 0
|
||||
if this.price then
|
||||
this.price = this.price + ( price * ( icount or 1 ) )
|
||||
this.count = this.count + 1
|
||||
|
||||
@@ -2,6 +2,7 @@ local _G = ShaguTweaks.GetGlobalEnv()
|
||||
local T = ShaguTweaks.T
|
||||
local GetExpansion = ShaguTweaks.GetExpansion
|
||||
local GetItemLinkByName = ShaguTweaks.GetItemLinkByName
|
||||
local GetItemIDFromLink = ShaguTweaks.GetItemIDFromLink
|
||||
|
||||
local module = ShaguTweaks:register({
|
||||
title = T["Vendor Values"],
|
||||
@@ -3887,18 +3888,18 @@ module.enable = function(self)
|
||||
|
||||
tooltip:SetScript("OnShow", function()
|
||||
if GameTooltip.itemLink and (GameTooltip.ignoreMerchant or not MerchantFrame:IsShown()) then
|
||||
local _, _, id = string.find(GameTooltip.itemLink, "item:(%d+):%d+:%d+:%d+")
|
||||
local itemID = GetItemIDFromLink(GameTooltip.itemLink)
|
||||
local count = tonumber(GameTooltip.itemCount) or 1
|
||||
AddVendorPrices(GameTooltip, tonumber(id), math.max(count, 1))
|
||||
AddVendorPrices(GameTooltip, itemID, math.max(count, 1))
|
||||
end
|
||||
end)
|
||||
|
||||
local HookSetItemRef = SetItemRef
|
||||
SetItemRef = function(link, text, button)
|
||||
local item, _, id = string.find(link, "item:(%d+):.*")
|
||||
local itemID = GetItemIDFromLink(GameTooltip.itemLink)
|
||||
HookSetItemRef(link, text, button)
|
||||
if not IsAltKeyDown() and not IsShiftKeyDown() and not IsControlKeyDown() and item then
|
||||
AddVendorPrices(ItemRefTooltip, tonumber(id), 1)
|
||||
if not IsAltKeyDown() and not IsShiftKeyDown() and not IsControlKeyDown() and itemID then
|
||||
AddVendorPrices(ItemRefTooltip, itemID, 1)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user