big refactoring
This commit is contained in:
+22
-22
@@ -6,12 +6,12 @@ MAX_ITEM_ID = 30000
|
||||
items_schema = {'record', '#', {name='string'}, {quality='number'}, {level='number'}, {class='string'}, {subclass='string'}, {slot='string'}, {max_stack='number'}, {texture='string'}}
|
||||
merchant_buy_schema = {'record', '#', {unit_price='number'}, {limited='boolean'} }
|
||||
|
||||
g.aux_items = {}
|
||||
g.aux_item_ids = {}
|
||||
g.aux_auctionable_items = {}
|
||||
g.aux_merchant_buy = {}
|
||||
g.aux_merchant_sell = {}
|
||||
g.aux_characters = {}
|
||||
_g.aux_items = {}
|
||||
_g.aux_item_ids = {}
|
||||
_g.aux_auctionable_items = {}
|
||||
_g.aux_merchant_buy = {}
|
||||
_g.aux_merchant_sell = {}
|
||||
_g.aux_characters = {}
|
||||
|
||||
function LOAD()
|
||||
scan_wdb()
|
||||
@@ -26,7 +26,7 @@ function LOAD()
|
||||
control.event_listener('NEW_AUCTION_UPDATE', function()
|
||||
for _, info in {info.auction_sell_item()} do
|
||||
for _, item_id in {cache.item_id(info.name)} do
|
||||
g.aux_merchant_sell[cache.item_id(info.name)] = info.vendor_price / (info.max_item_charges(item_id) or info.count)
|
||||
_g.aux_merchant_sell[cache.item_id(info.name)] = info.vendor_price / (info.max_item_charges(item_id) or info.count)
|
||||
end
|
||||
end
|
||||
end)
|
||||
@@ -78,15 +78,15 @@ end
|
||||
|
||||
function public.merchant_info(item_id)
|
||||
local buy_info
|
||||
if g.aux_merchant_buy[item_id] then
|
||||
buy_info = persistence.read(merchant_buy_schema, g.aux_merchant_buy[item_id])
|
||||
if _g.aux_merchant_buy[item_id] then
|
||||
buy_info = persistence.read(merchant_buy_schema, _g.aux_merchant_buy[item_id])
|
||||
end
|
||||
|
||||
return g.aux_merchant_sell[item_id], buy_info and buy_info.unit_price, buy_info and buy_info.limited
|
||||
return _g.aux_merchant_sell[item_id], buy_info and buy_info.unit_price, buy_info and buy_info.limited
|
||||
end
|
||||
|
||||
function public.item_info(item_id)
|
||||
local data_string = g.aux_items[item_id]
|
||||
local data_string = _g.aux_items[item_id]
|
||||
if data_string then
|
||||
local cached_data = persistence.read(items_schema, data_string)
|
||||
return {
|
||||
@@ -104,7 +104,7 @@ function public.item_info(item_id)
|
||||
end
|
||||
|
||||
function public.item_id(item_name)
|
||||
return g.aux_item_ids[strlower(item_name)]
|
||||
return _g.aux_item_ids[strlower(item_name)]
|
||||
end
|
||||
|
||||
function merchant_buy_scan()
|
||||
@@ -116,8 +116,8 @@ function merchant_buy_scan()
|
||||
if link then
|
||||
local item_id = info.parse_link(link)
|
||||
local new_unit_price, new_limited = price / count, stock >= 0
|
||||
if g.aux_merchant_buy[item_id] then
|
||||
local buy_info = persistence.read(merchant_buy_schema, g.aux_merchant_buy[item_id])
|
||||
if _g.aux_merchant_buy[item_id] then
|
||||
local buy_info = persistence.read(merchant_buy_schema, _g.aux_merchant_buy[item_id])
|
||||
|
||||
local unit_price
|
||||
if buy_info.limited and not new_limited then
|
||||
@@ -128,12 +128,12 @@ function merchant_buy_scan()
|
||||
unit_price = min(buy_info.unit_price, new_unit_price)
|
||||
end
|
||||
|
||||
g.aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, {
|
||||
_g.aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, {
|
||||
unit_price = unit_price,
|
||||
limited = buy_info.limited and new_limited,
|
||||
})
|
||||
else
|
||||
g.aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, {
|
||||
_g.aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, {
|
||||
unit_price = new_unit_price,
|
||||
limited = new_limited,
|
||||
})
|
||||
@@ -150,7 +150,7 @@ function merchant_sell_scan()
|
||||
for slot in inventory do
|
||||
local item_info = info.container_item(unpack(slot))
|
||||
if item_info then
|
||||
g.aux_merchant_sell[item_info.item_id] = item_info.tooltip_money / item_info.aux_quantity
|
||||
_g.aux_merchant_sell[item_info.item_id] = item_info.tooltip_money / item_info.aux_quantity
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -162,9 +162,9 @@ function scan_wdb(item_id)
|
||||
while processed <= 100 and item_id <= MAX_ITEM_ID do
|
||||
local itemstring = 'item:'..item_id
|
||||
local name, _, quality, level, class, subclass, max_stack, slot, texture = GetItemInfo(itemstring)
|
||||
if name and not g.aux_item_ids[strlower(name)] then
|
||||
g.aux_item_ids[strlower(name)] = item_id
|
||||
g.aux_items[item_id] = persistence.write(items_schema, {
|
||||
if name and not _g.aux_item_ids[strlower(name)] then
|
||||
_g.aux_item_ids[strlower(name)] = item_id
|
||||
_g.aux_items[item_id] = persistence.write(items_schema, {
|
||||
name = name,
|
||||
quality = quality,
|
||||
level = level,
|
||||
@@ -176,7 +176,7 @@ function scan_wdb(item_id)
|
||||
})
|
||||
local tooltip = info.tooltip(function(tt) tt:SetHyperlink(itemstring) end)
|
||||
if info.auctionable(tooltip, quality) then
|
||||
tinsert(g.aux_auctionable_items, strlower(name))
|
||||
tinsert(_g.aux_auctionable_items, strlower(name))
|
||||
end
|
||||
processed = processed + 1
|
||||
end
|
||||
@@ -187,7 +187,7 @@ function scan_wdb(item_id)
|
||||
local t0 = GetTime()
|
||||
control.thread(control.when, function() return GetTime() - t0 > 0.1 end, scan_wdb, item_id)
|
||||
else
|
||||
sort(g.aux_auctionable_items, function(a, b) return strlen(a) < strlen(b) or (strlen(a) == strlen(b) and a < b) end)
|
||||
sort(_g.aux_auctionable_items, function(a, b) return strlen(a) < strlen(b) or (strlen(a) == strlen(b) and a < b) end)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ do
|
||||
end
|
||||
end
|
||||
|
||||
function m.LOAD()
|
||||
function LOAD()
|
||||
armor = set(
|
||||
'INVTYPE_HEAD',
|
||||
'INVTYPE_NECK',
|
||||
@@ -72,7 +72,7 @@ end
|
||||
|
||||
function public.value(slot, quality, level)
|
||||
local expectation
|
||||
for _, event in m.distribution(slot, quality, level) do
|
||||
for _, event in distribution(slot, quality, level) do
|
||||
local value = history.value(event.item_id..':'..0)
|
||||
if not value then
|
||||
return
|
||||
@@ -84,19 +84,19 @@ function public.value(slot, quality, level)
|
||||
end
|
||||
|
||||
function public.distribution(slot, quality, level)
|
||||
if not (m.armor(slot) or m.weapon(slot)) or level == 0 then
|
||||
if not (armor(slot) or weapon(slot)) or level == 0 then
|
||||
return {}
|
||||
end
|
||||
|
||||
local function p(probability_armor, probability_weapon)
|
||||
if m.armor(slot) then
|
||||
if armor(slot) then
|
||||
return probability_armor
|
||||
elseif m.weapon(slot) then
|
||||
elseif weapon(slot) then
|
||||
return probability_weapon
|
||||
end
|
||||
end
|
||||
|
||||
if quality == m.UNCOMMON then
|
||||
if quality == UNCOMMON then
|
||||
if level <= 10 then
|
||||
return {
|
||||
{item_id=10940, min_quantity=1, max_quantity=2, probability=p(0.8, 0.2)},
|
||||
@@ -163,7 +163,7 @@ function public.distribution(slot, quality, level)
|
||||
{item_id=14344, min_quantity=1, max_quantity=1, probability=p(0.05, 0.03)},
|
||||
}
|
||||
end
|
||||
elseif quality == m.RARE then
|
||||
elseif quality == RARE then
|
||||
if level <= 20 then
|
||||
return {{item_id=10978, min_quantity=1, max_quantity=1, probability=1}}
|
||||
elseif level <= 25 then
|
||||
@@ -183,7 +183,7 @@ function public.distribution(slot, quality, level)
|
||||
elseif level <= 60 then
|
||||
return {{item_id=14344, min_quantity=1, max_quantity=1, probability=0.995}, {item_id=20725, min_quantity=1, max_quantity=1, probability=0.005}}
|
||||
end
|
||||
elseif quality == m.EPIC then
|
||||
elseif quality == EPIC then
|
||||
if level <= 40 then
|
||||
return {{item_id=11177, min_quantity=2, max_quantity=4, probability=1}}
|
||||
elseif level <= 45 then
|
||||
|
||||
+20
-20
@@ -10,7 +10,7 @@ function next_push()
|
||||
end
|
||||
|
||||
function new_record()
|
||||
return { next_push = m.next_push(), data_points = {} }
|
||||
return { next_push = next_push(), data_points = {} }
|
||||
end
|
||||
|
||||
function load_data()
|
||||
@@ -20,31 +20,31 @@ function load_data()
|
||||
end
|
||||
|
||||
function read_record(item_key)
|
||||
local data = m.load_data()
|
||||
local data = load_data()
|
||||
|
||||
local record
|
||||
if data[item_key] then
|
||||
record = persistence.read(history_schema, data[item_key])
|
||||
else
|
||||
record = m.new_record()
|
||||
record = new_record()
|
||||
end
|
||||
|
||||
if record.next_push <= time() then
|
||||
m.push_record(record)
|
||||
m.write_record(item_key, record)
|
||||
push_record(record)
|
||||
write_record(item_key, record)
|
||||
end
|
||||
|
||||
return record
|
||||
end
|
||||
|
||||
function write_record(item_key, record)
|
||||
m.value_cache[item_key] = nil
|
||||
local data = m.load_data()
|
||||
value_cache[item_key] = nil
|
||||
local data = load_data()
|
||||
data[item_key] = persistence.write(history_schema, record)
|
||||
end
|
||||
|
||||
function public.process_auction(auction_record)
|
||||
local item_record = m.read_record(auction_record.item_key)
|
||||
local item_record = read_record(auction_record.item_key)
|
||||
|
||||
local unit_bid_price = ceil(auction_record.bid_price / auction_record.aux_quantity)
|
||||
local unit_buyout_price = ceil(auction_record.buyout_price / auction_record.aux_quantity)
|
||||
@@ -55,17 +55,17 @@ function public.process_auction(auction_record)
|
||||
|
||||
item_record.daily_max_price = max(item_record.daily_max_price or 0, unit_buyout_price, unit_bid_price)
|
||||
|
||||
m.write_record(auction_record.item_key, item_record)
|
||||
write_record(auction_record.item_key, item_record)
|
||||
end
|
||||
|
||||
function public.price_data(item_key)
|
||||
local item_record = m.read_record(item_key)
|
||||
local item_record = read_record(item_key)
|
||||
return item_record.daily_min_buyout, item_record.daily_max_price, item_record.data_points
|
||||
end
|
||||
|
||||
function public.value(item_key)
|
||||
if not m.value_cache[item_key] or m.value_cache[item_key].next_push <= time() then
|
||||
local item_record = m.read_record(item_key)
|
||||
if not value_cache[item_key] or value_cache[item_key].next_push <= time() then
|
||||
local item_record = read_record(item_key)
|
||||
|
||||
local value
|
||||
if getn(item_record.data_points) > 0 then
|
||||
@@ -80,20 +80,20 @@ function public.value(item_key)
|
||||
weighted_value.weight = weighted_value.weight / total_weight
|
||||
end
|
||||
|
||||
value = m.weighted_median(weighted_values)
|
||||
value = weighted_median(weighted_values)
|
||||
else
|
||||
value = m.calculate_market_value(item_record)
|
||||
value = calculate_market_value(item_record)
|
||||
end
|
||||
|
||||
m.value_cache[item_key] = {value=value, next_push=item_record.next_push}
|
||||
value_cache[item_key] = {value=value, next_push=item_record.next_push}
|
||||
end
|
||||
|
||||
return m.value_cache[item_key].value
|
||||
return value_cache[item_key].value
|
||||
end
|
||||
|
||||
function public.market_value(item_key)
|
||||
local item_record = m.read_record(item_key)
|
||||
return m.calculate_market_value(item_record)
|
||||
local item_record = read_record(item_key)
|
||||
return calculate_market_value(item_record)
|
||||
end
|
||||
|
||||
function calculate_market_value(item_record)
|
||||
@@ -118,7 +118,7 @@ end
|
||||
|
||||
function push_record(item_record)
|
||||
|
||||
local market_value = m.calculate_market_value(item_record)
|
||||
local market_value = calculate_market_value(item_record)
|
||||
if market_value then
|
||||
tinsert(item_record.data_points, 1, { market_value = market_value, time = item_record.next_push })
|
||||
while getn(item_record.data_points) > 11 do
|
||||
@@ -128,5 +128,5 @@ function push_record(item_record)
|
||||
|
||||
item_record.daily_min_buyout = nil
|
||||
item_record.daily_max_price = nil
|
||||
item_record.next_push = m.next_push()
|
||||
item_record.next_push = next_push()
|
||||
end
|
||||
+17
-17
@@ -3,7 +3,7 @@ aux.module 'post'
|
||||
state = nil
|
||||
|
||||
function process()
|
||||
if m.state.posted < m.state.count then
|
||||
if state.posted < state.count then
|
||||
|
||||
local stacking_complete
|
||||
|
||||
@@ -11,21 +11,21 @@ function process()
|
||||
control.when(signal_received, function()
|
||||
local slot = signal_received()[1]
|
||||
if slot then
|
||||
return m.post_auction(slot, m.process)
|
||||
return post_auction(slot, process)
|
||||
else
|
||||
return m.stop()
|
||||
return stop()
|
||||
end
|
||||
end)
|
||||
|
||||
return stack.start(m.state.item_key, m.state.stack_size, send_signal)
|
||||
return stack.start(state.item_key, state.stack_size, send_signal)
|
||||
end
|
||||
|
||||
return m.stop()
|
||||
return stop()
|
||||
end
|
||||
|
||||
function post_auction(slot, k)
|
||||
local item_info = info.container_item(unpack(slot))
|
||||
if item_info.item_key == m.state.item_key and info.auctionable(item_info.tooltip) and item_info.aux_quantity == m.state.stack_size then
|
||||
if item_info.item_key == state.item_key and info.auctionable(item_info.tooltip) and item_info.aux_quantity == state.stack_size then
|
||||
|
||||
ClearCursor()
|
||||
ClickAuctionSellItemButton()
|
||||
@@ -34,11 +34,11 @@ function post_auction(slot, k)
|
||||
ClickAuctionSellItemButton()
|
||||
ClearCursor()
|
||||
|
||||
StartAuction(max(1, round(m.state.unit_start_price * item_info.aux_quantity)), round(m.state.unit_buyout_price * item_info.aux_quantity), m.state.duration)
|
||||
StartAuction(max(1, round(state.unit_start_price * item_info.aux_quantity)), round(state.unit_buyout_price * item_info.aux_quantity), state.duration)
|
||||
|
||||
local send_signal, signal_received = signal()
|
||||
control.when(signal_received, function()
|
||||
m.state.posted = m.state.posted + 1
|
||||
state.posted = state.posted + 1
|
||||
return k()
|
||||
end)
|
||||
|
||||
@@ -50,18 +50,18 @@ function post_auction(slot, k)
|
||||
end
|
||||
end)
|
||||
else
|
||||
return m.stop()
|
||||
return stop()
|
||||
end
|
||||
end
|
||||
|
||||
function public.stop()
|
||||
if m.state then
|
||||
control.kill_thread(m.state.thread_id)
|
||||
if state then
|
||||
control.kill_thread(state.thread_id)
|
||||
|
||||
local callback = m.state.callback
|
||||
local posted = m.state.posted
|
||||
local callback = state.callback
|
||||
local posted = state.posted
|
||||
|
||||
m.state = nil
|
||||
state = nil
|
||||
|
||||
if callback then
|
||||
callback(posted)
|
||||
@@ -70,11 +70,11 @@ function public.stop()
|
||||
end
|
||||
|
||||
function public.start(item_key, stack_size, duration, unit_start_price, unit_buyout_price, count, callback)
|
||||
m.stop()
|
||||
stop()
|
||||
|
||||
local thread_id = control.thread(m.process)
|
||||
local thread_id = control.thread(process)
|
||||
|
||||
m.state = {
|
||||
state = {
|
||||
thread_id = thread_id,
|
||||
item_key = item_key,
|
||||
stack_size = stack_size,
|
||||
|
||||
+2
-2
@@ -145,7 +145,7 @@ function scan_page(i)
|
||||
end
|
||||
|
||||
local auction_info = info.auction(i, state.params.type)
|
||||
if auction_info and (auction_info.owner or state.params.ignore_owner or g.aux_ignore_owner) then
|
||||
if auction_info and (auction_info.owner or state.params.ignore_owner or _g.aux_ignore_owner) then
|
||||
auction_info.index = i
|
||||
auction_info.page = state.page
|
||||
auction_info.blizzard_query = query.blizzard_query
|
||||
@@ -216,7 +216,7 @@ function wait_for_list_results(send_signal, signal_received)
|
||||
last_update = GetTime()
|
||||
updated = true
|
||||
end)
|
||||
local ignore_owner = state.params.ignore_owner or g.aux_ignore_owner
|
||||
local ignore_owner = state.params.ignore_owner or _g.aux_ignore_owner
|
||||
return control.thread(control.when, function()
|
||||
-- short circuiting order important, owner_data_complete must be called iif an update has happened.
|
||||
local ok = updated and (ignore_owner or owner_data_complete('list')) or last_update and GetTime() - last_update > 5
|
||||
|
||||
+29
-29
@@ -9,71 +9,71 @@ function SlashCmdList.AUX(command)
|
||||
persistence.load_dataset().post = nil
|
||||
log 'Post settings cleared.'
|
||||
elseif arguments[1] == 'clear' and arguments[2] == 'datasets' then
|
||||
g.aux_datasets = {}
|
||||
_g.aux_datasets = {}
|
||||
log 'Datasets cleared.'
|
||||
elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'buy' then
|
||||
g.aux_merchant_buy = {}
|
||||
_g.aux_merchant_buy = {}
|
||||
log 'Merchant buy prices cleared.'
|
||||
elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'sell' then
|
||||
g.aux_merchant_sell = {}
|
||||
_g.aux_merchant_sell = {}
|
||||
log 'Merchant sell prices cleared.'
|
||||
elseif arguments[1] == 'clear' and arguments[2] == 'item' and arguments[3] == 'cache' then
|
||||
g.aux_items = {}
|
||||
g.aux_item_ids = {}
|
||||
g.aux_auctionable_items = {}
|
||||
_g.aux_items = {}
|
||||
_g.aux_item_ids = {}
|
||||
_g.aux_auctionable_items = {}
|
||||
log 'Item cache cleared.'
|
||||
elseif arguments[1] == 'populate' and arguments[2] == 'wdb' then
|
||||
cache.populate_wdb()
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'value' then
|
||||
g.aux_tooltip_value = not g.aux_tooltip_value
|
||||
log('Historical value in tooltip '..(g.aux_tooltip_value and 'enabled' or 'disabled')..'.')
|
||||
_g.aux_tooltip_value = not _g.aux_tooltip_value
|
||||
log('Historical value in tooltip '..(_g.aux_tooltip_value and 'enabled' or 'disabled')..'.')
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'daily' then
|
||||
g.aux_tooltip_daily = not g.aux_tooltip_daily
|
||||
log('Market value in tooltip '..(g.aux_tooltip_daily and 'enabled' or 'disabled')..'.')
|
||||
_g.aux_tooltip_daily = not _g.aux_tooltip_daily
|
||||
log('Market value in tooltip '..(_g.aux_tooltip_daily and 'enabled' or 'disabled')..'.')
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'vendor' and arguments[3] == 'buy' then
|
||||
g.aux_tooltip_vendor_buy = not g.aux_tooltip_vendor_buy
|
||||
log('Vendor buy price in tooltip '..(g.aux_tooltip_vendor_buy and 'enabled' or 'disabled')..'.')
|
||||
_g.aux_tooltip_vendor_buy = not _g.aux_tooltip_vendor_buy
|
||||
log('Vendor buy price in tooltip '..(_g.aux_tooltip_vendor_buy and 'enabled' or 'disabled')..'.')
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'vendor' and arguments[3] == 'sell' then
|
||||
g.aux_tooltip_vendor_sell = not g.aux_tooltip_vendor_sell
|
||||
log('Vendor sell price in tooltip '..(g.aux_tooltip_vendor_sell and 'enabled' or 'disabled')..'.')
|
||||
_g.aux_tooltip_vendor_sell = not _g.aux_tooltip_vendor_sell
|
||||
log('Vendor sell price in tooltip '..(_g.aux_tooltip_vendor_sell and 'enabled' or 'disabled')..'.')
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'value' then
|
||||
g.aux_tooltip_disenchant_value = not g.aux_tooltip_disenchant_value
|
||||
log('Disenchant value in tooltip '..(g.aux_tooltip_disenchant_value and 'enabled' or 'disabled')..'.')
|
||||
_g.aux_tooltip_disenchant_value = not _g.aux_tooltip_disenchant_value
|
||||
log('Disenchant value in tooltip '..(_g.aux_tooltip_disenchant_value and 'enabled' or 'disabled')..'.')
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'distribution' then
|
||||
g.aux_tooltip_disenchant_distribution = not g.aux_tooltip_disenchant_distribution
|
||||
log('Disenchant distribution in tooltip '..(g.aux_tooltip_disenchant_distribution and 'enabled' or 'disabled')..'.')
|
||||
_g.aux_tooltip_disenchant_distribution = not _g.aux_tooltip_disenchant_distribution
|
||||
log('Disenchant distribution in tooltip '..(_g.aux_tooltip_disenchant_distribution and 'enabled' or 'disabled')..'.')
|
||||
elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'source' then
|
||||
g.aux_tooltip_disenchant_source = not g.aux_tooltip_disenchant_source
|
||||
log('Disenchant source in tooltip '..(g.aux_tooltip_disenchant_source and 'enabled' or 'disabled')..'.')
|
||||
_g.aux_tooltip_disenchant_source = not _g.aux_tooltip_disenchant_source
|
||||
log('Disenchant source in tooltip '..(_g.aux_tooltip_disenchant_source and 'enabled' or 'disabled')..'.')
|
||||
elseif arguments[1] == 'ignore' and arguments[2] == 'owner' then
|
||||
g.aux_ignore_owner = not g.aux_ignore_owner
|
||||
log('Ignoring of owner '..(g.aux_ignore_owner and 'enabled' or 'disabled')..'.')
|
||||
_g.aux_ignore_owner = not _g.aux_ignore_owner
|
||||
log('Ignoring of owner '..(_g.aux_ignore_owner and 'enabled' or 'disabled')..'.')
|
||||
elseif arguments[1] == 'chars' and arguments[2] == 'add' then
|
||||
local realm = GetCVar 'realmName'
|
||||
g.aux_characters[realm] = g.aux_characters[realm] or {}
|
||||
_g.aux_characters[realm] = _g.aux_characters[realm] or {}
|
||||
for i=3,getn(arguments) do
|
||||
local name = string.gsub(strlower(arguments[i]), '^%l', strupper)
|
||||
if not g.aux_characters[realm][name] then
|
||||
g.aux_characters[realm][name] = true
|
||||
if not _g.aux_characters[realm][name] then
|
||||
_g.aux_characters[realm][name] = true
|
||||
log('Character "'..name..'" added.')
|
||||
end
|
||||
end
|
||||
elseif arguments[1] == 'chars' and arguments[2] == 'remove' then
|
||||
local realm = GetCVar 'realmName'
|
||||
if not g.aux_characters[realm] then
|
||||
if not _g.aux_characters[realm] then
|
||||
return
|
||||
end
|
||||
for i=3,getn(arguments) do
|
||||
local name = string.gsub(strlower(arguments[i]), '^%l', strupper)
|
||||
if g.aux_characters[realm][name] then
|
||||
g.aux_characters[realm][name] = nil
|
||||
if _g.aux_characters[realm][name] then
|
||||
_g.aux_characters[realm][name] = nil
|
||||
log('Character "'..name..'" removed.')
|
||||
end
|
||||
end
|
||||
elseif arguments[1] == 'chars' then
|
||||
local realm = GetCVar 'realmName'
|
||||
local chars = {}
|
||||
for name in g.aux_characters[realm] or {} do
|
||||
for name in _g.aux_characters[realm] or {} do
|
||||
tinsert(chars, name)
|
||||
end
|
||||
if getn(chars) > 0 then
|
||||
|
||||
+35
-35
@@ -24,7 +24,7 @@ end
|
||||
|
||||
function find_item_slot(partial)
|
||||
for slot in inventory do
|
||||
if m.matching_item(slot, partial) and not eq(slot, m.state.target_slot) then
|
||||
if matching_item(slot, partial) and not eq(slot, state.target_slot) then
|
||||
return slot
|
||||
end
|
||||
end
|
||||
@@ -32,7 +32,7 @@ end
|
||||
|
||||
function matching_item(slot, partial)
|
||||
local item_info = info.container_item(unpack(slot))
|
||||
return item_info and item_info.item_key == m.state.item_key and info.auctionable(item_info.tooltip) and (not partial or item_info.count < item_info.max_stack)
|
||||
return item_info and item_info.item_key == state.item_key and info.auctionable(item_info.tooltip) and (not partial or item_info.count < item_info.max_stack)
|
||||
end
|
||||
|
||||
function find_empty_slot()
|
||||
@@ -45,81 +45,81 @@ end
|
||||
|
||||
function find_charge_item_slot()
|
||||
for slot in inventory do
|
||||
if m.matching_item(slot) and m.charges(slot) == m.state.target_size then
|
||||
if matching_item(slot) and charges(slot) == state.target_size then
|
||||
return slot
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function move_item(from_slot, to_slot, amount, k)
|
||||
if m.locked(from_slot) or m.locked(to_slot) then
|
||||
if locked(from_slot) or locked(to_slot) then
|
||||
return control.wait(k)
|
||||
end
|
||||
|
||||
amount = min(m.max_stack(from_slot) - m.stack_size(to_slot), m.stack_size(from_slot), amount)
|
||||
local expected_size = m.stack_size(to_slot) + amount
|
||||
amount = min(max_stack(from_slot) - stack_size(to_slot), stack_size(from_slot), amount)
|
||||
local expected_size = stack_size(to_slot) + amount
|
||||
|
||||
ClearCursor()
|
||||
SplitContainerItem(from_slot[1], from_slot[2], amount)
|
||||
PickupContainerItem(unpack(to_slot))
|
||||
|
||||
return control.when(function() return m.stack_size(to_slot) == expected_size end, k)
|
||||
return control.when(function() return stack_size(to_slot) == expected_size end, k)
|
||||
end
|
||||
|
||||
function process()
|
||||
|
||||
if not m.state.target_slot or not m.matching_item(m.state.target_slot) then
|
||||
m.state.target_slot = m.find_item_slot()
|
||||
if not m.state.target_slot then
|
||||
return m.stop()
|
||||
if not state.target_slot or not matching_item(state.target_slot) then
|
||||
state.target_slot = find_item_slot()
|
||||
if not state.target_slot then
|
||||
return stop()
|
||||
end
|
||||
end
|
||||
|
||||
if m.charges(m.state.target_slot) then
|
||||
m.state.target_slot = m.find_charge_item_slot()
|
||||
return m.stop()
|
||||
if charges(state.target_slot) then
|
||||
state.target_slot = find_charge_item_slot()
|
||||
return stop()
|
||||
end
|
||||
if m.stack_size(m.state.target_slot) > m.state.target_size then
|
||||
local slot = m.find_item_slot(true) or m.find_empty_slot()
|
||||
if stack_size(state.target_slot) > state.target_size then
|
||||
local slot = find_item_slot(true) or find_empty_slot()
|
||||
if slot then
|
||||
return m.move_item(
|
||||
m.state.target_slot,
|
||||
return move_item(
|
||||
state.target_slot,
|
||||
slot,
|
||||
m.stack_size(m.state.target_slot) - m.state.target_size,
|
||||
m.process
|
||||
stack_size(state.target_slot) - state.target_size,
|
||||
process
|
||||
)
|
||||
end
|
||||
elseif m.stack_size(m.state.target_slot) < m.state.target_size then
|
||||
local slot = m.find_item_slot()
|
||||
elseif stack_size(state.target_slot) < state.target_size then
|
||||
local slot = find_item_slot()
|
||||
if slot then
|
||||
return m.move_item(
|
||||
return move_item(
|
||||
slot,
|
||||
m.state.target_slot,
|
||||
m.state.target_size - m.stack_size(m.state.target_slot),
|
||||
m.process
|
||||
state.target_slot,
|
||||
state.target_size - stack_size(state.target_slot),
|
||||
process
|
||||
)
|
||||
end
|
||||
end
|
||||
return m.stop()
|
||||
return stop()
|
||||
end
|
||||
|
||||
function public.stop()
|
||||
if m.state then
|
||||
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
|
||||
if state then
|
||||
control.kill_thread(state.thread_id)
|
||||
local callback, slot = state.callback, state.target_slot
|
||||
if slot and not matching_item(slot) then
|
||||
slot = nil
|
||||
end
|
||||
m.state = nil
|
||||
state = nil
|
||||
call(callback, slot)
|
||||
end
|
||||
end
|
||||
|
||||
function public.start(item_key, size, callback)
|
||||
m.stop()
|
||||
stop()
|
||||
|
||||
local thread_id = control.thread(m.process)
|
||||
m.state = {
|
||||
local thread_id = control.thread(process)
|
||||
state = {
|
||||
thread_id = thread_id,
|
||||
item_key = item_key,
|
||||
target_size = size,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
aux.module 'tooltip'
|
||||
|
||||
g.aux_tooltip_value = true
|
||||
_g.aux_tooltip_value = true
|
||||
|
||||
game_tooltip_hooks = {}
|
||||
hooked_setter = nil
|
||||
@@ -47,7 +47,7 @@ function extend_tooltip(tooltip, link, quantity)
|
||||
local item_id, suffix_id = info.parse_link(link)
|
||||
quantity = IsShiftKeyDown() and quantity or 1
|
||||
|
||||
if g.aux_tooltip_disenchant_source then
|
||||
if _g.aux_tooltip_disenchant_source then
|
||||
local color = {r=0.7, g=0.7, b=0.7}
|
||||
|
||||
local type, range = disenchant.source(item_id)
|
||||
@@ -69,7 +69,7 @@ function extend_tooltip(tooltip, link, quantity)
|
||||
|
||||
if getn(distribution) > 0 then
|
||||
|
||||
if g.aux_tooltip_disenchant_distribution then
|
||||
if _g.aux_tooltip_disenchant_distribution then
|
||||
local color = {r=0.8, g=0.8, b=0.2}
|
||||
|
||||
tooltip:AddLine('Disenchants into:', color.r, color.g, color.b)
|
||||
@@ -79,7 +79,7 @@ function extend_tooltip(tooltip, link, quantity)
|
||||
end
|
||||
end
|
||||
|
||||
if g.aux_tooltip_disenchant_value then
|
||||
if _g.aux_tooltip_disenchant_value then
|
||||
local color = {r=0.1, g=0.6, b=0.6}
|
||||
|
||||
local disenchant_value = disenchant.value(item_info.slot, item_info.quality, item_info.level)
|
||||
@@ -88,7 +88,7 @@ function extend_tooltip(tooltip, link, quantity)
|
||||
end
|
||||
end
|
||||
|
||||
if g.aux_tooltip_vendor_buy then
|
||||
if _g.aux_tooltip_vendor_buy then
|
||||
local color = {r=0.8, g=0.5, b=0.1}
|
||||
|
||||
local _, price, limited = cache.merchant_info(item_id)
|
||||
@@ -96,7 +96,7 @@ function extend_tooltip(tooltip, link, quantity)
|
||||
tooltip:AddLine('Vendor Buy '..(limited and '(limited): ' or ': ')..money.to_string2(price * quantity), color.r, color.g, color.b)
|
||||
end
|
||||
end
|
||||
if g.aux_tooltip_vendor_sell then
|
||||
if _g.aux_tooltip_vendor_sell then
|
||||
local color = {r=0.8, g=0.5, b=0.1}
|
||||
|
||||
local price = cache.merchant_info(item_id)
|
||||
@@ -112,10 +112,10 @@ function extend_tooltip(tooltip, link, quantity)
|
||||
|
||||
local value = history.value(item_key)
|
||||
if auctionable then
|
||||
if g.aux_tooltip_value then
|
||||
if _g.aux_tooltip_value then
|
||||
tooltip:AddLine('Value: '..(value and money.to_string2(value * quantity) or GRAY_FONT_COLOR_CODE..'---'..FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
|
||||
end
|
||||
if g.aux_tooltip_daily then
|
||||
if _g.aux_tooltip_daily then
|
||||
local market_value = history.market_value(item_key)
|
||||
tooltip:AddLine('Today: '..(market_value and money.to_string2(market_value * quantity)..' ('..auction_listing.percentage_historical(round(market_value / value * 100))..')' or GRAY_FONT_COLOR_CODE..'---'..FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user