refactorings
This commit is contained in:
+24
-24
@@ -1,4 +1,4 @@
|
||||
local m, public, private = Aux.module'cache'
|
||||
local m, public, private = aux.module'cache'
|
||||
|
||||
local MIN_ITEM_ID, MAX_ITEM_ID = 1, 30000
|
||||
local items_schema = {'record', '#', {name='string'}, {quality='number'}, {level='number'}, {class='string'}, {subclass='string'}, {slot='string'}, {max_stack='number'}, {texture='string'}}
|
||||
@@ -14,19 +14,19 @@ aux_characters = {}
|
||||
function public.LOAD()
|
||||
m.scan_wdb()
|
||||
|
||||
Aux.control.event_listener('MERCHANT_SHOW', m.on_merchant_show)
|
||||
Aux.control.event_listener('MERCHANT_CLOSED', m.on_merchant_closed)
|
||||
Aux.control.event_listener('MERCHANT_UPDATE', m.on_merchant_update)
|
||||
Aux.control.event_listener('BAG_UPDATE', m.on_bag_update)
|
||||
aux.control.event_listener('MERCHANT_SHOW', m.on_merchant_show)
|
||||
aux.control.event_listener('MERCHANT_CLOSED', m.on_merchant_closed)
|
||||
aux.control.event_listener('MERCHANT_UPDATE', m.on_merchant_update)
|
||||
aux.control.event_listener('BAG_UPDATE', m.on_bag_update)
|
||||
|
||||
CreateFrame('Frame', nil, MerchantFrame):SetScript('OnUpdate', m.merchant_on_update)
|
||||
|
||||
Aux.control.event_listener('NEW_AUCTION_UPDATE', function()
|
||||
local info = Aux.info.auction_sell_item()
|
||||
aux.control.event_listener('NEW_AUCTION_UPDATE', function()
|
||||
local info = aux.info.auction_sell_item()
|
||||
if info then
|
||||
local item_id = Aux.cache.item_id(info.name)
|
||||
local item_id = aux.cache.item_id(info.name)
|
||||
if item_id then
|
||||
aux_merchant_sell[Aux.cache.item_id(info.name)] = info.vendor_price / (Aux.info.max_item_charges(item_id) or info.count)
|
||||
aux_merchant_sell[aux.cache.item_id(info.name)] = info.vendor_price / (aux.info.max_item_charges(item_id) or info.count)
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -79,7 +79,7 @@ end
|
||||
function public.merchant_info(item_id)
|
||||
local buy_info
|
||||
if aux_merchant_buy[item_id] then
|
||||
buy_info = Aux.persistence.read(merchant_buy_schema, aux_merchant_buy[item_id])
|
||||
buy_info = aux.persistence.read(merchant_buy_schema, aux_merchant_buy[item_id])
|
||||
end
|
||||
|
||||
return aux_merchant_sell[item_id], buy_info and buy_info.unit_price, buy_info and buy_info.limited
|
||||
@@ -88,7 +88,7 @@ end
|
||||
function public.item_info(item_id)
|
||||
local data_string = aux_items[item_id]
|
||||
if data_string then
|
||||
local cached_data = Aux.persistence.read(items_schema, data_string)
|
||||
local cached_data = aux.persistence.read(items_schema, data_string)
|
||||
return {
|
||||
name = cached_data.name,
|
||||
itemstring = 'item:'..item_id..':0:0:0',
|
||||
@@ -114,10 +114,10 @@ function private.merchant_buy_scan()
|
||||
local _, _, price, count, stock = GetMerchantItemInfo(i)
|
||||
local link = GetMerchantItemLink(i)
|
||||
if link then
|
||||
local item_id = Aux.info.parse_hyperlink(link)
|
||||
local item_id = aux.info.parse_hyperlink(link)
|
||||
local new_unit_price, new_limited = price / count, stock >= 0
|
||||
if aux_merchant_buy[item_id] then
|
||||
local buy_info = Aux.persistence.read(merchant_buy_schema, aux_merchant_buy[item_id])
|
||||
local buy_info = aux.persistence.read(merchant_buy_schema, aux_merchant_buy[item_id])
|
||||
|
||||
local unit_price
|
||||
if buy_info.limited and not new_limited then
|
||||
@@ -128,12 +128,12 @@ function private.merchant_buy_scan()
|
||||
unit_price = min(buy_info.unit_price, new_unit_price)
|
||||
end
|
||||
|
||||
aux_merchant_buy[item_id] = Aux.persistence.write(merchant_buy_schema, {
|
||||
aux_merchant_buy[item_id] = aux.persistence.write(merchant_buy_schema, {
|
||||
unit_price = unit_price,
|
||||
limited = buy_info.limited and new_limited,
|
||||
})
|
||||
else
|
||||
aux_merchant_buy[item_id] = Aux.persistence.write(merchant_buy_schema, {
|
||||
aux_merchant_buy[item_id] = aux.persistence.write(merchant_buy_schema, {
|
||||
unit_price = new_unit_price,
|
||||
limited = new_limited,
|
||||
})
|
||||
@@ -147,8 +147,8 @@ function private.merchant_buy_scan()
|
||||
end
|
||||
|
||||
function private.merchant_sell_scan()
|
||||
for slot in Aux.util.inventory() do
|
||||
local item_info = Aux.info.container_item(unpack(slot))
|
||||
for slot in aux.util.inventory() do
|
||||
local item_info = aux.info.container_item(unpack(slot))
|
||||
if item_info then
|
||||
aux_merchant_sell[item_info.item_id] = item_info.tooltip_money / item_info.aux_quantity
|
||||
end
|
||||
@@ -164,7 +164,7 @@ function private.scan_wdb(item_id)
|
||||
local name, _, quality, level, class, subclass, max_stack, slot, texture = GetItemInfo(itemstring)
|
||||
if name and not aux_item_ids[strlower(name)] then
|
||||
aux_item_ids[strlower(name)] = item_id
|
||||
aux_items[item_id] = Aux.persistence.write(items_schema, {
|
||||
aux_items[item_id] = aux.persistence.write(items_schema, {
|
||||
name = name,
|
||||
quality = quality,
|
||||
level = level,
|
||||
@@ -174,8 +174,8 @@ function private.scan_wdb(item_id)
|
||||
max_stack = max_stack,
|
||||
texture = texture,
|
||||
})
|
||||
local tooltip = Aux.info.tooltip(function(tt) tt:SetHyperlink(itemstring) end)
|
||||
if Aux.info.auctionable(tooltip, quality) then
|
||||
local tooltip = aux.info.tooltip(function(tt) tt:SetHyperlink(itemstring) end)
|
||||
if aux.info.auctionable(tooltip, quality) then
|
||||
tinsert(aux_auctionable_items, strlower(name))
|
||||
end
|
||||
processed = processed + 1
|
||||
@@ -185,7 +185,7 @@ function private.scan_wdb(item_id)
|
||||
|
||||
if item_id <= MAX_ITEM_ID then
|
||||
local t0 = GetTime()
|
||||
Aux.control.as_soon_as(function() return GetTime() - t0 > 0.1 end, m.scan_wdb, item_id)
|
||||
aux.control.as_soon_as(function() return GetTime() - t0 > 0.1 end, m.scan_wdb, item_id)
|
||||
else
|
||||
sort(aux_auctionable_items, function(a, b) return strlen(a) < strlen(b) or (strlen(a) == strlen(b) and a < b) end)
|
||||
end
|
||||
@@ -195,14 +195,14 @@ function public.populate_wdb(item_id)
|
||||
item_id = item_id or MIN_ITEM_ID
|
||||
|
||||
if item_id > MAX_ITEM_ID then
|
||||
Aux.log('Cache populated.')
|
||||
aux.log('Cache populated.')
|
||||
return
|
||||
end
|
||||
|
||||
if not GetItemInfo('item:'..item_id) then
|
||||
Aux.log('Fetching item '..item_id..'.')
|
||||
aux.log('Fetching item '..item_id..'.')
|
||||
AuxTooltip:SetHyperlink('item:'..item_id)
|
||||
end
|
||||
|
||||
Aux.control.thread(m.populate_wdb, item_id + 1)
|
||||
aux.control.thread(m.populate_wdb, item_id + 1)
|
||||
end
|
||||
@@ -1,4 +1,4 @@
|
||||
local m, public, private = Aux.module'disenchant'
|
||||
local m, public, private = aux.module'disenchant'
|
||||
|
||||
private.UNCOMMON = 2
|
||||
private.RARE = 3
|
||||
@@ -41,7 +41,7 @@ do
|
||||
end
|
||||
|
||||
function public.LOAD()
|
||||
private.armor = Aux.util.set(
|
||||
private.armor = aux.util.set(
|
||||
'INVTYPE_HEAD',
|
||||
'INVTYPE_NECK',
|
||||
'INVTYPE_SHOULDER',
|
||||
@@ -59,7 +59,7 @@ function public.LOAD()
|
||||
'INVTYPE_HOLDABLE'
|
||||
)
|
||||
|
||||
private.weapon = Aux.util.set(
|
||||
private.weapon = aux.util.set(
|
||||
'INVTYPE_2HWEAPON' ,
|
||||
'INVTYPE_WEAPONMAINHAND',
|
||||
'INVTYPE_WEAPON',
|
||||
@@ -73,7 +73,7 @@ end
|
||||
function public.value(slot, quality, level)
|
||||
local expectation
|
||||
for _, event in m.distribution(slot, quality, level) do
|
||||
local value = Aux.history.value(event.item_id..':'..0)
|
||||
local value = aux.history.value(event.item_id..':'..0)
|
||||
if not value then
|
||||
return
|
||||
else
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
local m, public, private = Aux.module'history'
|
||||
local m, public, private = aux.module'history'
|
||||
|
||||
local history_schema = {'record', '#', {next_push='number'}, {daily_min_buyout='number'}, {daily_max_price='number'}, {data_points={'list', ';', {'record', '@', {market_value='number'}, {time='number'}}}}}
|
||||
private.value_cache = {}
|
||||
@@ -14,7 +14,7 @@ function private.new_record()
|
||||
end
|
||||
|
||||
function private.load_data()
|
||||
local dataset = Aux.persistence.load_dataset()
|
||||
local dataset = aux.persistence.load_dataset()
|
||||
dataset.history = dataset.history or {}
|
||||
return dataset.history
|
||||
end
|
||||
@@ -24,7 +24,7 @@ function private.read_record(item_key)
|
||||
|
||||
local record
|
||||
if data[item_key] then
|
||||
record = Aux.persistence.read(history_schema, data[item_key])
|
||||
record = aux.persistence.read(history_schema, data[item_key])
|
||||
else
|
||||
record = m.new_record()
|
||||
end
|
||||
@@ -40,7 +40,7 @@ end
|
||||
function private.write_record(item_key, record)
|
||||
m.value_cache[item_key] = nil
|
||||
local data = m.load_data()
|
||||
data[item_key] = Aux.persistence.write(history_schema, record)
|
||||
data[item_key] = aux.persistence.write(history_schema, record)
|
||||
end
|
||||
|
||||
function public.process_auction(auction_record)
|
||||
@@ -72,7 +72,7 @@ function public.value(item_key)
|
||||
local weighted_values = {}
|
||||
local total_weight = 0
|
||||
for _, data_point in item_record.data_points do
|
||||
local weight = 0.99^Aux.util.round((item_record.data_points[1].time - data_point.time) / (60*60*24))
|
||||
local weight = 0.99^aux.util.round((item_record.data_points[1].time - data_point.time) / (60*60*24))
|
||||
total_weight = total_weight + weight
|
||||
tinsert(weighted_values, {value = data_point.market_value, weight = weight})
|
||||
end
|
||||
|
||||
+10
-10
@@ -1,4 +1,4 @@
|
||||
local m, public, private = Aux.module'post'
|
||||
local m, public, private = aux.module'post'
|
||||
|
||||
private.state = nil
|
||||
|
||||
@@ -7,7 +7,7 @@ function private.process()
|
||||
|
||||
local stacking_complete
|
||||
|
||||
local c = Aux.control.await(function(slot)
|
||||
local c = aux.control.await(function(slot)
|
||||
if slot then
|
||||
return m.post_auction(slot, m.process)
|
||||
else
|
||||
@@ -15,15 +15,15 @@ function private.process()
|
||||
end
|
||||
end)
|
||||
|
||||
return Aux.stack.start(m.state.item_key, m.state.stack_size, c)
|
||||
return aux.stack.start(m.state.item_key, m.state.stack_size, c)
|
||||
end
|
||||
|
||||
return m.stop()
|
||||
end
|
||||
|
||||
function private.post_auction(slot, k)
|
||||
local item_info = Aux.info.container_item(unpack(slot))
|
||||
if item_info.item_key == m.state.item_key and Aux.info.auctionable(item_info.tooltip) and item_info.aux_quantity == m.state.stack_size then
|
||||
local item_info = aux.info.container_item(unpack(slot))
|
||||
if item_info.item_key == m.state.item_key and aux.info.auctionable(item_info.tooltip) and item_info.aux_quantity == m.state.stack_size then
|
||||
|
||||
ClearCursor()
|
||||
ClickAuctionSellItemButton()
|
||||
@@ -32,15 +32,15 @@ function private.post_auction(slot, k)
|
||||
ClickAuctionSellItemButton()
|
||||
ClearCursor()
|
||||
|
||||
StartAuction(max(1, Aux.util.round(m.state.unit_start_price * item_info.aux_quantity)), Aux.util.round(m.state.unit_buyout_price * item_info.aux_quantity), m.state.duration)
|
||||
StartAuction(max(1, aux.util.round(m.state.unit_start_price * item_info.aux_quantity)), aux.util.round(m.state.unit_buyout_price * item_info.aux_quantity), m.state.duration)
|
||||
|
||||
local c = Aux.control.await(function()
|
||||
local c = aux.control.await(function()
|
||||
m.state.posted = m.state.posted + 1
|
||||
return k()
|
||||
end)
|
||||
|
||||
local posted
|
||||
Aux.control.event_listener('CHAT_MSG_SYSTEM', function(kill)
|
||||
aux.control.event_listener('CHAT_MSG_SYSTEM', function(kill)
|
||||
if arg1 == ERR_AUCTION_STARTED then
|
||||
c()
|
||||
kill()
|
||||
@@ -53,7 +53,7 @@ end
|
||||
|
||||
function public.stop()
|
||||
if m.state then
|
||||
Aux.control.kill_thread(m.state.thread_id)
|
||||
aux.control.kill_thread(m.state.thread_id)
|
||||
|
||||
local callback = m.state.callback
|
||||
local posted = m.state.posted
|
||||
@@ -69,7 +69,7 @@ end
|
||||
function public.start(item_key, stack_size, duration, unit_start_price, unit_buyout_price, count, callback)
|
||||
m.stop()
|
||||
|
||||
local thread_id = Aux.control.thread(m.process)
|
||||
local thread_id = aux.control.thread(m.process)
|
||||
|
||||
m.state = {
|
||||
thread_id = thread_id,
|
||||
|
||||
+25
-25
@@ -1,4 +1,4 @@
|
||||
local m, public, private = Aux.module'scan'
|
||||
local m, public, private = aux.module'scan'
|
||||
|
||||
private.PAGE_SIZE = 50
|
||||
|
||||
@@ -11,7 +11,7 @@ do
|
||||
for _, old_state in {scan_states[params.type]} do
|
||||
m.abort(old_state.id)
|
||||
end
|
||||
local thread_id = Aux.control.thread(Aux.f(m.wait_for_callback, params.on_scan_start, m.scan))
|
||||
local thread_id = aux.control.thread(aux.f(m.wait_for_callback, params.on_scan_start, m.scan))
|
||||
scan_states[params.type] = {
|
||||
id = thread_id,
|
||||
params = params,
|
||||
@@ -23,29 +23,29 @@ do
|
||||
local aborted = {}
|
||||
for type, state in scan_states do
|
||||
if not scan_id or state.id == scan_id then
|
||||
Aux.control.kill_thread(state.id)
|
||||
aux.control.kill_thread(state.id)
|
||||
scan_states[type] = nil
|
||||
tinsert(aborted, state)
|
||||
end
|
||||
end
|
||||
for _, state in aborted do
|
||||
Aux.safe_call(state.params.on_abort)
|
||||
aux.safe_call(state.params.on_abort)
|
||||
end
|
||||
end
|
||||
|
||||
function private.complete()
|
||||
local on_complete = m.state.params.on_complete
|
||||
scan_states[m.state.params.type] = nil
|
||||
Aux.safe_call(on_complete)
|
||||
aux.safe_call(on_complete)
|
||||
end
|
||||
|
||||
private.state = Aux.dynamic_table(function()
|
||||
local _, state = next(Aux.util.filter(scan_states, function(state) return state.id == Aux.control.thread_id end))
|
||||
private.state = aux.dynamic_table(function()
|
||||
local _, state = next(aux.util.filter(scan_states, function(state) return state.id == aux.control.thread_id end))
|
||||
return state
|
||||
end)
|
||||
end
|
||||
|
||||
private.query = Aux.dynamic_table(function()
|
||||
private.query = aux.dynamic_table(function()
|
||||
return m.state.params.queries[m.state.query_index]
|
||||
end)
|
||||
|
||||
@@ -67,7 +67,7 @@ function private.wait_for_callback(...)
|
||||
if ok then
|
||||
return k()
|
||||
else
|
||||
return Aux.control.when(function() return ok end, function() return k(unpack(ret)) end)
|
||||
return aux.control.when(function() return ok end, function() return k(unpack(ret)) end)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -104,8 +104,8 @@ function private.process_query()
|
||||
end
|
||||
|
||||
function private.submit_query()
|
||||
Aux.control.when(function() return m.state.params.type ~= 'list' or CanSendAuctionQuery() end, function()
|
||||
Aux.safe_call(m.state.params.on_submit_query)
|
||||
aux.control.when(function() return m.state.params.type ~= 'list' or CanSendAuctionQuery() end, function()
|
||||
aux.safe_call(m.state.params.on_submit_query)
|
||||
m.last_query_time[m.state.params.type] = GetTime()
|
||||
if m.state.params.type == 'bidder' then
|
||||
GetBidderAuctionItems(m.state.page)
|
||||
@@ -146,19 +146,19 @@ function private.scan_page(i)
|
||||
end
|
||||
end
|
||||
|
||||
local auction_info = Aux.info.auction(i, m.state.params.type)
|
||||
local auction_info = aux.info.auction(i, m.state.params.type)
|
||||
if auction_info and (auction_info.owner or m.state.params.ignore_owner or aux_ignore_owner) then
|
||||
auction_info.index = i
|
||||
auction_info.page = m.state.page
|
||||
auction_info.blizzard_query = m.query.blizzard_query
|
||||
auction_info.query_type = m.state.params.type
|
||||
|
||||
Aux.history.process_auction(auction_info)
|
||||
aux.history.process_auction(auction_info)
|
||||
|
||||
if Aux.safe_call(m.state.params.auto_buy_validator, auction_info) then
|
||||
local c = Aux.control.await(recurse)
|
||||
Aux.place_bid(auction_info.query_type, auction_info.index, auction_info.buyout_price, Aux.f(c, true))
|
||||
return Aux.control.thread(Aux.control.sleep, 10, Aux.f(c, false))
|
||||
if aux.safe_call(m.state.params.auto_buy_validator, auction_info) then
|
||||
local c = aux.control.await(recurse)
|
||||
aux.place_bid(auction_info.query_type, auction_info.index, auction_info.buyout_price, aux.f(c, true))
|
||||
return aux.control.thread(aux.control.sleep, 10, aux.f(c, false))
|
||||
elseif not m.query.validator or m.query.validator(auction_info) then
|
||||
return m.wait_for_callback(m.state.params.on_auction, auction_info, function(removed)
|
||||
if removed then
|
||||
@@ -178,7 +178,7 @@ function private.timeout(type)
|
||||
end
|
||||
|
||||
function private.wait_for_results()
|
||||
local c = Aux.control.await(function()
|
||||
local c = aux.control.await(function()
|
||||
if m.timeout(m.state.params.type) then
|
||||
return m.submit_query()
|
||||
else
|
||||
@@ -194,10 +194,10 @@ function private.wait_for_results()
|
||||
end)
|
||||
|
||||
local type = m.state.params.type
|
||||
Aux.control.as_soon_as(function() return -c or m.timeout(type) end, c)
|
||||
aux.control.as_soon_as(function() return -c or m.timeout(type) end, c)
|
||||
|
||||
if m.state.params.type == 'bidder' then
|
||||
return Aux.control.as_soon_as(function() return Aux.bids_loaded end, c)
|
||||
return aux.control.as_soon_as(function() return aux.bids_loaded end, c)
|
||||
elseif m.state.params.type == 'owner' then
|
||||
return m.wait_for_owner_results(c)
|
||||
elseif m.state.params.type == 'list' then
|
||||
@@ -206,22 +206,22 @@ function private.wait_for_results()
|
||||
end
|
||||
|
||||
function private.wait_for_owner_results(c)
|
||||
if m.state.page == Aux.current_owner_page then
|
||||
if m.state.page == aux.current_owner_page then
|
||||
return c()
|
||||
else
|
||||
return Aux.control.on_next_event('AUCTION_OWNED_LIST_UPDATE', c)
|
||||
return aux.control.on_next_event('AUCTION_OWNED_LIST_UPDATE', c)
|
||||
end
|
||||
end
|
||||
|
||||
function private.wait_for_list_results(c)
|
||||
local updated, last_update
|
||||
Aux.control.event_listener('AUCTION_ITEM_LIST_UPDATE', function(kill)
|
||||
aux.control.event_listener('AUCTION_ITEM_LIST_UPDATE', function(kill)
|
||||
kill(-c)
|
||||
last_update = GetTime()
|
||||
updated = true
|
||||
end)
|
||||
local ignore_owner = m.state.params.ignore_owner or aux_ignore_owner
|
||||
return Aux.control.as_soon_as(function()
|
||||
return aux.control.as_soon_as(function()
|
||||
-- short circuiting order important, owner_data_complete must be called iif an update has happened.
|
||||
local ok = updated and (ignore_owner or m.owner_data_complete('list')) or last_update and GetTime() - last_update > 5
|
||||
updated = false
|
||||
@@ -231,7 +231,7 @@ end
|
||||
|
||||
function private.owner_data_complete(type)
|
||||
for i=1,m.PAGE_SIZE do
|
||||
local auction_info = Aux.info.auction(i, type)
|
||||
local auction_info = aux.info.auction(i, type)
|
||||
if auction_info and not auction_info.owner then
|
||||
return false
|
||||
end
|
||||
|
||||
+24
-24
@@ -1,53 +1,53 @@
|
||||
SLASH_AUX1 = '/aux'
|
||||
function SlashCmdList.AUX(command)
|
||||
function SlashCmdList.aux(command)
|
||||
if not command then return end
|
||||
local arguments = Aux.util.tokenize(command)
|
||||
local arguments = aux.util.tokenize(command)
|
||||
if arguments[1] == 'clear' and arguments[2] == 'history' then
|
||||
Aux.persistence.load_dataset().history = nil
|
||||
Aux.log('History cleared.')
|
||||
aux.persistence.load_dataset().history = nil
|
||||
aux.log('History cleared.')
|
||||
elseif arguments[1] == 'clear' and arguments[2] == 'post' then
|
||||
Aux.persistence.load_dataset().post = nil
|
||||
Aux.log('Post settings cleared.')
|
||||
aux.persistence.load_dataset().post = nil
|
||||
aux.log('Post settings cleared.')
|
||||
elseif arguments[1] == 'clear' and arguments[2] == 'datasets' then
|
||||
aux_datasets = {}
|
||||
Aux.log('Datasets cleared.')
|
||||
aux.log('Datasets cleared.')
|
||||
elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'buy' then
|
||||
aux_merchant_buy = {}
|
||||
Aux.log('Merchant buy prices cleared.')
|
||||
aux.log('Merchant buy prices cleared.')
|
||||
elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'sell' then
|
||||
aux_merchant_sell = {}
|
||||
Aux.log('Merchant sell prices cleared.')
|
||||
aux.log('Merchant sell prices cleared.')
|
||||
elseif arguments[1] == 'clear' and arguments[2] == 'item' and arguments[3] == 'cache' then
|
||||
aux_items = {}
|
||||
aux_item_ids = {}
|
||||
aux_auctionable_items = {}
|
||||
Aux.log('Item cache cleared.')
|
||||
aux.log('Item cache cleared.')
|
||||
elseif arguments[1] == 'populate' and arguments[2] == 'wdb' then
|
||||
Aux.cache.populate_wdb()
|
||||
aux.cache.populate_wdb()
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'value' then
|
||||
aux_tooltip_value = not aux_tooltip_value
|
||||
Aux.log('Historical value in tooltip '..(aux_tooltip_value and 'enabled' or 'disabled')..'.')
|
||||
aux.log('Historical value in tooltip '..(aux_tooltip_value and 'enabled' or 'disabled')..'.')
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'daily' then
|
||||
aux_tooltip_daily = not aux_tooltip_daily
|
||||
Aux.log('Market value in tooltip '..(aux_tooltip_daily and 'enabled' or 'disabled')..'.')
|
||||
aux.log('Market value in tooltip '..(aux_tooltip_daily and 'enabled' or 'disabled')..'.')
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'vendor' and arguments[3] == 'buy' then
|
||||
aux_tooltip_vendor_buy = not aux_tooltip_vendor_buy
|
||||
Aux.log('Vendor buy price in tooltip '..(aux_tooltip_vendor_buy and 'enabled' or 'disabled')..'.')
|
||||
aux.log('Vendor buy price in tooltip '..(aux_tooltip_vendor_buy and 'enabled' or 'disabled')..'.')
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'vendor' and arguments[3] == 'sell' then
|
||||
aux_tooltip_vendor_sell = not aux_tooltip_vendor_sell
|
||||
Aux.log('Vendor sell price in tooltip '..(aux_tooltip_vendor_sell and 'enabled' or 'disabled')..'.')
|
||||
aux.log('Vendor sell price in tooltip '..(aux_tooltip_vendor_sell and 'enabled' or 'disabled')..'.')
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'value' then
|
||||
aux_tooltip_disenchant_value = not aux_tooltip_disenchant_value
|
||||
Aux.log('Disenchant value in tooltip '..(aux_tooltip_disenchant_value and 'enabled' or 'disabled')..'.')
|
||||
aux.log('Disenchant value in tooltip '..(aux_tooltip_disenchant_value and 'enabled' or 'disabled')..'.')
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'distribution' then
|
||||
aux_tooltip_disenchant_distribution = not aux_tooltip_disenchant_distribution
|
||||
Aux.log('Disenchant distribution in tooltip '..(aux_tooltip_disenchant_distribution and 'enabled' or 'disabled')..'.')
|
||||
aux.log('Disenchant distribution in tooltip '..(aux_tooltip_disenchant_distribution and 'enabled' or 'disabled')..'.')
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'source' then
|
||||
aux_tooltip_disenchant_source = not aux_tooltip_disenchant_source
|
||||
Aux.log('Disenchant source in tooltip '..(aux_tooltip_disenchant_source and 'enabled' or 'disabled')..'.')
|
||||
aux.log('Disenchant source in tooltip '..(aux_tooltip_disenchant_source and 'enabled' or 'disabled')..'.')
|
||||
elseif arguments[1] == 'ignore' and arguments[2] == 'owner' then
|
||||
aux_ignore_owner = not aux_ignore_owner
|
||||
Aux.log('Ignoring of owner '..(aux_ignore_owner and 'enabled' or 'disabled')..'.')
|
||||
aux.log('Ignoring of owner '..(aux_ignore_owner and 'enabled' or 'disabled')..'.')
|
||||
elseif arguments[1] == 'chars' and arguments[2] == 'add' then
|
||||
local realm = GetCVar('realmName')
|
||||
aux_characters[realm] = aux_characters[realm] or {}
|
||||
@@ -55,7 +55,7 @@ function SlashCmdList.AUX(command)
|
||||
local name = string.gsub(strlower(arguments[i]), '^%l', strupper)
|
||||
if not aux_characters[realm][name] then
|
||||
aux_characters[realm][name] = true
|
||||
Aux.log('Character "'..name..'" added.')
|
||||
aux.log('Character "'..name..'" added.')
|
||||
end
|
||||
end
|
||||
elseif arguments[1] == 'chars' and arguments[2] == 'remove' then
|
||||
@@ -67,7 +67,7 @@ function SlashCmdList.AUX(command)
|
||||
local name = string.gsub(strlower(arguments[i]), '^%l', strupper)
|
||||
if aux_characters[realm][name] then
|
||||
aux_characters[realm][name] = nil
|
||||
Aux.log('Character "'..name..'" removed.')
|
||||
aux.log('Character "'..name..'" removed.')
|
||||
end
|
||||
end
|
||||
elseif arguments[1] == 'chars' then
|
||||
@@ -77,11 +77,11 @@ function SlashCmdList.AUX(command)
|
||||
tinsert(chars, name)
|
||||
end
|
||||
if getn(chars) > 0 then
|
||||
Aux.log('Your characters: "'..Aux.util.join(chars, ', ')..'".')
|
||||
aux.log('Your characters: "'..aux.util.join(chars, ', ')..'".')
|
||||
else
|
||||
Aux.log('You don\'t have any additional characters. To add your characters type "/aux chars add NAME1 NAME2 NAME3...".')
|
||||
aux.log('You don\'t have any additional characters. To add your characters type "/aux chars add NAME1 NAME2 NAME3...".')
|
||||
end
|
||||
else
|
||||
Aux.log('Unknown command: "'..command..'"')
|
||||
aux.log('Unknown command: "'..command..'"')
|
||||
end
|
||||
end
|
||||
+16
-16
@@ -1,42 +1,42 @@
|
||||
local m, public, private = Aux.module'stack'
|
||||
local m, public, private = aux.module'stack'
|
||||
|
||||
private.state = nil
|
||||
|
||||
function private.stack_size(slot)
|
||||
local container_item_info = Aux.info.container_item(unpack(slot))
|
||||
local container_item_info = aux.info.container_item(unpack(slot))
|
||||
return container_item_info and container_item_info.count or 0
|
||||
end
|
||||
|
||||
function private.charges(slot)
|
||||
local container_item_info = Aux.info.container_item(unpack(slot))
|
||||
local container_item_info = aux.info.container_item(unpack(slot))
|
||||
return container_item_info and container_item_info.charges
|
||||
end
|
||||
|
||||
function private.max_stack(slot)
|
||||
local container_item_info = Aux.info.container_item(unpack(slot))
|
||||
local container_item_info = aux.info.container_item(unpack(slot))
|
||||
return container_item_info and container_item_info.max_stack
|
||||
end
|
||||
|
||||
function private.locked(slot)
|
||||
local container_item_info = Aux.info.container_item(unpack(slot))
|
||||
local container_item_info = aux.info.container_item(unpack(slot))
|
||||
return container_item_info and container_item_info.locked
|
||||
end
|
||||
|
||||
function private.find_item_slot(partial)
|
||||
for slot in Aux.util.inventory() do
|
||||
if m.matching_item(slot, partial) and not Aux.util.eq(slot, m.state.target_slot) then
|
||||
for slot in aux.util.inventory() do
|
||||
if m.matching_item(slot, partial) and not aux.util.eq(slot, m.state.target_slot) then
|
||||
return slot
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function private.matching_item(slot, partial)
|
||||
local item_info = Aux.info.container_item(unpack(slot))
|
||||
return item_info and item_info.item_key == m.state.item_key and Aux.info.auctionable(item_info.tooltip) and (not partial or item_info.count < item_info.max_stack)
|
||||
local item_info = aux.info.container_item(unpack(slot))
|
||||
return item_info and item_info.item_key == m.state.item_key and aux.info.auctionable(item_info.tooltip) and (not partial or item_info.count < item_info.max_stack)
|
||||
end
|
||||
|
||||
function private.find_empty_slot()
|
||||
for slot, type in Aux.util.inventory() do
|
||||
for slot, type in aux.util.inventory() do
|
||||
if type == 1 and not GetContainerItemInfo(unpack(slot)) then
|
||||
return slot
|
||||
end
|
||||
@@ -44,7 +44,7 @@ function private.find_empty_slot()
|
||||
end
|
||||
|
||||
function private.find_charge_item_slot()
|
||||
for slot in Aux.util.inventory() do
|
||||
for slot in aux.util.inventory() do
|
||||
if m.matching_item(slot) and m.charges(slot) == m.state.target_size then
|
||||
return slot
|
||||
end
|
||||
@@ -53,7 +53,7 @@ end
|
||||
|
||||
function private.move_item(from_slot, to_slot, amount, k)
|
||||
if m.locked(from_slot) or m.locked(to_slot) then
|
||||
return Aux.control.wait(k)
|
||||
return aux.control.wait(k)
|
||||
end
|
||||
|
||||
amount = min(m.max_stack(from_slot) - m.stack_size(to_slot), m.stack_size(from_slot), amount)
|
||||
@@ -63,7 +63,7 @@ function private.move_item(from_slot, to_slot, amount, k)
|
||||
SplitContainerItem(from_slot[1], from_slot[2], amount)
|
||||
PickupContainerItem(unpack(to_slot))
|
||||
|
||||
return Aux.control.when(function() return m.stack_size(to_slot) == expected_size end, k)
|
||||
return aux.control.when(function() return m.stack_size(to_slot) == expected_size end, k)
|
||||
end
|
||||
|
||||
function private.process()
|
||||
@@ -105,20 +105,20 @@ end
|
||||
|
||||
function public.stop()
|
||||
if m.state then
|
||||
Aux.control.kill_thread(m.state.thread_id)
|
||||
aux.control.kill_thread(m.state.thread_id)
|
||||
local callback, slot = m.state.callback, m.state.target_slot
|
||||
if slot and not m.matching_item(slot) then
|
||||
slot = nil
|
||||
end
|
||||
m.state = nil
|
||||
Aux.safe_call(callback, slot)
|
||||
aux.safe_call(callback, slot)
|
||||
end
|
||||
end
|
||||
|
||||
function public.start(item_key, size, callback)
|
||||
m.stop()
|
||||
|
||||
local thread_id = Aux.control.thread(m.process)
|
||||
local thread_id = aux.control.thread(m.process)
|
||||
m.state = {
|
||||
thread_id = thread_id,
|
||||
item_key = item_key,
|
||||
|
||||
+22
-22
@@ -1,4 +1,4 @@
|
||||
local m, public, private = Aux.module'tooltip'
|
||||
local m, public, private = aux.module'tooltip'
|
||||
|
||||
aux_tooltip_value = true
|
||||
|
||||
@@ -9,12 +9,12 @@ private.game_tooltip_money = nil
|
||||
function public.LOAD()
|
||||
for func, hook in m.game_tooltip_hooks do
|
||||
local func, hook = func, hook
|
||||
Aux.hook(
|
||||
aux.hook(
|
||||
func,
|
||||
function(...)
|
||||
m.hooked_setter = true
|
||||
m.game_tooltip_money = 0
|
||||
local results = {Aux.orig[GameTooltip][func](unpack(arg)) }
|
||||
local results = {aux.orig[GameTooltip][func](unpack(arg)) }
|
||||
m.hooked_setter = false
|
||||
hook(unpack(arg))
|
||||
return unpack(results)
|
||||
@@ -44,13 +44,13 @@ function public.LOAD()
|
||||
end
|
||||
|
||||
function private.extend_tooltip(tooltip, hyperlink, quantity)
|
||||
local item_id, suffix_id = Aux.info.parse_hyperlink(hyperlink)
|
||||
local item_id, suffix_id = aux.info.parse_hyperlink(hyperlink)
|
||||
quantity = IsShiftKeyDown() and quantity or 1
|
||||
|
||||
if aux_tooltip_disenchant_source then
|
||||
local color = {r=0.7, g=0.7, b=0.7}
|
||||
|
||||
local type, range = Aux.disenchant.source(item_id)
|
||||
local type, range = aux.disenchant.source(item_id)
|
||||
|
||||
if type == 'CRYSTAL' then
|
||||
tooltip:AddLine(format('Can disenchant from level %s |cffa335eeEpic|r and |cff0070ddRare|r items.', range), color.r, color.g, color.b, true)
|
||||
@@ -63,9 +63,9 @@ function private.extend_tooltip(tooltip, hyperlink, quantity)
|
||||
end
|
||||
end
|
||||
|
||||
local item_info = Aux.info.item(item_id)
|
||||
local item_info = aux.info.item(item_id)
|
||||
if item_info then
|
||||
local distribution = Aux.disenchant.distribution(item_info.slot, item_info.quality, item_info.level)
|
||||
local distribution = aux.disenchant.distribution(item_info.slot, item_info.quality, item_info.level)
|
||||
|
||||
if getn(distribution) > 0 then
|
||||
|
||||
@@ -75,15 +75,15 @@ function private.extend_tooltip(tooltip, hyperlink, quantity)
|
||||
tooltip:AddLine('Disenchants into:', color.r, color.g, color.b)
|
||||
sort(distribution, function(a,b) return a.probability > b.probability end)
|
||||
for _, event in distribution do
|
||||
tooltip:AddLine(format(' %s%% %s (%s-%s)', event.probability * 100, Aux.info.display_name(event.item_id, true) or 'item:'..event.item_id, event.min_quantity, event.max_quantity), color.r, color.g, color.b)
|
||||
tooltip:AddLine(format(' %s%% %s (%s-%s)', event.probability * 100, aux.info.display_name(event.item_id, true) or 'item:'..event.item_id, event.min_quantity, event.max_quantity), color.r, color.g, color.b)
|
||||
end
|
||||
end
|
||||
|
||||
if aux_tooltip_disenchant_value then
|
||||
local color = {r=0.1, g=0.6, b=0.6}
|
||||
|
||||
local disenchant_value = Aux.disenchant.value(item_info.slot, item_info.quality, item_info.level)
|
||||
tooltip:AddLine('Disenchant Value: '..(disenchant_value and Aux.util.format_money(disenchant_value) or GRAY_FONT_COLOR_CODE..'---'..FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
|
||||
local disenchant_value = aux.disenchant.value(item_info.slot, item_info.quality, item_info.level)
|
||||
tooltip:AddLine('Disenchant Value: '..(disenchant_value and aux.util.format_money(disenchant_value) or GRAY_FONT_COLOR_CODE..'---'..FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -91,33 +91,33 @@ function private.extend_tooltip(tooltip, hyperlink, quantity)
|
||||
if aux_tooltip_vendor_buy then
|
||||
local color = {r=0.8, g=0.5, b=0.1}
|
||||
|
||||
local _, price, limited = Aux.cache.merchant_info(item_id)
|
||||
local _, price, limited = aux.cache.merchant_info(item_id)
|
||||
if price then
|
||||
tooltip:AddLine('Vendor Buy '..(limited and '(limited): ' or ': ')..Aux.util.format_money(price * quantity), color.r, color.g, color.b)
|
||||
tooltip:AddLine('Vendor Buy '..(limited and '(limited): ' or ': ')..aux.util.format_money(price * quantity), color.r, color.g, color.b)
|
||||
end
|
||||
end
|
||||
if aux_tooltip_vendor_sell then
|
||||
local color = {r=0.8, g=0.5, b=0.1}
|
||||
|
||||
local price = Aux.cache.merchant_info(item_id)
|
||||
local price = aux.cache.merchant_info(item_id)
|
||||
if price ~= 0 then
|
||||
tooltip:AddLine('Vendor Sell: '..(price and Aux.util.format_money(price * quantity) or GRAY_FONT_COLOR_CODE..'---'..FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
|
||||
tooltip:AddLine('Vendor Sell: '..(price and aux.util.format_money(price * quantity) or GRAY_FONT_COLOR_CODE..'---'..FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
|
||||
end
|
||||
end
|
||||
|
||||
local color = {r=1, g=1, b=0.6}
|
||||
|
||||
local auctionable = not item_info or Aux.info.auctionable(Aux.info.tooltip(function(tt) tt:SetHyperlink(item_info.itemstring) end), item_info.quality)
|
||||
local auctionable = not item_info or aux.info.auctionable(aux.info.tooltip(function(tt) tt:SetHyperlink(item_info.itemstring) end), item_info.quality)
|
||||
local item_key = (item_id or 0)..':'..(suffix_id or 0)
|
||||
|
||||
local value = Aux.history.value(item_key)
|
||||
local value = aux.history.value(item_key)
|
||||
if auctionable then
|
||||
if aux_tooltip_value then
|
||||
tooltip:AddLine('Value: '..(value and Aux.util.format_money(value * quantity) or GRAY_FONT_COLOR_CODE..'---'..FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
|
||||
tooltip:AddLine('Value: '..(value and aux.util.format_money(value * quantity) or GRAY_FONT_COLOR_CODE..'---'..FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
|
||||
end
|
||||
if aux_tooltip_daily then
|
||||
local market_value = Aux.history.market_value(item_key)
|
||||
tooltip:AddLine('Today: '..(market_value and Aux.util.format_money(market_value * quantity)..' ('..Aux.auction_listing.percentage_historical(Aux.util.round(market_value / value * 100))..')' or GRAY_FONT_COLOR_CODE..'---'..FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
|
||||
local market_value = aux.history.market_value(item_key)
|
||||
tooltip:AddLine('Today: '..(market_value and aux.util.format_money(market_value * quantity)..' ('..aux.auction_listing.percentage_historical(aux.util.round(market_value / value * 100))..')' or GRAY_FONT_COLOR_CODE..'---'..FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -179,7 +179,7 @@ end
|
||||
function m.game_tooltip_hooks:SetInboxItem(index)
|
||||
local name, _, quantity = GetInboxItem(index)
|
||||
|
||||
local id = name and Aux.cache.item_id(name)
|
||||
local id = name and aux.cache.item_id(name)
|
||||
if id then
|
||||
local _, itemstring, quality = GetItemInfo(id)
|
||||
local _, _, _, hex = GetItemQualityColor(tonumber(quality))
|
||||
@@ -241,9 +241,9 @@ end
|
||||
function m.game_tooltip_hooks:SetAuctionSellItem()
|
||||
local name, _, quantity, _, _, _ = GetAuctionSellItemInfo()
|
||||
if name then
|
||||
for slot in Aux.util.inventory() do
|
||||
for slot in aux.util.inventory() do
|
||||
local link = GetContainerItemLink(unpack(slot))
|
||||
if link and ({Aux.info.parse_hyperlink(link)})[5] == name then
|
||||
if link and ({aux.info.parse_hyperlink(link)})[5] == name then
|
||||
m.extend_tooltip(GameTooltip, link, quantity)
|
||||
return
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user