imported the util core module

This commit is contained in:
Manuel Simon Hirsig
2016-08-19 17:18:04 +02:00
parent e334a444df
commit 95250002a5
24 changed files with 93 additions and 93 deletions
+1 -1
View File
@@ -147,7 +147,7 @@ function merchant_buy_scan()
end
function merchant_sell_scan()
for slot in aux.util.inventory() do
for slot in inventory() do
local item_info = aux.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
+2 -2
View File
@@ -41,7 +41,7 @@ do
end
function m.LOAD()
armor = aux.util.set(
armor = set(
'INVTYPE_HEAD',
'INVTYPE_NECK',
'INVTYPE_SHOULDER',
@@ -59,7 +59,7 @@ function m.LOAD()
'INVTYPE_HOLDABLE'
)
weapon = aux.util.set(
weapon = set(
'INVTYPE_2HWEAPON' ,
'INVTYPE_WEAPONMAINHAND',
'INVTYPE_WEAPON',
+1 -1
View File
@@ -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^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
+3 -3
View File
@@ -7,7 +7,7 @@ function process()
local stacking_complete
local send_signal, signal_received = aux.util.signal()
local send_signal, signal_received = signal()
aux.control.when(signal_received, function()
local slot = signal_received()[1]
if slot then
@@ -34,9 +34,9 @@ function 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, round(m.state.unit_start_price * item_info.aux_quantity)), round(m.state.unit_buyout_price * item_info.aux_quantity), m.state.duration)
local send_signal, signal_received = aux.util.signal()
local send_signal, signal_received = signal()
aux.control.when(signal_received, function()
m.state.posted = m.state.posted + 1
return k()
+6 -6
View File
@@ -38,7 +38,7 @@ do
end
function accessor.state()
local _, state = next(aux.util.filter(scan_states, function(state) return state.id == aux.control.thread_id end))
local _, state = next(filter(scan_states, function(state) return state.id == aux.control.thread_id end))
return state
end
end
@@ -48,7 +48,7 @@ function accessor.query()
end
function wait_for_callback(...)
local send_signal, signal_received = aux.util.signal()
local send_signal, signal_received = signal()
local suspended
local ret
@@ -154,10 +154,10 @@ function scan_page(i)
aux.history.process_auction(auction_info)
if aux.call(state.params.auto_buy_validator, auction_info) then
local send_signal, signal_received = aux.util.signal()
local send_signal, signal_received = signal()
aux.control.when(signal_received, recurse)
aux.place_bid(auction_info.query_type, auction_info.index, auction_info.buyout_price, aux.C(send_signal, true))
return aux.control.thread(aux.control.when, aux.util.later(GetTime(), 10), aux.C(send_signal, false))
return aux.control.thread(aux.control.when, later(GetTime(), 10), aux.C(send_signal, false))
elseif not query.validator or query.validator(auction_info) then
return wait_for_callback(state.params.on_auction, auction_info, function(removed)
if removed then
@@ -173,8 +173,8 @@ function scan_page(i)
end
function wait_for_results()
local timeout = aux.util.later(state.last_query_time, 10)
local send_signal, signal_received = aux.util.signal()
local timeout = later(state.last_query_time, 10)
local send_signal, signal_received = signal()
aux.control.when(signal_received, function()
if timeout() then
return submit_query()
+1 -1
View File
@@ -1,7 +1,7 @@
SLASH_AUX1 = '/aux'
function SlashCmdList.AUX(command)
if not command then return end
local arguments = aux.util.tokenize(command)
local arguments = tokenize(command)
if arguments[1] == 'clear' and arguments[2] == 'history' then
aux.persistence.load_dataset().history = nil
aux.log 'History cleared.'
+4 -4
View File
@@ -23,8 +23,8 @@ function locked(slot)
end
function 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 inventory() do
if m.matching_item(slot, partial) and not eq(slot, m.state.target_slot) then
return slot
end
end
@@ -36,7 +36,7 @@ function matching_item(slot, partial)
end
function find_empty_slot()
for slot, type in aux.util.inventory() do
for slot, type in inventory() do
if type == 1 and not GetContainerItemInfo(unpack(slot)) then
return slot
end
@@ -44,7 +44,7 @@ function find_empty_slot()
end
function find_charge_item_slot()
for slot in aux.util.inventory() do
for slot in inventory() do
if m.matching_item(slot) and m.charges(slot) == m.state.target_size then
return slot
end
+2 -2
View File
@@ -117,7 +117,7 @@ function extend_tooltip(tooltip, link, quantity)
end
if g.aux_tooltip_daily then
local market_value = aux.history.market_value(item_key)
tooltip:AddLine('Today: '..(market_value and aux.money.to_string2(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)
tooltip:AddLine('Today: '..(market_value and aux.money.to_string2(market_value * quantity)..' ('..aux.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
end
@@ -241,7 +241,7 @@ end
function m.game_tooltip_hooks:SetAuctionSellItem()
local name, _, quantity, _, _, _ = GetAuctionSellItemInfo()
if name then
for slot in aux.util.inventory() do
for slot in inventory() do
local link = GetContainerItemLink(unpack(slot))
if link and ({aux.info.parse_link(link)})[5] == name then
m.extend_tooltip(GameTooltip, link, quantity)
+1 -1
View File
@@ -20,7 +20,7 @@ end
function UPDATE()
for _, listener in m.listeners do
if not aux.util.any(m.listeners, function(l) return not l.killed and l.event == listener.event end) then
if not any(m.listeners, function(l) return not l.killed and l.event == listener.event end) then
m.event_frame:UnregisterEvent(listener.event)
end
end
+4 -4
View File
@@ -201,7 +201,7 @@ do
break
end
local item_id, suffix_id = m.info.parse_link(link)
local count = aux.util.select(3, GetCraftReagentInfo(id, i))
local count = select(3, GetCraftReagentInfo(id, i))
local _, price, limited = m.cache.merchant_info(item_id)
local value = price and not limited and price or m.history.value(item_id..':'..suffix_id)
if not value then
@@ -233,7 +233,7 @@ do
break
end
local item_id, suffix_id = m.info.parse_link(link)
local count = aux.util.select(3, GetTradeSkillReagentInfo(id, i))
local count = select(3, GetTradeSkillReagentInfo(id, i))
local _, price, limited = m.cache.merchant_info(item_id)
local value = price and not limited and price or m.history.value(item_id..':'..suffix_id)
if not value then
@@ -284,7 +284,7 @@ function SetItemRef(...)
if arg[3] ~= 'RightButton' or not m.index(active_tab, 'env', 'CLICK_LINK') or not strfind(arg[1], '^item:%d+') then
return m.orig.SetItemRef(unpack(arg))
end
for item_info in aux.util.present(m.info.item(tonumber(({strfind(arg[1], '^item:(%d+)')})[3]))) do
for item_info in present(m.info.item(tonumber(({strfind(arg[1], '^item:(%d+)')})[3]))) do
return m.active_tab.env.CLICK_LINK(item_info)
end
end
@@ -293,7 +293,7 @@ function UseContainerItem(...)
if m.modified() or not m.index(active_tab, 'env', 'USE_ITEM') then
return m.orig.UseContainerItem(unpack(arg))
end
for item_info in aux.util.present(m.info.container_item(arg[1], arg[2])) do
for item_info in present(m.info.container_item(arg[1], arg[2])) do
return m.active_tab.env.USE_ITEM(item_info)
end
end
+1 -1
View File
@@ -37,7 +37,7 @@ do
if getn(self.private.table) == 0 then
return self.public
else
local color = aux.util.copy(self.private.table)
local color = copy(self.private.table)
self.private.table = config.colors
return self.private.callback(color)
end
+7 -7
View File
@@ -524,9 +524,9 @@ function record_percentage(record)
local historical_value = aux.history.value(record.item_key) or 0
if historical_value > 0 then
if record.unit_buyout_price > 0 then
return aux.util.round(100 * record.unit_buyout_price / historical_value, 1)
return round(100 * record.unit_buyout_price / historical_value, 1)
end
return nil, aux.util.round(100 * record.unit_bid_price / historical_value, 1)
return nil, round(100 * record.unit_bid_price / historical_value, 1)
end
end
@@ -679,7 +679,7 @@ local methods = {
-- ============================================================================
UpdateRowInfo = function(self)
aux.util.wipe(self.rowInfo)
wipe(self.rowInfo)
self.rowInfo.numDisplayRows = 0
self.isSorted = nil
self:SetSelectedRecord(nil, true)
@@ -847,7 +847,7 @@ local methods = {
-- ============================================================================
Reset = function(rt)
aux.util.wipe(rt.expanded)
wipe(rt.expanded)
rt:UpdateRowInfo()
rt:UpdateRows()
rt:SetSelectedRecord()
@@ -892,7 +892,7 @@ local methods = {
end,
RemoveAuctionRecord = function(self, record)
local index = aux.util.key(record, self.records)
local index = key(record, self.records)
if index then
tremove(self.records, index)
end
@@ -902,7 +902,7 @@ local methods = {
RemoveSelectedRecord = function(self, count)
count = count or 1
for i=1, count do
local index = aux.util.key(self.selected, self.records)
local index = key(self.selected, self.records)
if index then
tremove(self.records, index)
end
@@ -919,7 +919,7 @@ local methods = {
end,
ContainsRecord = function(rt, record)
if aux.util.key(record, rt.records) then
if key(record, rt.records) then
return true
end
end,
+10 -10
View File
@@ -92,7 +92,7 @@ function update_inventory_listing()
return
end
aux.item_listing.populate(m.item_listing, aux.util.values(aux.util.filter(m.inventory_records, function(record)
aux.item_listing.populate(m.item_listing, values(filter(m.inventory_records, function(record)
local settings = m.read_settings(record.key)
return record.aux_quantity > 0 and (not settings.hidden or m.show_hidden_checkbox:GetChecked())
end)))
@@ -145,9 +145,9 @@ function update_auction_listing()
{value=aux.auction_listing.time_left(auction_record.duration)},
{value=auction_record.stack_size == stack_size and aux.gui.color.yellow(auction_record.stack_size) or auction_record.stack_size},
{value=aux.money.to_string(auction_record.unit_blizzard_bid, true, nil, 3, bid_color) },
{value=historical_value and aux.auction_listing.percentage_historical(aux.util.round(auction_record.unit_blizzard_bid / historical_value * 100)) or '---'},
{value=historical_value and aux.auction_listing.percentage_historical(round(auction_record.unit_blizzard_bid / historical_value * 100)) or '---'},
{value=auction_record.unit_buyout_price > 0 and aux.money.to_string(auction_record.unit_buyout_price, true, nil, 3, buyout_color) or '---'},
{value=auction_record.unit_buyout_price > 0 and historical_value and aux.auction_listing.percentage_historical(aux.util.round(auction_record.unit_buyout_price / historical_value * 100)) or '---'},
{value=auction_record.unit_buyout_price > 0 and historical_value and aux.auction_listing.percentage_historical(round(auction_record.unit_buyout_price / historical_value * 100)) or '---'},
},
record = auction_record,
})
@@ -175,7 +175,7 @@ function update_auction_listing()
end
function public.select_item(item_key)
for _, inventory_record in aux.util.filter(m.inventory_records, function(record) return record.aux_quantity > 0 end) do
for _, inventory_record in filter(m.inventory_records, function(record) return record.aux_quantity > 0 end) do
if inventory_record.key == item_key then
m.set_item(inventory_record)
break
@@ -190,12 +190,12 @@ function price_update()
local start_price_input = m.get_unit_start_price()
settings.start_price = start_price_input
local historical_value = aux.history.value(m.selected_item.key)
m.start_price_percentage:SetText(historical_value and aux.auction_listing.percentage_historical(aux.util.round(start_price_input / historical_value * 100)) or '---')
m.start_price_percentage:SetText(historical_value and aux.auction_listing.percentage_historical(round(start_price_input / historical_value * 100)) or '---')
local buyout_price_input = m.get_unit_buyout_price()
settings.buyout_price = buyout_price_input
local historical_value = aux.history.value(m.selected_item.key)
m.buyout_price_percentage:SetText(historical_value and aux.auction_listing.percentage_historical(aux.util.round(buyout_price_input / historical_value * 100)) or '---')
m.buyout_price_percentage:SetText(historical_value and aux.auction_listing.percentage_historical(round(buyout_price_input / historical_value * 100)) or '---')
m.write_settings(settings)
end
@@ -328,8 +328,8 @@ function update_item_configuration()
end
function undercut(record, stack_size, stack)
local start_price = aux.util.round(record.unit_blizzard_bid * (stack and record.stack_size or stack_size))
local buyout_price = aux.util.round(record.unit_buyout_price * (stack and record.stack_size or stack_size))
local start_price = round(record.unit_blizzard_bid * (stack and record.stack_size or stack_size))
local buyout_price = round(record.unit_buyout_price * (stack and record.stack_size or stack_size))
if not record.own then
start_price = max(0, start_price - 1)
@@ -352,7 +352,7 @@ end
function unit_vendor_price(item_key)
for slot in aux.util.inventory() do
for slot in inventory() do
local item_info = aux.info.container_item(unpack(slot))
if item_info and item_info.item_key == item_key then
@@ -423,7 +423,7 @@ function update_inventory_records()
local auction_candidate_map = {}
for slot in aux.util.inventory() do
for slot in inventory() do
local item_info = aux.info.container_item(unpack(slot))
if item_info then
+1 -1
View File
@@ -69,7 +69,7 @@ function create_frames()
auction_listing:EnableSorting(false)
auction_listing:DisableSelection(true)
auction_listing:SetHandler('OnClick', function(table, row_data, column, button)
local column_index = aux.util.key(column, column.row.cols)
local column_index = key(column, column.row.cols)
local unit_start_price, unit_buyout_price = undercut(row_data.record, stack_size_slider:GetValue(), button == 'RightButton')
if column_index == 3 then
stack_size_slider:SetValue(row_data.record.stack_size)
+1 -1
View File
@@ -106,7 +106,7 @@ end
function public.add_filter(filter_string)
local old_filter_string = m.search_box:GetText()
old_filter_string = aux.util.trim(old_filter_string)
old_filter_string = trim(old_filter_string)
if old_filter_string ~= '' then
old_filter_string = old_filter_string..';'
+8 -8
View File
@@ -2,7 +2,7 @@ aux.module 'search_tab'
function valid_level(str)
local level = tonumber(str)
return level and aux.util.bound(1, 60, level)
return level and bound(1, 60, level)
end
blizzard_query = setmetatable({}, {
@@ -92,7 +92,7 @@ function update_form()
m.usable_checkbox:Enable()
end
if aux.util.any({'min_level', 'max_level', 'usable', 'class', 'subclass', 'slot', 'quality'}, function(key) return m.blizzard_query[key] end) then
if any({'min_level', 'max_level', 'usable', 'class', 'subclass', 'slot', 'quality'}, function(key) return m.blizzard_query[key] end) then
m.exact_checkbox:Disable()
else
m.exact_checkbox:Enable()
@@ -171,7 +171,7 @@ function clear_form()
end
function import_query_string()
local components, error = aux.filter.parse_query_string(aux.util.select(3, strfind(m.search_box:GetText(), '^([^;]*)')))
local components, error = aux.filter.parse_query_string(select(3, strfind(m.search_box:GetText(), '^([^;]*)')))
if components then
m.set_form(components)
else
@@ -206,7 +206,7 @@ function public.formatted_post_filter(components)
component_text = component_text..filter_color(tonumber(component[3]) or '')
tinsert(stack, component[3])
elseif component[1] == 'filter' then
for parameter in aux.util.present(component[3]) do
for parameter in present(component[3]) do
if component[2] == 'item' then
parameter = aux.info.display_name(aux.cache.item_id(parameter)) or '['..parameter..']'
elseif aux.filter.filters[component[2]].input_type == 'money' then
@@ -261,8 +261,8 @@ function add_component(component)
end
function add_post_filter()
for str in aux.util.present(m.filter_input:GetText()) do
for filter in aux.util.present(aux.filter.filters[str]) do
for str in present(m.filter_input:GetText()) do
for filter in present(aux.filter.filters[str]) do
if filter.input_type ~= '' then
str = str..'/'..m.filter_parameter_input:GetText()
end
@@ -314,8 +314,8 @@ function set_filter_display_offset(x_offset, y_offset)
local x_upper_bound = 0
local y_lower_bound = 0
local y_upper_bound = max(0, height - scroll_frame:GetHeight())
scroll_frame:SetHorizontalScroll(aux.util.bound(x_lower_bound, x_upper_bound, x_offset))
scroll_frame:SetVerticalScroll(aux.util.bound(y_lower_bound, y_upper_bound, y_offset))
scroll_frame:SetHorizontalScroll(bound(x_lower_bound, x_upper_bound, x_offset))
scroll_frame:SetVerticalScroll(bound(y_lower_bound, y_upper_bound, y_offset))
end
function initialize_filter_dropdown()
+3 -3
View File
@@ -336,7 +336,7 @@ function create_frames()
if filters then
tinsert(g.aux_favorite_searches, 1, {
filter_string = search_box:GetText(),
prettified = table.concat(aux.util.map(filters, function(filter) return filter.prettified end), ';'),
prettified = table.concat(map(filters, function(filter) return filter.prettified end), ';'),
})
end
update_search_listings()
@@ -536,7 +536,7 @@ function create_frames()
input:SetScript('OnTabPressed', function()
filter_parameter_input:SetFocus()
end)
input.complete = aux.completion.complete(function() return {'and', 'or', 'not', unpack(aux.util.keys(aux.filter.filters))} end)
input.complete = aux.completion.complete(function() return {'and', 'or', 'not', unpack(keys(aux.filter.filters))} end)
input:SetScript('OnChar', function()
this:complete()
end)
@@ -583,7 +583,7 @@ function create_frames()
scroll_frame:EnableMouseWheel(true)
scroll_frame:SetScript('OnMouseWheel', function()
local child = this:GetScrollChild()
child:SetFont('p', [[Fonts\ARIALN.TTF]], aux.util.bound(11, 23, aux.util.select(2, child:GetFont()) + arg1*2))
child:SetFont('p', [[Fonts\ARIALN.TTF]], bound(11, 23, select(2, child:GetFont()) + arg1*2))
update_filter_display()
end)
scroll_frame:RegisterForDrag('LeftButton')
+4 -4
View File
@@ -119,7 +119,7 @@ function update_auto_buy_filter()
if queries then
if getn(queries) > 1 then
aux.log('Error: The automatic buyout filter may contain only one query')
elseif aux.util.size(queries[1].blizzard_query) > 0 then
elseif size(queries[1].blizzard_query) > 0 then
aux.log('Error: The automatic buyout filter does not support Blizzard filters')
else
m.auto_buy_validator = queries[1].validator
@@ -163,7 +163,7 @@ function start_real_time_scan(query, search, continuation)
if search.auto_buy then
ctrl.suspend()
aux.place_bid('list', auction_record.index, auction_record.buyout_price, aux.C(ctrl.resume, true))
aux.control.thread(aux.control.when, aux.util.later(GetTime(), 10), aux.C(ctrl.resume, false))
aux.control.thread(aux.control.when, later(GetTime(), 10), aux.C(ctrl.resume, false))
else
tinsert(new_records, auction_record)
end
@@ -259,7 +259,7 @@ function start_search(queries, continuation)
if search.auto_buy then
ctrl.suspend()
aux.place_bid('list', auction_record.index, auction_record.buyout_price, aux.C(ctrl.resume, true))
aux.control.thread(aux.control.when, aux.util.later(GetTime(), 10), aux.C(ctrl.resume, false))
aux.control.thread(aux.control.when, later(GetTime(), 10), aux.C(ctrl.resume, false))
elseif getn(search.records) < 1000 then
tinsert(search.records, auction_record)
if getn(search.records) == 1000 then
@@ -335,7 +335,7 @@ function public.execute(resume, real_time)
else
m.new_search(filter_string)
end
m.new_recent_search(filter_string, table.concat(aux.util.map(queries, function(filter) return filter.prettified end), ';'))
m.new_recent_search(filter_string, table.concat(map(queries, function(filter) return filter.prettified end), ';'))
else
m.current_search().records = {}
m.current_search().table:SetDatabase(m.current_search().records)
+1 -1
View File
@@ -220,7 +220,7 @@ function public.bag_type(bag)
if bag == 0 then
return 1
end
for link in aux.util.present(GetInventoryItemLink('player', ContainerIDToInventoryID(bag))) do
for link in present(GetInventoryItemLink('player', ContainerIDToInventoryID(bag))) do
local item_id = aux.info.parse_link(link)
local item_info = aux.info.item(item_id)
return aux.info.item_subclass_index(3, item_info.subclass)
+16 -16
View File
@@ -5,7 +5,7 @@ function default_filter(str)
input_type = '',
validator = function()
return function(auction_record)
return aux.util.any(auction_record.tooltip, function(entry)
return any(auction_record.tooltip, function(entry)
return strfind(strlower(entry.left_text or ''), str, 1, true) or strfind(strlower(entry.right_text or ''), str, 1, true)
end)
end
@@ -205,7 +205,7 @@ public.filters = {
function operator(str)
local operator = str == 'not' and {'operator', 'not', 1}
for _, name in {'and', 'or'} do
for arity in aux.util.present(aux.util.select(3, strfind(str, '^'..name..'(%d*)$'))) do
for arity in present(select(3, strfind(str, '^'..name..'(%d*)$'))) do
arity = tonumber(arity)
operator = not (arity and arity < 2) and {'operator', name, arity}
end
@@ -223,7 +223,7 @@ do
if self.exact then
return
end
for number in aux.util.present(tonumber(aux.util.select(3, strfind(str, '^(%d+)$')))) do
for number in present(tonumber(select(3, strfind(str, '^(%d+)$')))) do
if number >= 1 and number <= 60 then
for _, filter in {'min_level', 'max_level'} do
if not self[filter] then
@@ -241,13 +241,13 @@ do
} do
if not self[parser[1]] then
tinsert(parser, str)
for index, label in aux.util.present(parser[2](aux.util.select(3, unpack(parser)))) do
for index, label in present(parser[2](select(3, unpack(parser)))) do
self[parser[1]] = {label, index}
return true
end
end
end
if not self[str] and (str == 'usable' or str == 'exact' and self.name and aux.util.size(self) == 1) then
if not self[str] and (str == 'usable' or str == 'exact' and self.name and size(self) == 1) then
self[str] = {str, 1}
elseif i == 1 and strlen(str) <= 63 then
self.name = {str, m.unquote(str)}
@@ -274,14 +274,14 @@ function parse_parameter(input_type, str)
elseif input_type == 'string' then
return str ~= '' and str or nil
elseif type(input_type) == 'table' then
return aux.util.key(str, input_type)
return key(str, input_type)
end
end
function public.parse_query_string(str)
local post_filter = {}
local blizzard_filter_parser = m.blizzard_filter_parser()
local parts = aux.util.map(aux.util.split(str, '/'), function(part) return strlower(aux.util.trim(part)) end)
local parts = map(split(str, '/'), function(part) return strlower(trim(part)) end)
local i = 1
while parts[i] do
@@ -353,11 +353,11 @@ function public.query(query_string)
end
function public.queries(query_string)
local parts = aux.util.split(query_string, ';')
local parts = split(query_string, ';')
local queries = {}
for _, str in parts do
str = aux.util.trim(str)
str = trim(str)
local query, _, error = m.query(str)
@@ -375,7 +375,7 @@ end
function suggestions(components)
local suggestions = {}
if components.blizzard.name and aux.util.size(components.blizzard) == 1 then
if components.blizzard.name and size(components.blizzard) == 1 then
tinsert(suggestions, 'exact')
end
@@ -422,7 +422,7 @@ function suggestions(components)
end
-- item names
if aux.util.size(components.blizzard) + getn(components.post) == 1 and components.blizzard.name == '' then
if size(components.blizzard) + getn(components.post) == 1 and components.blizzard.name == '' then
for _, name in g.aux_auctionable_items do
tinsert(suggestions, name..'/exact')
end
@@ -477,7 +477,7 @@ function prettified_query_string(components)
if component[2] ~= 'tooltip' then
prettified.append(aux.gui.color.aux(component[2]))
end
for parameter in aux.util.present(component[3]) do
for parameter in present(component[3]) do
if component[2] == 'item' then
prettified.append(aux.info.display_name(aux.cache.item_id(parameter)) or aux.gui.color.label.enabled('['..parameter..']'))
else
@@ -502,7 +502,7 @@ function public.quote(name)
end
function public.unquote(name)
return aux.util.select(3, strfind(name, '^<(.*)>$')) or name
return select(3, strfind(name, '^<(.*)>$')) or name
end
function blizzard_query(components)
@@ -559,15 +559,15 @@ function validator(components)
if name == 'not' then
tinsert(stack, not args[1])
elseif name == 'and' then
tinsert(stack, aux.util.all(args))
tinsert(stack, all(args))
elseif name == 'or' then
tinsert(stack, aux.util.any(args))
tinsert(stack, any(args))
end
elseif type == 'filter' then
tinsert(stack, validators[i](record) and true or false)
end
end
return aux.util.all(stack)
return all(stack)
end
end
+5 -5
View File
@@ -38,7 +38,7 @@ do
end
function public.container_item(bag, slot)
for link in aux.util.present(GetContainerItemLink(bag, slot)) do
for link in present(GetContainerItemLink(bag, slot)) do
local item_id, suffix_id, unique_id, enchant_id = parse_link(link)
local item_info = m.item(item_id, suffix_id, unique_id, enchant_id)
@@ -98,7 +98,7 @@ end
function public.auction(index, query_type)
query_type = query_type or 'list'
for link in aux.util.present(GetAuctionItemLink(query_type, index)) do
for link in present(GetAuctionItemLink(query_type, index)) do
local item_id, suffix_id, unique_id, enchant_id = parse_link(link)
local item_info = m.item(item_id, suffix_id, unique_id, enchant_id)
@@ -208,7 +208,7 @@ function public.set_shopping_tooltip(slot)
end
function public.tooltip_match(entry, tooltip)
return aux.util.any(tooltip, function(line)
return any(tooltip, function(line)
local left_match = line.left_text and strupper(line.left_text) == strupper(entry)
local right_match = line.right_text and strupper(line.right_text) == strupper(entry)
return left_match or right_match
@@ -244,7 +244,7 @@ function public.load_tooltip(frame, tooltip)
end
function public.display_name(item_id, no_brackets, no_color)
for item_info in aux.util.present(aux.info.item(item_id)) do
for item_info in present(aux.info.item(item_id)) do
local name = item_info.name
if not no_brackets then
name = '['..name..']'
@@ -355,7 +355,7 @@ end
function public.item(item_id, suffix_id)
local itemstring = 'item:'..(item_id or 0)..':0:'..(suffix_id or 0)..':0'
for name, itemstring, quality, level, class, subclass, max_stack, slot, texture in aux.util.present(GetItemInfo(itemstring)) do
for name, itemstring, quality, level, class, subclass, max_stack, slot, texture in present(GetItemInfo(itemstring)) do
return {
name = name,
itemstring = itemstring,
+4 -4
View File
@@ -58,7 +58,7 @@ end
--function public.to_string(params) -- TODO
-- local gold, silver, copper = to_gsc(params.copper or 0 + )
-- local settings = aux.util.set(unpack(arg))
-- local settings = set(unpack(arg))
--end
function public.to_string(money, pad, trim, decimal_points, color, no_color)
@@ -121,9 +121,9 @@ function public.from_string(value)
value = gsub(gsub(strlower(value), '|c%x%x%x%x%x%x%x%x', ''), FONT_COLOR_CODE_CLOSE, '')
-- extract gold/silver/copper values
local gold = tonumber(aux.util.select(3, strfind(value, '(%d*%.?%d+)g')))
local silver = tonumber(aux.util.select(3, strfind(value, '(%d*%.?%d+)s')))
local copper = tonumber(aux.util.select(3, strfind(value, '(%d*%.?%d+)c')))
local gold = tonumber(select(3, strfind(value, '(%d*%.?%d+)g')))
local silver = tonumber(select(3, strfind(value, '(%d*%.?%d+)s')))
local copper = tonumber(select(3, strfind(value, '(%d*%.?%d+)c')))
if not gold and not silver and not copper then return end
-- test that there are no extra characters (other than spaces)
+4 -4
View File
@@ -60,8 +60,8 @@ function public.read_list(schema, str)
local separator = schema[2]
local element_type = schema[3]
local parts = aux.util.split(str, separator)
return aux.util.map(parts, function(part)
local parts = split(str, separator)
return map(parts, function(part)
return m.read(element_type, part)
end)
end
@@ -69,7 +69,7 @@ end
function public.write_list(schema, list)
local separator = schema[2]
local element_type = schema[3]
local parts = aux.util.map(list, function(element)
local parts = map(list, function(element)
return m.write(element_type, element)
end)
return table.concat(parts, separator)
@@ -78,7 +78,7 @@ end
function public.read_record(schema, str)
local separator = schema[2]
local record = {}
local parts = aux.util.split(str, separator)
local parts = split(str, separator)
for i=3,getn(schema) do
local key, type = next(schema[i])
record[key] = m.read(type, parts[i - 2])
+3 -3
View File
@@ -12,7 +12,7 @@ function public.find(auction_record, status_bar, on_abort, on_failure, on_succes
if auction_record.blizzard_query then
local blizzard_query1 = aux.util.copy(auction_record.blizzard_query)
local blizzard_query1 = copy(auction_record.blizzard_query)
blizzard_query1.first_page = auction_record.page
blizzard_query1.last_page = auction_record.page
tinsert(queries, {
@@ -20,7 +20,7 @@ function public.find(auction_record, status_bar, on_abort, on_failure, on_succes
})
if auction_record.page > 0 then
local blizzard_query2 = aux.util.copy(auction_record.blizzard_query)
local blizzard_query2 = copy(auction_record.blizzard_query)
blizzard_query2.first_page = auction_record.page - 1
blizzard_query2.last_page = auction_record.page - 1
tinsert(queries, {
@@ -29,7 +29,7 @@ function public.find(auction_record, status_bar, on_abort, on_failure, on_succes
end
local item_query = m.item_query(auction_record.item_id, 1, 1)
if not aux.util.eq(auction_record.blizzard_query, item_query.blizzard_query) then
if not eq(auction_record.blizzard_query, item_query.blizzard_query) then
tinsert(queries, item_query)
end
end