diff --git a/aux-addon.lua b/aux-addon.lua index a0d4f5c..26405e2 100644 --- a/aux-addon.lua +++ b/aux-addon.lua @@ -76,16 +76,15 @@ do return t end - function public.operator_mt(f) + function public.modifier_mt(f) local function apply(self, value) - local raw = self.raw recycle(self) - return raw and setmetatable(f(value), nil) or f(value) + return f(value) end - return {__unm=function(self) self.raw = true; return self end, __call=apply, __sub=apply} + return {__call=apply, __sub=apply} end do - local mt = operator_mt(function(t) tmp[t] = true; return t end) + local mt = modifier_mt(function(t) tmp[t] = true; return t end) public.temp { get = function() return setmetatable(t, mt) end, @@ -93,7 +92,7 @@ do } end do - local mt = operator_mt(function(t) tmp[t] = nil; return t end) + local mt = modifier_mt(function(t) tmp[t] = nil; return t end) public.perm { get = function() return setmetatable(t, mt) end, @@ -123,31 +122,30 @@ do if k19 == nil then return t end; t[k19] = true if k20 == nil then return t end; t[k20] = true if overflow ~= nil then error('Overflow.') end - return t end local function insert_values(t,v1,v2,v3,v4,v5,v6,v7,v8,v9,v10,v11,v12,v13,v14,v15,v16,v17,v18,v19,v20,overflow) - if v1 == nil then return t end; tinsert(t, v1) - if v2 == nil then return t end; tinsert(t, v2) - if v3 == nil then return t end; tinsert(t, v3) - if v4 == nil then return t end; tinsert(t, v4) - if v5 == nil then return t end; tinsert(t, v5) - if v6 == nil then return t end; tinsert(t, v6) - if v7 == nil then return t end; tinsert(t, v7) - if v8 == nil then return t end; tinsert(t, v8) - if v9 == nil then return t end; tinsert(t, v9) - if v10 == nil then return t end; tinsert(t, v10) - if v11 == nil then return t end; tinsert(t, v11) - if v12 == nil then return t end; tinsert(t, v12) - if v13 == nil then return t end; tinsert(t, v13) - if v14 == nil then return t end; tinsert(t, v14) - if v15 == nil then return t end; tinsert(t, v15) - if v16 == nil then return t end; tinsert(t, v16) - if v17 == nil then return t end; tinsert(t, v17) - if v18 == nil then return t end; tinsert(t, v18) - if v19 == nil then return t end; tinsert(t, v19) - if v20 == nil then return t end; tinsert(t, v20) + local n = getn(t) + if v1 == nil then return t end; t[n + 1] = v1 + if v2 == nil then return t end; t[n + 2] = v2 + if v3 == nil then return t end; t[n + 3] = v3 + if v4 == nil then return t end; t[n + 4] = v4 + if v5 == nil then return t end; t[n + 5] = v5 + if v6 == nil then return t end; t[n + 6] = v6 + if v7 == nil then return t end; t[n + 7] = v7 + if v8 == nil then return t end; t[n + 8] = v8 + if v9 == nil then return t end; t[n + 9] = v9 + if v10 == nil then return t end; t[n + 10] = v10 + if v11 == nil then return t end; t[n + 11] = v11 + if v12 == nil then return t end; t[n + 12] = v12 + if v13 == nil then return t end; t[n + 13] = v13 + if v14 == nil then return t end; t[n + 14] = v14 + if v15 == nil then return t end; t[n + 15] = v15 + if v16 == nil then return t end; t[n + 16] = v16 + if v17 == nil then return t end; t[n + 17] = v17 + if v18 == nil then return t end; t[n + 18] = v18 + if v19 == nil then return t end; t[n + 19] = v19 + if v20 == nil then return t end; t[n + 20] = v20 if overflow ~= nil then error('Overflow.') end - return t end local function insert_pairs(t,k1,v1,k2,v2,k3,v3,k4,v4,k5,v5,k6,v6,k7,v7,k8,v8,k9,v9,k10,v10,overflow) if k1 == nil then return t end t[k1] = v1 @@ -161,21 +159,27 @@ do if k9 == nil then return t end t[k9] = v9 if k10 == nil then return t end t[k10] = v10 if overflow ~= nil then error('Overflow.') end - return t end - local function collector_mt(f) - return {__call=f, __unm=function(self) return setmetatable(self, nil) end} + local function constructor_mt(insert) + return { + __call=function(self,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,overflow) + self.t, self.n = self.t or t, (self.n or 1) - 1 + insert(self.t,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10,a11,a12,a13,a14,a15,a16,a17,a18,a19,a20,overflow) + return self.n > 0 and self or self.t + end, + __index=function(self, key) self.n = key end, + } end - local set_mt, list_mt, object_mt = collector_mt(insert_keys), collector_mt(insert_values), collector_mt(insert_pairs) + local set_mt, list_mt, table_mt = constructor_mt(insert_keys), constructor_mt(insert_values), constructor_mt(insert_pairs) public() - function set.get() return setmetatable(t, set_mt) end - function list.get() return setmetatable(t, list_mt) end - function object.get() return setmetatable(t, object_mt) end + function set.get() return setmetatable(tt, set_mt) end + function list.get() return setmetatable(tt, list_mt) end + function T.get() return setmetatable(tt, table_mt) end private() end local event_frame = CreateFrame('Frame') -for event in -temp-set('ADDON_LOADED', 'VARIABLES_LOADED', 'PLAYER_LOGIN', 'AUCTION_HOUSE_SHOW', 'AUCTION_HOUSE_CLOSED', 'AUCTION_BIDDER_LIST_UPDATE', 'AUCTION_OWNED_LIST_UPDATE') do +for event in temp-set('ADDON_LOADED', 'VARIABLES_LOADED', 'PLAYER_LOGIN', 'AUCTION_HOUSE_SHOW', 'AUCTION_HOUSE_CLOSED', 'AUCTION_BIDDER_LIST_UPDATE', 'AUCTION_OWNED_LIST_UPDATE') do event_frame:RegisterEvent(event) end @@ -200,9 +204,9 @@ end tab_info = t do - for k, v in -temp-object('search_tab', 'Search', 'post_tab', 'Post', 'auctions_tab', 'Auctions', 'bids_tab', 'Bids') do - local tab = -object('name', v) - local env = (function() aux(k) return M end)() + for _, info in temp-list(temp-list('search_tab', 'Search'), temp-list('post_tab', 'Post'), temp-list('auctions_tab', 'Auctions'), temp-list('bids_tab', 'Bids')) do + local tab = T('name', info[2]) + local env = (function() aux(info[1]) return M end)() function env.private.OPEN.set(f) tab.OPEN = f end function env.private.CLOSE.set(f) tab.CLOSE = f end function env.private.USE_ITEM.set(f) tab.USE_ITEM = f end diff --git a/core/cache.lua b/core/cache.lua index 02a7ee0..8e526df 100644 --- a/core/cache.lua +++ b/core/cache.lua @@ -28,7 +28,7 @@ function LOAD() event_listener('NEW_AUCTION_UPDATE', function() for info in present(info.auction_sell_item()) do for item_id in present(item_id(info.name)) do - _G.aux_merchant_sell[M.item_id(info.name)] = info.vendor_price / (M.info.max_item_charges(item_id) or info.count) + _G.aux_merchant_sell[M.item_id(info.name)] = info.vendor_price / (aux.info.max_item_charges(item_id) or info.count) end end end) @@ -86,7 +86,7 @@ function public.item_info(item_id) local data_string = _G.aux_items[item_id] if data_string then local cached_data = persistence.read(items_schema, data_string) - return -object( + return T( 'name', cached_data.name, 'itemstring', 'item:'..item_id..':0:0:0', 'quality', cached_data.quality, @@ -125,12 +125,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, -object( + _G.aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, T( 'unit_price', unit_price, 'limited', buy_info.limited and new_limited )) else - _G.aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, -object( + _G.aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, T( 'unit_price', new_unit_price, 'limited', new_limited )) @@ -161,7 +161,7 @@ function scan_wdb(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, -object( + _G.aux_items[item_id] = persistence.write(items_schema, T( 'name', name, 'quality', quality, 'level', level, diff --git a/core/disenchant.lua b/core/disenchant.lua index 5b624b3..fd8de2c 100644 --- a/core/disenchant.lua +++ b/core/disenchant.lua @@ -39,7 +39,7 @@ do end function LOAD() - ARMOR = -set( + ARMOR = set( 'INVTYPE_HEAD', 'INVTYPE_NECK', 'INVTYPE_SHOULDER', @@ -56,7 +56,7 @@ function LOAD() 'INVTYPE_CLOAK', 'INVTYPE_HOLDABLE' ) - WEAPON = -set( + WEAPON = set( 'INVTYPE_2HWEAPON', 'INVTYPE_WEAPONMAINHAND', 'INVTYPE_WEAPON', diff --git a/core/history.lua b/core/history.lua index dce6770..5b3f09c 100644 --- a/core/history.lua +++ b/core/history.lua @@ -17,19 +17,19 @@ do end do - local time = 0 + local cache = 0 function private.next_push.get() - if time() > time then + if time() > cache then local date = date('*t') date.hour, date.min, date.sec = 24, 0, 0 - time = time(date) + cache = time(date) end - return time + return cache end end function private.new_record.get() - return -object('next_push', next_push, 'data_points', t) + return T('next_push', next_push, 'data_points', t) end function read_record(item_key) @@ -78,7 +78,7 @@ function public.value(item_key) for _, data_point in item_record.data_points do local weight = .99 ^ round((item_record.data_points[1].time - data_point.time) / (60 * 60 * 24)) total_weight = total_weight + weight - tinsert(weighted_values, -object('value', data_point.market_value, 'weight', weight)) + tinsert(weighted_values, T('value', data_point.market_value, 'weight', weight)) end for _, weighted_value in weighted_values do weighted_value.weight = weighted_value.weight / total_weight @@ -87,7 +87,7 @@ function public.value(item_key) else value = calculate_market_value(item_record) end - value_cache[item_key] = -object('value', value, 'next_push', item_record.next_push) + value_cache[item_key] = T('value', value, 'next_push', item_record.next_push) end return value_cache[item_key].value end @@ -113,7 +113,7 @@ end function push_record(item_record) for market_value in present(calculate_market_value(item_record)) do - tinsert(item_record.data_points, 1, -object('market_value', market_value, 'time', item_record.next_push)) + tinsert(item_record.data_points, 1, T('market_value', market_value, 'time', item_record.next_push)) while getn(item_record.data_points) > 11 do tremove(item_record.data_points) end diff --git a/tabs/post/core.lua b/tabs/post/core.lua index ddc993f..170da21 100644 --- a/tabs/post/core.lua +++ b/tabs/post/core.lua @@ -5,7 +5,7 @@ local DURATION_4, DURATION_8, DURATION_24 = 120, 480, 1440 local settings_schema = {'record', '#', {stack_size='number'}, {duration='number'}, {start_price='number'}, {buyout_price='number'}, {hidden='boolean'}} function private.default_settings.get() - return -object('duration', DURATION_8 , 'stack_size', 1, 'start_price', 0, 'buyout_price', 0, 'hidden', false) + return T('duration', DURATION_8 , 'stack_size', 1, 'start_price', 0, 'buyout_price', 0, 'hidden', false) end do @@ -70,20 +70,20 @@ end function get_unit_start_price() local money_text = unit_start_price:GetText() - return money.from_string(money_text) or 0 + return aux.money.from_string(money_text) or 0 end function set_unit_start_price(amount) - unit_start_price:SetText(money.to_string(amount, true, nil, 3)) + unit_start_price:SetText(aux.money.to_string(amount, true, nil, 3)) end function get_unit_buyout_price() local money_text = unit_buyout_price:GetText() - return money.from_string(money_text) or 0 + return aux.money.from_string(money_text) or 0 end function set_unit_buyout_price(amount) - unit_buyout_price:SetText(money.to_string(amount, true, nil, 3)) + unit_buyout_price:SetText(aux.money.to_string(amount, true, nil, 3)) end function update_inventory_listing() @@ -104,32 +104,32 @@ function update_auction_listing() for i, auction_record in existing_auctions[selected_item.key] or tt do local blizzard_bid_undercut, buyout_price_undercut = undercut(auction_record, stack_size_slider:GetValue()) - blizzard_bid_undercut = money.from_string(money.to_string(blizzard_bid_undercut, true, nil, 3)) - buyout_price_undercut = money.from_string(money.to_string(buyout_price_undercut, true, nil, 3)) + blizzard_bid_undercut = aux.money.from_string(aux.money.to_string(blizzard_bid_undercut, true, nil, 3)) + buyout_price_undercut = aux.money.from_string(aux.money.to_string(buyout_price_undercut, true, nil, 3)) local stack_blizzard_bid_undercut, stack_buyout_price_undercut = undercut(auction_record, stack_size_slider:GetValue(), true) - stack_blizzard_bid_undercut = money.from_string(money.to_string(stack_blizzard_bid_undercut, true, nil, 3)) - stack_buyout_price_undercut = money.from_string(money.to_string(stack_buyout_price_undercut, true, nil, 3)) + stack_blizzard_bid_undercut = aux.money.from_string(aux.money.to_string(stack_blizzard_bid_undercut, true, nil, 3)) + stack_buyout_price_undercut = aux.money.from_string(aux.money.to_string(stack_buyout_price_undercut, true, nil, 3)) local stack_size = stack_size_slider:GetValue() local historical_value = history.value(selected_item.key) local bid_color if blizzard_bid_undercut < unit_start_price and stack_blizzard_bid_undercut < unit_start_price then - bid_color = gui.inline_color.red + bid_color = inline_color.red elseif blizzard_bid_undercut < unit_start_price then - bid_color = gui.inline_color.orange + bid_color = inline_color.orange elseif stack_blizzard_bid_undercut < unit_start_price then - bid_color = gui.inline_color.yellow + bid_color = inline_color.yellow end local buyout_color if buyout_price_undercut < unit_buyout_price and stack_buyout_price_undercut < unit_buyout_price then - buyout_color = gui.inline_color.red + buyout_color = inline_color.red elseif buyout_price_undercut < unit_buyout_price then - buyout_color = gui.inline_color.orange + buyout_color = inline_color.orange elseif stack_buyout_price_undercut < unit_buyout_price then - buyout_color = gui.inline_color.yellow + buyout_color = inline_color.yellow end tinsert(auction_rows, { @@ -137,9 +137,9 @@ function update_auction_listing() {value=auction_record.own and color.yellow(auction_record.count) or auction_record.count}, {value=al.time_left(auction_record.duration)}, {value=auction_record.stack_size == stack_size and color.yellow(auction_record.stack_size) or auction_record.stack_size}, - {value=money.to_string(auction_record.unit_blizzard_bid, true, nil, 3, bid_color) }, + {value=aux.money.to_string(auction_record.unit_blizzard_bid, true, nil, 3, bid_color) }, {value=historical_value and al.percentage_historical(round(auction_record.unit_blizzard_bid / historical_value * 100)) or '---'}, - {value=auction_record.unit_buyout_price > 0 and money.to_string(auction_record.unit_buyout_price, true, nil, 3, buyout_color) 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 al.percentage_historical(round(auction_record.unit_buyout_price / historical_value * 100)) or '---'}, }, record = auction_record, @@ -306,7 +306,7 @@ function update_item_configuration() local deposit_factor = neutral_faction() and 0.25 or 0.05 local stack_size, stack_count = stack_size_slider:GetValue(), stack_count_slider:GetValue() local amount = floor(selected_item.unit_vendor_price * deposit_factor * (selected_item.max_charges and 1 or stack_size)) * stack_count * UIDropDownMenu_GetSelectedValue(duration_dropdown) / 120 - deposit:SetText('Deposit: '..money.to_string(amount, nil, nil, nil, gui.inline_color.text.enabled)) + deposit:SetText('Deposit: '..aux.money.to_string(amount, nil, nil, nil, inline_color.text.enabled)) end refresh_button:Enable() @@ -358,7 +358,7 @@ function update_historical_value_button() if selected_item then local historical_value = history.value(selected_item.key) historical_value_button.amount = historical_value - historical_value_button:SetText(historical_value and money.to_string(historical_value, true, nil, 3) or '---') + historical_value_button:SetText(historical_value and aux.money.to_string(historical_value, true, nil, 3) or '---') end end @@ -386,8 +386,8 @@ function set_item(item) stack_size_slider:SetValue(settings.stack_size) quantity_update(true) - unit_start_price:SetText(money.to_string(settings.start_price, true, nil, 3, nil, true)) - unit_buyout_price:SetText(money.to_string(settings.buyout_price, true, nil, 3, nil, true)) + unit_start_price:SetText(aux.money.to_string(settings.start_price, true, nil, 3, nil, true)) + unit_buyout_price:SetText(aux.money.to_string(settings.buyout_price, true, nil, 3, nil, true)) if not existing_auctions[selected_item.key] then refresh_entries() @@ -409,10 +409,10 @@ function update_inventory_records() availability[i] = 0 end availability[charge_class] = item_info.count - auctionable_map[item_info.item_key] = -object( + auctionable_map[item_info.item_key] = T( 'item_id', item_info.item_id, 'suffix_id', item_info.suffix_id, - 'key', item_info.item_key + 'key', item_info.item_key, 'itemstring', item_info.itemstring, 'name', item_info.name, 'texture', item_info.texture, @@ -451,7 +451,7 @@ function refresh_entries() scan_id = scan.start{ type = 'list', ignore_owner = true, - queries = -list(query), + queries = list(query), on_page_loaded = function(page, total_pages) status_bar:update_status(100 * (page - 1) / total_pages, 0) -- TODO status_bar:set_text(format('Scanning Page %d / %d', page, total_pages)) @@ -493,7 +493,7 @@ function record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price, end end if not entry then - entry = -object('stack_size', aux_quantity 'unit_blizzard_bid', unit_blizzard_bid 'unit_buyout_price', unit_buyout_price 'duration', duration 'own', is_player(owner) 'count', 0) + entry = T('stack_size', aux_quantity, 'unit_blizzard_bid', unit_blizzard_bid, 'unit_buyout_price', unit_buyout_price, 'duration', duration, 'own', is_player(owner), 'count', 0) tinsert(existing_auctions[key], entry) end entry.count = entry.count + 1 diff --git a/tabs/search/filter.lua b/tabs/search/filter.lua index e09a0b4..cc483c8 100644 --- a/tabs/search/filter.lua +++ b/tabs/search/filter.lua @@ -72,14 +72,14 @@ function update_form() end if blizzard_query.exact then - for key in -temp-set('class', 'subclass', 'slot', 'quality') do + for key in temp-set('class', 'subclass', 'slot', 'quality') do M[key..'_dropdown'].button:Disable() end else class_dropdown.button:Enable() quality_dropdown.button:Enable() end - for key in -temp-set('min_level', 'max_level') do + for key in temp-set('min_level', 'max_level') do if blizzard_query.exact then M[key..'_input']:Disable() else @@ -134,7 +134,7 @@ function get_filter_builder_query() add(strlower(_G['ITEM_QUALITY'..quality..'_DESC'])) end - local post_filter_string = filter_util.query_string(-temp-object('blizzard', tt, 'post', post_filter)) + local post_filter_string = filter_util.query_string(temp-T('blizzard', tt, 'post', post_filter)) add(post_filter_string ~= '' and post_filter_string) return query_string or '' @@ -231,7 +231,7 @@ function data_link(id, str) end post_filter = t -filter_builder_state = -object('selected', 0) +filter_builder_state = T('selected', 0) function data_link_click() local button = arg3 @@ -313,8 +313,8 @@ function set_filter_display_offset(x_offset, y_offset) end function initialize_filter_dropdown() - for filter in -temp-set('and', 'or', 'not', 'min-unit-bid', 'min-unit-buy', 'max-unit-bid', 'max-unit-buy', 'bid-profit', 'buy-profit', 'bid-vend-profit', 'buy-vend-profit', 'bid-dis-profit', 'buy-dis-profit', 'bid-pct', 'buy-pct', 'item', 'tooltip', 'min-lvl', 'max-lvl', 'rarity')('left', 'utilizable', 'discard') do - UIDropDownMenu_AddButton(-object( + for filter in temp-set('and', 'or', 'not', 'min-unit-bid', 'min-unit-buy', 'max-unit-bid', 'max-unit-buy', 'bid-profit', 'buy-profit', 'bid-vend-profit', 'buy-vend-profit', 'bid-dis-profit', 'buy-dis-profit', 'bid-pct', 'buy-pct', 'item', 'tooltip', 'min-lvl', 'max-lvl', 'rarity')('left', 'utilizable', 'discard') do + UIDropDownMenu_AddButton(T( 'text', filter, 'value', filter, 'func', function() @@ -343,9 +343,9 @@ function initialize_class_dropdown() update_form() end end - UIDropDownMenu_AddButton(-object('text', ALL, 'value', 0, 'func', on_click)) + UIDropDownMenu_AddButton(T('text', ALL, 'value', 0, 'func', on_click)) for i, class in temp-{GetAuctionItemClasses()} do - UIDropDownMenu_AddButton(-object('text', class, 'value', i, 'func', on_click)) + UIDropDownMenu_AddButton(T('text', class, 'value', i, 'func', on_click)) end end @@ -360,9 +360,9 @@ function initialize_subclass_dropdown() end local class_index = UIDropDownMenu_GetSelectedValue(class_dropdown) if class_index and GetAuctionItemSubClasses(class_index) then - UIDropDownMenu_AddButton(-object('text', ALL, 'value', 0, 'func', on_click)) - for i, subclass in temp-{GetAuctionItemSubClasses(class_index)} do - UIDropDownMenu_AddButton(-object('text', subclass, 'value', i, 'func', on_click)) + UIDropDownMenu_AddButton(T('text', ALL, 'value', 0, 'func', on_click)) + for i, subclass in temp-list(GetAuctionItemSubClasses(class_index)) do + UIDropDownMenu_AddButton(T('text', subclass, 'value', i, 'func', on_click)) end end end @@ -375,9 +375,9 @@ function initialize_slot_dropdown() local class_index = UIDropDownMenu_GetSelectedValue(class_dropdown) local subclass_index = UIDropDownMenu_GetSelectedValue(subclass_dropdown) if subclass_index and GetAuctionInvTypes(class_index, subclass_index) then - UIDropDownMenu_AddButton(-object('text', ALL, 'value', '', 'func', on_click)) + UIDropDownMenu_AddButton(T('text', ALL, 'value', '', 'func', on_click)) for _, slot in {GetAuctionInvTypes(class_index, subclass_index)} do - UIDropDownMenu_AddButton(-object('text', _G[slot], 'value', slot, 'func', on_click)) + UIDropDownMenu_AddButton(T('text', _G[slot], 'value', slot, 'func', on_click)) end end end @@ -387,8 +387,8 @@ function initialize_quality_dropdown() UIDropDownMenu_SetSelectedValue(quality_dropdown, this.value) update_form() end - UIDropDownMenu_AddButton(-object('text', ALL, 'value', -1, 'func', on_click)) + UIDropDownMenu_AddButton(T('text', ALL, 'value', -1, 'func', on_click)) for i = 0, 4 do - UIDropDownMenu_AddButton(-object('text', _G['ITEM_QUALITY'..i..'_DESC'], 'value', i, 'func', on_click)) + UIDropDownMenu_AddButton(T('text', _G['ITEM_QUALITY'..i..'_DESC'], 'value', i, 'func', on_click)) end end diff --git a/tabs/search/results.lua b/tabs/search/results.lua index 3a206da..2aa6f24 100644 --- a/tabs/search/results.lua +++ b/tabs/search/results.lua @@ -56,7 +56,7 @@ do while getn(searches) > search_index do tremove(searches) end - local search = -object('filter_string', filter_string, 'records', t) + local search = T('filter_string', filter_string, 'records', t) tinsert(searches, search) if getn(searches) > 5 then tremove(searches, 1) @@ -124,7 +124,7 @@ end function update_auto_buy_filter() if _G.aux_auto_buy_filter ~= '' then - local queries = filter_util.queries(_G.aux_auto_buy_filter) + local queries = aux.filter_util.queries(_G.aux_auto_buy_filter) if queries then if getn(queries) > 1 then log 'Error: The automatic buyout filter does not support multi-queries' @@ -319,7 +319,7 @@ function public.execute(resume, real_time) end local filter_string = search_box:GetText() - local queries = filter_util.queries(filter_string) + local queries = aux.filter_util.queries(filter_string) if not queries then return elseif real_time then diff --git a/util/core.lua b/util/core.lua index 9808745..1ce01e8 100644 --- a/util/core.lua +++ b/util/core.lua @@ -81,7 +81,7 @@ function public.modified.get() return IsShiftKeyDown() or IsControlKeyDown() or --end do - local _state = setmetatable(t, -object('__mode', 'kv')) + local _state = setmetatable(t, T('__mode', 'kv')) local __index = function(self, key) return _state[self].handler({public=self, private=_state[self].state}, key) end diff --git a/util/filter.lua b/util/filter.lua index 228b063..befbad3 100644 --- a/util/filter.lua +++ b/util/filter.lua @@ -41,7 +41,7 @@ public.filters = { }, ['left'] = { - input_type = -list('30m', '2h', '8h', '24h'), + input_type = list('30m', '2h', '8h', '24h'), validator = function(index) return function(auction_record) return auction_record.duration == index @@ -50,7 +50,7 @@ public.filters = { }, ['rarity'] = { - input_type = -list('poor', 'common', 'uncommon', 'rare', 'epic'), + input_type = list('poor', 'common', 'uncommon', 'rare', 'epic'), validator = function(index) return function(auction_record) return auction_record.quality == index - 1 @@ -203,11 +203,11 @@ public.filters = { } function operator(str) - local operator = str == 'not' and -list('operator', 'not', 1) - for name in -temp-set('and', 'or') do + local operator = str == 'not' and list('operator', 'not', 1) + for name in temp-set('and', 'or') do for arity in present(select(3, strfind(str, '^'..name..'(%d*)$'))) do arity = tonumber(arity) - operator = not (arity and arity < 2) and -list('operator', name, arity) + operator = not (arity and arity < 2) and list('operator', name, arity) end end return operator or nil @@ -225,7 +225,7 @@ do end for number in present(tonumber(select(3, strfind(str, '^(%d+)$')))) do if number >= 1 and number <= 60 then - for filter in -temp-set('min_level', 'max_level') do + for filter in temp-set('min_level', 'max_level') do if not self[filter] then self[filter] = {str, number} return true @@ -233,11 +233,11 @@ do end end end - for _, parser in -list( - -list('class', info.item_class_index), - -list('subclass', L(info.item_subclass_index, index(self.class, 2) or 0, _1)), - -list('slot', L(info.item_slot_index, index(self.class, 2) or 0, index(self.subclass, 2) or 0, _1)), - -list('quality', info.item_quality_index) + for _, parser in list( + list('class', info.item_class_index), + list('subclass', L(info.item_subclass_index, index(self.class, 2) or 0, _1)), + list('slot', L(info.item_slot_index, index(self.class, 2) or 0, index(self.subclass, 2) or 0, _1)), + list('quality', info.item_quality_index) ) do if not self[parser[1]] then tinsert(parser, str) @@ -250,7 +250,7 @@ do 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 = -list(str, unquote(str)) + self.name = list(str, unquote(str)) -- return nil, 'The name filter must not be longer than 63 characters' else return @@ -300,14 +300,14 @@ function public.parse_query_string(str) return nil, 'Invalid input for '..parts[i]..'. Expecting: '..input_type end end - tinsert(post_filter, -list('filter', parts[i], parts[i + 1])) + tinsert(post_filter, list('filter', parts[i], parts[i + 1])) i = i + 1 else - tinsert(post_filter, -list('filter', parts[i])) + tinsert(post_filter, list('filter', parts[i])) end elseif not blizzard_filter_parser(parts[i], i) then if parts[i] ~= '' then - tinsert(post_filter, -list('filter', 'tooltip', parts[i])) + tinsert(post_filter, list('filter', 'tooltip', parts[i])) else return nil, 'Empty modifier' end @@ -315,7 +315,7 @@ function public.parse_query_string(str) i = i + 1 end - return -object('blizzard', blizzard_filter_parser(), 'post', post_filter) + return T('blizzard', blizzard_filter_parser(), 'post', post_filter) end function public.query(query_string) @@ -492,7 +492,7 @@ end function blizzard_query(components) local filters = components.blizzard - local query = -object('name', filters.name and filters.name[2]) + local query = T('name', filters.name and filters.name[2]) local item_info, class_index, subclass_index, slot_index local item_id = aux.cache.item_id(filters.name[2]) @@ -513,7 +513,7 @@ function blizzard_query(components) query.slot = slot_index query.quality = item_info.quality else - for key in -temp-set('min_level', 'max_level', 'class', 'subclass', 'slot', 'usable', 'quality') do + for key in temp-set('min_level', 'max_level', 'class', 'subclass', 'slot', 'usable', 'quality') do query[key] = index(filters[key], 2) end end @@ -559,7 +559,7 @@ end function public.query_builder() local filter - return -object( + return T( 'appended', function(part) return query_builder(not filter and part or filter..'/'..part) end, diff --git a/util/info.lua b/util/info.lua index f2acd6c..903ba43 100644 --- a/util/info.lua +++ b/util/info.lua @@ -190,7 +190,7 @@ function public.set_shopping_tooltip(slot) end if tooltips[1] then - tinsert(tooltips[1], 1, -temp-object('left_text', 'Currently Equipped', 'left_color', -temp-list(.5, .5, .5))) + tinsert(tooltips[1], 1, temp-T('left_text', 'Currently Equipped', 'left_color', temp-list(.5, .5, .5))) ShoppingTooltip1:SetOwner(GameTooltip, 'ANCHOR_BOTTOMRIGHT') load_tooltip(ShoppingTooltip1, tooltips[1]) ShoppingTooltip1:Show() @@ -198,7 +198,7 @@ function public.set_shopping_tooltip(slot) end if tooltips[2] then - tinsert(tooltips[2], 1, -temp-object('left_text', 'Currently Equipped', 'left_color', -temp-list(.5, .5, .5))) + tinsert(tooltips[2], 1, temp-T('left_text', 'Currently Equipped', 'left_color', temp-list(.5, .5, .5))) ShoppingTooltip2:SetOwner(ShoppingTooltip1, 'ANCHOR_BOTTOMRIGHT') load_tooltip(ShoppingTooltip2, tooltips[2]) ShoppingTooltip2:Show() diff --git a/util/scan.lua b/util/scan.lua index 0148b1a..a4941ef 100644 --- a/util/scan.lua +++ b/util/scan.lua @@ -15,13 +15,13 @@ function public.find(auction_record, status_bar, on_abort, on_failure, on_succes local blizzard_query1 = copy(auction_record.blizzard_query) blizzard_query1.first_page = auction_record.page blizzard_query1.last_page = auction_record.page - tinsert(queries, -object('blizzard_query', blizzard_query1)) + tinsert(queries, T('blizzard_query', blizzard_query1)) if auction_record.page > 0 then 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, -object('blizzard_query', blizzard_query2)) + tinsert(queries, T('blizzard_query', blizzard_query2)) end local item_query = item_query(auction_record.item_id, 1, 1) @@ -71,6 +71,6 @@ function public.item_query(item_id, first_page, last_page) local query = filter_util.query(item_info.name..'/exact') query.blizzard_query.first_page = first_page query.blizzard_query.last_page = last_page - return -object('validator', query.validator, 'blizzard_query', query.blizzard_query) + return T('validator', query.validator, 'blizzard_query', query.blizzard_query) end end \ No newline at end of file