refactoring, bugfix
This commit is contained in:
+4
-2
@@ -30,8 +30,10 @@ function LOAD()
|
||||
CreateFrame('Frame', nil, MerchantFrame):SetScript('OnUpdate', merchant_on_update)
|
||||
|
||||
event_listener('NEW_AUCTION_UPDATE', function()
|
||||
for data in present(info.auction_sell_item()) do
|
||||
for item_id in present(item_id(data.name)) do
|
||||
local data = info.auction_sell_item()
|
||||
if data then
|
||||
local item_id = item_id(data.name)
|
||||
if item_id then
|
||||
aux_merchant_sell[_M.item_id(data.name)] = data.vendor_price / (info.max_item_charges(item_id) or data.count)
|
||||
end
|
||||
end
|
||||
|
||||
+3
-2
@@ -108,7 +108,7 @@ end
|
||||
function weighted_median(list)
|
||||
sort(list, function(a,b) return a.value < b.value end)
|
||||
local weight = 0
|
||||
for _, element in list do
|
||||
for _, element in ipairs(list) do
|
||||
weight = weight + element.weight
|
||||
if weight >= .5 then
|
||||
return element.value
|
||||
@@ -117,7 +117,8 @@ function weighted_median(list)
|
||||
end
|
||||
|
||||
function push_record(item_record)
|
||||
for market_value in present(market_value(item_record)) do
|
||||
local market_value = market_value(item_record)
|
||||
if market_value then
|
||||
tinsert(item_record.data_points, 1, weak-O('market_value', market_value, 'time', item_record.next_push))
|
||||
while getn(item_record.data_points) > 11 do
|
||||
release(item_record.data_points[getn(item_record.data_points)])
|
||||
|
||||
+2
-1
@@ -12,7 +12,8 @@ do
|
||||
local scan_states = T
|
||||
|
||||
function M.start(params)
|
||||
for old_state in present(scan_states[params.type]) do
|
||||
local old_state = scan_states[params.type]
|
||||
if old_state then
|
||||
abort(old_state.id)
|
||||
end
|
||||
do (params.on_scan_start or nop)() end
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ function SlashCmdList.AUX(command)
|
||||
elseif arguments[1] == 'chars' then
|
||||
local realm = GetCVar'realmName'
|
||||
local chars = T
|
||||
for name in aux_characters[realm] or T do
|
||||
for name in aux_characters[realm] or empty do
|
||||
tinsert(chars, name)
|
||||
end
|
||||
if getn(chars) > 0 then
|
||||
|
||||
+18
-9
@@ -124,38 +124,44 @@ function game_tooltip_hooks:SetHyperlink(itemstring)
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetAuctionItem(type, index)
|
||||
for link in present(GetAuctionItemLink(type, index)) do
|
||||
local link = GetAuctionItemLink(type, index)
|
||||
if link then
|
||||
extend_tooltip(GameTooltip, link, select(3, GetAuctionItemInfo(type, index)))
|
||||
end
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetLootItem(slot)
|
||||
for link in present(GetLootSlotLink(slot)) do
|
||||
local link = GetLootSlotLink(slot)
|
||||
if link then
|
||||
extend_tooltip(GameTooltip, link, select(3, GetLootSlotInfo(slot)))
|
||||
end
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetQuestItem(qtype, slot)
|
||||
for link in present(GetQuestItemLink(qtype, slot)) do
|
||||
local link = GetQuestItemLink(qtype, slot)
|
||||
if link then
|
||||
extend_tooltip(GameTooltip, link, select(3, GetQuestItemInfo(qtype, slot)))
|
||||
end
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetQuestLogItem(qtype, slot)
|
||||
for link in present(GetQuestLogItemLink(qtype, slot)) do
|
||||
local link = GetQuestLogItemLink(qtype, slot)
|
||||
if link then
|
||||
extend_tooltip(GameTooltip, link, select(3, GetQuestLogRewardInfo(slot)))
|
||||
end
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetBagItem(bag, slot)
|
||||
for link in present(GetContainerItemLink(bag, slot)) do
|
||||
local link = GetContainerItemLink(bag, slot)
|
||||
if link then
|
||||
extend_tooltip(GameTooltip, link, select(2, GetContainerItemInfo(bag, slot)))
|
||||
end
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetInboxItem(index)
|
||||
local name, _, quantity = GetInboxItem(index)
|
||||
for id in present(name and cache.item_id(name)) do
|
||||
local id = name and cache.item_id(name)
|
||||
if id then
|
||||
local _, itemstring, quality = GetItemInfo(id)
|
||||
local hex = select(4, GetItemQualityColor(tonumber(quality)))
|
||||
local link = hex .. '|H' .. itemstring .. '|h[' .. name .. ']|h' .. FONT_COLOR_CODE_CLOSE
|
||||
@@ -164,13 +170,15 @@ function game_tooltip_hooks:SetInboxItem(index)
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetInventoryItem(unit, slot)
|
||||
for link in present(GetInventoryItemLink(unit, slot)) do
|
||||
local link = GetInventoryItemLink(unit, slot)
|
||||
if link then
|
||||
extend_tooltip(GameTooltip, link, 1)
|
||||
end
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetMerchantItem(slot)
|
||||
for link in present(GetMerchantItemLink(slot)) do
|
||||
local link = GetMerchantItemLink(slot)
|
||||
if link then
|
||||
local quantity = select(4, GetMerchantItemInfo(slot))
|
||||
extend_tooltip(GameTooltip, link, quantity)
|
||||
end
|
||||
@@ -189,7 +197,8 @@ function game_tooltip_hooks:SetCraftItem(skill, slot)
|
||||
end
|
||||
|
||||
function game_tooltip_hooks:SetCraftSpell(slot)
|
||||
for link in present(GetCraftItemLink(slot)) do
|
||||
local link = GetCraftItemLink(slot)
|
||||
if link then
|
||||
extend_tooltip(GameTooltip, link, 1)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user