diff --git a/buy.lua b/buy.lua index bc8add7..c41d9a9 100644 --- a/buy.lua +++ b/buy.lua @@ -46,7 +46,7 @@ function AuxBuySearchButton_OnClick() local stack_size = auction_item.charges or auction_item.count if auction_item.name == search_query.name or name == '' or not AuxBuyExactCheckButton:GetChecked() then - record_auction(auction_item.name, stack_size, auction_item.buyout_price, auction_item.quality, auction_item.owner, auction_item.itemlink) + record_auction(auction_item.name, auction_item.tooltip, stack_size, auction_item.buyout_price, auction_item.quality, auction_item.owner, auction_item.hyperlink) end end, on_complete = function() @@ -64,7 +64,7 @@ end function createOrder() local order = {} for entry,_ in pairs(selectedEntries) do - local key = entry.name.."_"..entry.stackSize.."_"..entry.buyoutPrice + local key = Aux.auction_key(entry.tooltip, entry.stackSize, entry.buyoutPrice) if order[key] then order[key] = order[key] + 1 @@ -121,7 +121,7 @@ function AuxBuyBuySelectedButton_OnClick() return end - local key = auction_item.name.."_"..stack_size.."_"..auction_item.buyout_price + local key = Aux.auction_key(auction_item.tooltip, stack_size, auction_item.buyout_price) if order[key] then if GetMoney() >= auction_item.buyout_price then @@ -138,7 +138,7 @@ function AuxBuyBuySelectedButton_OnClick() end else if auction_item.name == search_query.name then - record_auction(auction_item.name, stack_size, auction_item.buyout_price, auction_item.quality, auction_item.owner, auction_item.itemlink) + record_auction(auction_item.name, auction_item.tooltip, stack_size, auction_item.buyout_price, auction_item.quality, auction_item.owner, auction_item.hyperlink) end end end, @@ -178,31 +178,32 @@ function AuxBuyEntry_OnEnter() local entryIndex = this:GetID() local entry = entries[entryIndex] - local found, _, itemString = string.find(entry.itemLink, "^|%x+|H(.+)|h%[.+%]") - if found then + local _, _, itemString = strfind(entry.hyperlink, "^|%x+|H(.+)|h%[.+%]") + if itemString then GameTooltip:SetOwner(this, "ANCHOR_RIGHT") GameTooltip:SetHyperlink(itemString) GameTooltip:Show() if(EnhTooltip ~= nil) then - EnhTooltip.TooltipCall(GameTooltip, entry.name, entry.itemLink, entry.quality, entry.stackSize) + EnhTooltip.TooltipCall(GameTooltip, entry.name, entry.hyperlink, entry.quality, entry.stackSize) end end end ----------------------------------------- -function record_auction(name, stack_size, buyout_price, quality, owner, itemlink) +function record_auction(name, tooltip, stack_size, buyout_price, quality, owner, hyperlink) entries = entries or {} if buyout_price > 0 and owner ~= UnitName("player") then tinsert(entries, { name = name, + tooltip = tooltip, stackSize = stack_size, buyoutPrice = buyout_price, itemPrice = buyout_price / stack_size, quality = quality, - itemLink = itemlink, + hyperlink = hyperlink, }) end diff --git a/core.lua b/core.lua index 7c2da3f..1f13e3f 100644 --- a/core.lua +++ b/core.lua @@ -499,4 +499,14 @@ function Aux_QualityColor(code) elseif code == 5 then return "ffff8000" -- legendary, orange end +end + +----------------------------------------- + +function Aux.auction_key(tooltip, stack_size, buyout_price) + local key = '' + for i, entry in ipairs(tooltip) do + key = key .. (i == 1 and '' or '_') + end + return key .. '_' .. stack_size .. '_' .. buyout_price end \ No newline at end of file diff --git a/info.lua b/info.lua index 938e7bd..03a5a77 100644 --- a/info.lua +++ b/info.lua @@ -1,23 +1,23 @@ Aux.info = {} -local itemlink_item, item_id, item_charges +local hyperlink_item, item_id, item_charges function Aux.info.container_item(bag, slot) - local itemlink = GetContainerItemLink(bag, slot) + local hyperlink = GetContainerItemLink(bag, slot) - if not itemlink then + if not hyperlink then return end - local container_item = itemlink_item(itemlink) + local container_item = hyperlink_item(hyperlink) - local texture, count, locked, quality, readable, lootable, itemlink = GetContainerItemInfo(bag, slot) + local texture, count, locked, quality, readable, lootable, hyperlink = GetContainerItemInfo(bag, slot) container_item.texture = texture container_item.count = count container_item.locked = locked container_item.readable = readable container_item.lootable = lootable - container_item.itemlink = itemlink + container_item.hyperlink = hyperlink container_item.tooltip = Aux.info.tooltip(function(tt) tt:SetBagItem(bag, slot) end) container_item.charges = item_charges(container_item.tooltip) @@ -46,13 +46,13 @@ function Aux.info.auction_sell_item() end function Aux.info.auction_item(index) - local itemlink = GetAuctionItemLink("list", index) + local hyperlink = GetAuctionItemLink("list", index) - if not itemlink then + if not hyperlink then return end - local auction_item = itemlink_item(itemlink) + local auction_item = hyperlink_item(hyperlink) local name, texture, count, quality, usable, level, min_bid, min_increment, buyout_price, bid_amount, high_bidder, owner, sale_status, id, has_all_info = GetAuctionItemInfo("list", index) local duration = GetAuctionItemTimeLeft("list", index) @@ -108,7 +108,7 @@ end function item_charges(tooltip) for _, entry in ipairs(tooltip) do - local charges_string = gsub(entry, "(%d+) Charges", "%1") + local _, _, charges_string = strfind(entry, "(%d+) Charges") local charges = tonumber(charges_string) if charges then return charges @@ -116,16 +116,16 @@ function item_charges(tooltip) end end -function item_id(itemlink) - local id_string = string.gsub(itemlink, "^.-:(%d*).*", "%1") +function item_id(hyperlink) + local _, _, id_string = strfind(hyperlink, "^.-:(%d*).*") return tonumber(id_string) end -function itemlink_item(itemlink) - local name, link, quality, level, type, subtype, max_stack = GetItemInfo(item_id(itemlink)) +function hyperlink_item(hyperlink) + local name, link, quality, level, type, subtype, max_stack = GetItemInfo(item_id(hyperlink)) return { name = name, - itemlink = itemlink, + hyperlink = link, quality = quality, level = level, type = type, diff --git a/stack.lua b/stack.lua index 5fcad19..4077865 100644 --- a/stack.lua +++ b/stack.lua @@ -76,16 +76,17 @@ function move_item(from_slot, to_slot, amount) end function item_name(slot) - local itemLink = GetContainerItemLink(slot.bag, slot.bag_slot) - if itemLink then - return string.gsub(itemLink, "^.-%[(.*)%].*", "%1") + local hyperlink = GetContainerItemLink(slot.bag, slot.bag_slot) + if hyperlink then + local _, _, item_name = strfind(hyperlink, "^.-%[(.*)%].*") + return item_name end end function item_id(slot) - local itemLink = GetContainerItemLink(slot.bag, slot.bag_slot) - if itemLink then - local id_string = string.gsub(itemLink, "^.-:(%d*).*", "%1") + local hyperlink = GetContainerItemLink(slot.bag, slot.bag_slot) + if hyperlink then + local _, _, id_string = strfind(hyperlink, "^.-:(%d*).*") return tonumber(id_string) end end