diff --git a/aux-addon.lua b/aux-addon.lua index 89b7d00..71cdbc4 100644 --- a/aux-addon.lua +++ b/aux-addon.lua @@ -1,6 +1,6 @@ module 'aux' -include 'green_t' +include 'green_T' local info = require 'aux.util.info' local money = require 'aux.util.money' @@ -19,7 +19,8 @@ function M.set_p(v) inspect(nil, v) end -function M.print(...) auto_release(arg, true) +function M.print(...) + auto_release(arg, true) DEFAULT_CHAT_FRAME:AddMessage(LIGHTYELLOW_FONT_COLOR_CODE .. '[aux] ' .. join(map(arg, tostring), ' ')) end @@ -35,9 +36,9 @@ for event in temp-S('ADDON_LOADED', 'VARIABLES_LOADED', 'PLAYER_LOGIN', 'AUCTION event_frame:RegisterEvent(event) end -ADDON_LOADED = t +ADDON_LOADED = T do - local handlers, handlers2 = t, t + local handlers, handlers2 = T, T function M.set_LOAD(f) tinsert(handlers, f) end @@ -58,9 +59,9 @@ do end) end -tab_info = t +tab_info = T function M.TAB(name) - local tab = T('name', name) + local tab = O('name', name) local env = getfenv(2) function env.set_OPEN(f) tab.OPEN = f end function env.set_CLOSE(f) tab.CLOSE = f end @@ -80,7 +81,8 @@ do end end -function SetItemRef(...) auto_release(arg, true) +function SetItemRef(...) + auto_release(arg, true) if arg[3] ~= 'RightButton' or not index(active_tab, 'CLICK_LINK') or not strfind(arg[1], '^item:%d+') then return orig.SetItemRef(unpack(arg)) end @@ -89,7 +91,8 @@ function SetItemRef(...) auto_release(arg, true) end end -function UseContainerItem(...) auto_release(arg, true) +function UseContainerItem(...) + auto_release(arg, true) if modified or not index(active_tab, 'USE_ITEM') then return orig.UseContainerItem(unpack(arg)) end @@ -98,8 +101,9 @@ function UseContainerItem(...) auto_release(arg, true) end end -M.orig = setmetatable({[_G]=t}, {__index=function(self, key) return self[_G][key] end}) -function M.hook(...) auto_release(arg, true) +M.orig = setmetatable({[_G]=T}, {__index=function(self, key) return self[_G][key] end}) +function M.hook(...) + auto_release(arg, true) local name, object, handler if arg.n == 3 then name, object, handler = unpack(arg) @@ -107,7 +111,7 @@ function M.hook(...) auto_release(arg, true) object, name, handler = _G, unpack(arg) end handler = handler or getfenv(2)[name] - orig[object] = orig[object] or t + orig[object] = orig[object] or T assert(not orig[object][name], '"' .. name .. '" is already hooked into.') orig[object][name], object[name] = object[name], handler return hook @@ -195,7 +199,8 @@ end do local last_owner_page_requested - function GetOwnerAuctionItems(...) auto_release(arg, true) + function GetOwnerAuctionItems(...) + auto_release(arg, true) local page = arg[1] last_owner_page_requested = page return orig.GetOwnerAuctionItems(unpack(arg)) @@ -208,7 +213,8 @@ end function ADDON_LOADED.Blizzard_AuctionUI() AuctionFrame:UnregisterEvent('AUCTION_HOUSE_SHOW') AuctionFrame:SetScript('OnHide', nil) - hook('ShowUIPanel', function(...) auto_release(arg, true) + hook('ShowUIPanel', function(...) + auto_release(arg, true) if arg[1] == AuctionFrame then return AuctionFrame:Show() end return orig.ShowUIPanel(unpack(arg)) end) @@ -223,7 +229,8 @@ do return label end function ADDON_LOADED.Blizzard_CraftUI() - hook('CraftFrame_SetSelection', function(...) auto_release(arg, true) + hook('CraftFrame_SetSelection', function(...) + auto_release(arg, true) local ret = temp-A(orig.CraftFrame_SetSelection(unpack(arg))) local id = GetCraftSelectionIndex() local reagent_count = GetCraftNumReagents(id) @@ -250,7 +257,8 @@ do end) end function ADDON_LOADED.Blizzard_TradeSkillUI() - hook('TradeSkillFrame_SetSelection', function(...) auto_release(arg, true) + hook('TradeSkillFrame_SetSelection', function(...) + auto_release(arg, true) local ret = temp-A(orig.TradeSkillFrame_SetSelection(unpack(arg))) local id = GetTradeSkillSelectionIndex() local reagent_count = GetTradeSkillNumReagents(id) @@ -278,7 +286,8 @@ do end end -function AuctionFrameAuctions_OnEvent(...) auto_release(arg, true) +function AuctionFrameAuctions_OnEvent(...) + auto_release(arg, true) if AuctionFrameAuctions:IsVisible() then return orig.AuctionFrameAuctions_OnEvent(unpack(arg)) end diff --git a/control.lua b/control.lua index 496880a..9fa4d49 100644 --- a/control.lua +++ b/control.lua @@ -2,7 +2,7 @@ module 'aux' local event_frame = CreateFrame('Frame') -local listeners, threads = t, t +local listeners, threads = T, T local thread_id function M.get_thread_id() return thread_id end @@ -70,7 +70,7 @@ end function M.event_listener(event, cb) local listener_id = unique_id - listeners[listener_id] = T( + listeners[listener_id] = O( 'event', event, 'cb', cb, 'kill', vararg-function(arg) if getn(arg) == 0 or arg[1] then kill_listener(listener_id) end end @@ -95,7 +95,7 @@ do auto_release(arg, false) arg.f = tremove(arg, 1) local thread_id = unique_id - threads[thread_id] = T('k', setmetatable(arg, mt)) + threads[thread_id] = O('k', setmetatable(arg, mt)) return thread_id end diff --git a/core/cache.lua b/core/cache.lua index 6fe0425..0c28753 100644 --- a/core/cache.lua +++ b/core/cache.lua @@ -1,6 +1,6 @@ module 'aux.core.cache' -include 'green_t' +include 'green_T' include 'aux' local info = require 'aux.util.info' @@ -12,12 +12,12 @@ local MAX_ITEM_ID = 30000 local items_schema = {'tuple', '#', {name='string'}, {quality='number'}, {level='number'}, {class='string'}, {subclass='string'}, {slot='string'}, {max_stack='number'}, {texture='string'}} local merchant_buy_schema = {'tuple', '#', {unit_price='number'}, {limited='boolean'}} -_G.aux_items = t -_G.aux_item_ids = t -_G.aux_auctionable_items = t -_G.aux_merchant_buy = t -_G.aux_merchant_sell = t -_G.aux_characters = t +_G.aux_items = T +_G.aux_item_ids = T +_G.aux_auctionable_items = T +_G.aux_merchant_buy = T +_G.aux_merchant_sell = T +_G.aux_characters = T function LOAD() scan_wdb() @@ -87,7 +87,7 @@ function M.item_info(item_id) local data_string = aux_items[item_id] if data_string then local cached_data = temp-persistence.read(items_schema, data_string) - return T( + return O( '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 - aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, T( + aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, O( 'unit_price', unit_price, 'limited', buy_info.limited and new_limited )) else - aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, T( + aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, O( '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 aux_item_ids[strlower(name)] then aux_item_ids[strlower(name)] = item_id - aux_items[item_id] = persistence.write(items_schema, T( + aux_items[item_id] = persistence.write(items_schema, O( 'name', name, 'quality', quality, 'level', level, diff --git a/core/disenchant.lua b/core/disenchant.lua index b9b1b88..fafcea0 100644 --- a/core/disenchant.lua +++ b/core/disenchant.lua @@ -1,6 +1,6 @@ module 'aux.core.disenchant' -include 'green_t' +include 'green_T' include 'aux' local history = require 'aux.core.history' @@ -8,7 +8,7 @@ local history = require 'aux.core.history' local UNCOMMON, RARE, EPIC = 2, 3, 4 do - local data = T( + local data = O( 10940, A('DUST', '1-20'), 11083, A('DUST', '21-30'), 11137, A('DUST', '31-40'), @@ -86,7 +86,7 @@ end function M.distribution(slot, quality, level) if not ARMOR[slot] and not WEAPON[slot] or level == 0 then - return t + return T end local function p(probability_armor, probability_weapon) @@ -100,102 +100,102 @@ function M.distribution(slot, quality, level) if quality == UNCOMMON then if level <= 10 then return A( - weak-T('item_id', 10940, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.8, .2)), - weak-T('item_id', 10938, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .8)) + weak-O('item_id', 10940, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.8, .2)), + weak-O('item_id', 10938, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .8)) ) elseif level <= 15 then return A( - weak-T('item_id', 10940, 'min_quantity', 2, 'max_quantity', 3, 'probability', p(.75, .2)), - weak-T('item_id', 10939, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)), - weak-T('item_id', 10978, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05) + weak-O('item_id', 10940, 'min_quantity', 2, 'max_quantity', 3, 'probability', p(.75, .2)), + weak-O('item_id', 10939, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)), + weak-O('item_id', 10978, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05) ) elseif level <= 20 then return A( - weak-T('item_id', 10940, 'min_quantity', 4, 'max_quantity', 6, 'probability', p(.75, .15)), - weak-T('item_id', 10998, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.15, .75)), - weak-T('item_id', 10978, 'min_quantity', 1, 'max_quantity', 1, 'probability', .10) + weak-O('item_id', 10940, 'min_quantity', 4, 'max_quantity', 6, 'probability', p(.75, .15)), + weak-O('item_id', 10998, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.15, .75)), + weak-O('item_id', 10978, 'min_quantity', 1, 'max_quantity', 1, 'probability', .10) ) elseif level <= 25 then return A( - weak-T('item_id', 11083, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.75, .2)), - weak-T('item_id', 11082, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)), - weak-T('item_id', 11084, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05) + weak-O('item_id', 11083, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.75, .2)), + weak-O('item_id', 11082, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)), + weak-O('item_id', 11084, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05) ) elseif level <= 30 then return A( - weak-T('item_id', 11083, 'min_quantity', 2, 'max_quantity', 5, 'probability', p(.75, .2)), - weak-T('item_id', 11134, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)), - weak-T('item_id', 11138, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05) + weak-O('item_id', 11083, 'min_quantity', 2, 'max_quantity', 5, 'probability', p(.75, .2)), + weak-O('item_id', 11134, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)), + weak-O('item_id', 11138, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05) ) elseif level <= 35 then return A( - weak-T('item_id', 11137, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.75, .2)), - weak-T('item_id', 11135, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)), - weak-T('item_id', 11139, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05) + weak-O('item_id', 11137, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.75, .2)), + weak-O('item_id', 11135, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)), + weak-O('item_id', 11139, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05) ) elseif level <= 40 then return A( - weak-T('item_id', 11137, 'min_quantity', 2, 'max_quantity', 5, 'probability', p(.75, .2)), - weak-T('item_id', 11174, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)), - weak-T('item_id', 11177, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05) + weak-O('item_id', 11137, 'min_quantity', 2, 'max_quantity', 5, 'probability', p(.75, .2)), + weak-O('item_id', 11174, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)), + weak-O('item_id', 11177, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05) ) elseif level <= 45 then return A( - weak-T('item_id', 11176, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.75, .2)), - weak-T('item_id', 11175, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)), - weak-T('item_id', 11178, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05) + weak-O('item_id', 11176, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.75, .2)), + weak-O('item_id', 11175, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)), + weak-O('item_id', 11178, 'min_quantity', 1, 'max_quantity', 1, 'probability', .05) ) elseif level <= 50 then return A( - weak-T('item_id', 11176, 'min_quantity', 2, 'max_quantity', 5, 'probability', p(.75, .22)), - weak-T('item_id', 16202, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)), - weak-T('item_id', 14343, 'min_quantity', 1, 'max_quantity', 1, 'probability', p(.05, .03)) + weak-O('item_id', 11176, 'min_quantity', 2, 'max_quantity', 5, 'probability', p(.75, .22)), + weak-O('item_id', 16202, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)), + weak-O('item_id', 14343, 'min_quantity', 1, 'max_quantity', 1, 'probability', p(.05, .03)) ) elseif level <= 55 then return A( - weak-T('item_id', 16204, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.75, .22)), - weak-T('item_id', 16203, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)), - weak-T('item_id', 14344, 'min_quantity', 1, 'max_quantity', 1, 'probability', p(.05, .03)) + weak-O('item_id', 16204, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.75, .22)), + weak-O('item_id', 16203, 'min_quantity', 1, 'max_quantity', 2, 'probability', p(.2, .75)), + weak-O('item_id', 14344, 'min_quantity', 1, 'max_quantity', 1, 'probability', p(.05, .03)) ) elseif level <= 60 then return A( - weak-T('item_id', 16204, 'min_quantity', 2, 'max_quantity', 5, 'probability', p(.75, .22)), - weak-T('item_id', 16203, 'min_quantity', 2, 'max_quantity', 3, 'probability', p(.2, .75)), - weak-T('item_id', 14344, 'min_quantity', 1, 'max_quantity', 1, 'probability', p(.05, .03)) + weak-O('item_id', 16204, 'min_quantity', 2, 'max_quantity', 5, 'probability', p(.75, .22)), + weak-O('item_id', 16203, 'min_quantity', 2, 'max_quantity', 3, 'probability', p(.2, .75)), + weak-O('item_id', 14344, 'min_quantity', 1, 'max_quantity', 1, 'probability', p(.05, .03)) ) end elseif quality == RARE then if level <= 20 then - return A(weak-T('item_id', 10978, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1)) + return A(weak-O('item_id', 10978, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1)) elseif level <= 25 then - return A(weak-T('item_id', 11084, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1)) + return A(weak-O('item_id', 11084, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1)) elseif level <= 30 then - return A(weak-T('item_id', 11138, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1)) + return A(weak-O('item_id', 11138, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1)) elseif level <= 35 then - return A(weak-T('item_id', 11139, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1)) + return A(weak-O('item_id', 11139, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1)) elseif level <= 40 then - return A(weak-T('item_id', 11177, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1)) + return A(weak-O('item_id', 11177, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1)) elseif level <= 45 then - return A(weak-T('item_id', 11178, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1)) + return A(weak-O('item_id', 11178, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1)) elseif level <= 50 then - return A(weak-T('item_id', 14343, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1)) + return A(weak-O('item_id', 14343, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1)) elseif level <= 55 then - return A(weak-T('item_id', 14344, 'min_quantity', 1, 'max_quantity', 1, 'probability', .995), T('item_id', 20725, 'min_quantity', 1, 'max_quantity', 1, 'probability', .005)) + return A(weak-O('item_id', 14344, 'min_quantity', 1, 'max_quantity', 1, 'probability', .995), O('item_id', 20725, 'min_quantity', 1, 'max_quantity', 1, 'probability', .005)) elseif level <= 60 then - return A(weak-T('item_id', 14344, 'min_quantity', 1, 'max_quantity', 1, 'probability', .995), T('item_id', 20725, 'min_quantity', 1, 'max_quantity', 1, 'probability', .005)) + return A(weak-O('item_id', 14344, 'min_quantity', 1, 'max_quantity', 1, 'probability', .995), O('item_id', 20725, 'min_quantity', 1, 'max_quantity', 1, 'probability', .005)) end elseif quality == EPIC then if level <= 40 then - return A(weak-T('item_id', 11177, 'min_quantity', 2, 'max_quantity', 4, 'probability', 1)) + return A(weak-O('item_id', 11177, 'min_quantity', 2, 'max_quantity', 4, 'probability', 1)) elseif level <= 45 then - return A(weak-T('item_id', 11178, 'min_quantity', 2, 'max_quantity', 4, 'probability', 1)) + return A(weak-O('item_id', 11178, 'min_quantity', 2, 'max_quantity', 4, 'probability', 1)) elseif level <= 50 then - return A(weak-T('item_id', 14343, 'min_quantity', 2, 'max_quantity', 4, 'probability', 1)) + return A(weak-O('item_id', 14343, 'min_quantity', 2, 'max_quantity', 4, 'probability', 1)) elseif level <= 55 then - return A(weak-T('item_id', 20725, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1)) + return A(weak-O('item_id', 20725, 'min_quantity', 1, 'max_quantity', 1, 'probability', 1)) elseif level <= 60 then - return A(weak-T('item_id', 20725, 'min_quantity', 1, 'max_quantity', 2, 'probability', 1)) + return A(weak-O('item_id', 20725, 'min_quantity', 1, 'max_quantity', 2, 'probability', 1)) end end - return t + return T end \ No newline at end of file diff --git a/core/history.lua b/core/history.lua index a02855e..8a25745 100644 --- a/core/history.lua +++ b/core/history.lua @@ -1,20 +1,20 @@ module 'aux.core.history' -include 'green_t' +include 'green_T' include 'aux' local persistence = require 'aux.util.persistence' local history_schema = {'tuple', '#', {next_push='number'}, {daily_min_buyout='number'}, {daily_max_price='number'}, {data_points={'list', ';', {'tuple', '@', {market_value='number'}, {time='number'}}}}} -local value_cache = t +local value_cache = T do local cache function get_data() if not cache then local dataset = persistence.dataset - cache = dataset.history or t + cache = dataset.history or T dataset.history = cache end return cache @@ -34,7 +34,7 @@ do end function get_new_record() - return T('next_push', next_push, 'data_points', t) + return O('next_push', next_push, 'data_points', T) end function read_record(item_key) @@ -79,11 +79,11 @@ function M.value(item_key) local item_record, value item_record = read_record(item_key) if getn(item_record.data_points) > 0 then - local total_weight, weighted_values = 0, tt + local total_weight, weighted_values = 0, temp-T 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, T('value', data_point.market_value, 'weight', weight)) + tinsert(weighted_values, O('value', data_point.market_value, 'weight', weight)) end for _, weighted_value in weighted_values do weighted_value.weight = weighted_value.weight / total_weight @@ -92,7 +92,7 @@ function M.value(item_key) else value = calculate_market_value(item_record) end - value_cache[item_key] = T('value', value, 'next_push', item_record.next_push) + value_cache[item_key] = O('value', value, 'next_push', item_record.next_push) end return value_cache[item_key].value end @@ -118,7 +118,7 @@ end function push_record(item_record) for market_value in present(calculate_market_value(item_record)) do - tinsert(item_record.data_points, 1, weak-T('market_value', market_value, 'time', item_record.next_push)) + tinsert(item_record.data_points, 1, weak-O('market_value', market_value, 'time', item_record.next_push)) while getn(item_record.data_points) > 11 do release(item_record.data_points[getn(item_record.data_points)]) tremove(item_record.data_points) diff --git a/core/post.lua b/core/post.lua index b750891..3dfe153 100644 --- a/core/post.lua +++ b/core/post.lua @@ -1,6 +1,6 @@ module 'aux.core.post' -include 'green_t' +include 'green_T' include 'aux' local info = require 'aux.util.info' diff --git a/core/scan.lua b/core/scan.lua index 6066cbf..91c47a4 100644 --- a/core/scan.lua +++ b/core/scan.lua @@ -1,6 +1,6 @@ module 'aux.core.scan' -include 'green_t' +include 'green_T' include 'aux' local info = require 'aux.util.info' @@ -9,7 +9,7 @@ local history = require 'aux.core.history' local PAGE_SIZE = 50 do - local scan_states = t + local scan_states = T function M.start(params) for old_state in present(scan_states[params.type]) do @@ -25,7 +25,7 @@ do end function M.abort(scan_id) - local aborted = t + local aborted = T for type, state in scan_states do if not scan_id or state.id == scan_id then kill_thread(state.id) @@ -96,7 +96,7 @@ do elseif state.params.type == 'owner' then GetOwnerAuctionItems(state.page) else - local blizzard_query = query.blizzard_query or t + local blizzard_query = query.blizzard_query or T QueryAuctionItems( blizzard_query.name, blizzard_query.min_level, diff --git a/core/slash.lua b/core/slash.lua index 37f2250..822fe88 100644 --- a/core/slash.lua +++ b/core/slash.lua @@ -1,6 +1,6 @@ module 'aux.core.slash' -include 'green_t' +include 'green_T' include 'aux' local persistence = require 'aux.util.persistence' @@ -19,18 +19,18 @@ function SlashCmdList.AUX(command) persistence.dataset.post = nil print('Post settings cleared.') elseif arguments[1] == 'clear' and arguments[2] == 'datasets' then - _G.aux_datasets = t + _G.aux_datasets = T print('Datasets cleared.') elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'buy' then - _G.aux_merchant_buy = t + _G.aux_merchant_buy = T print('Merchant buy prices cleared.') elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'sell' then - _G.aux_merchant_sell = t + _G.aux_merchant_sell = T print('Merchant sell prices cleared.') elseif arguments[1] == 'clear' and arguments[2] == 'item' and arguments[3] == 'cache' then - _G.aux_items = t - _G.aux_item_ids = t - _G.aux_auctionable_items = t + _G.aux_items = T + _G.aux_item_ids = T + _G.aux_auctionable_items = T print('Item cache cleared.') elseif arguments[1] == 'populate' and arguments[2] == 'wdb' then cache.populate_wdb() @@ -60,7 +60,7 @@ function SlashCmdList.AUX(command) print('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 t + aux_characters[realm] = aux_characters[realm] or T for i = 3, getn(arguments) do local name = gsub(strlower(arguments[i]), '^%l', strupper) if not aux_characters[realm][name] then @@ -82,8 +82,8 @@ function SlashCmdList.AUX(command) end elseif arguments[1] == 'chars' then local realm = GetCVar'realmName' - local chars = t - for name in aux_characters[realm] or t do + local chars = T + for name in aux_characters[realm] or T do tinsert(chars, name) end if getn(chars) > 0 then diff --git a/core/stack.lua b/core/stack.lua index 149ac3b..75438ca 100644 --- a/core/stack.lua +++ b/core/stack.lua @@ -1,6 +1,6 @@ module 'aux.core.stack' -include 'green_t' +include 'green_T' include 'aux' local info = require 'aux.util.info' diff --git a/core/tooltip.lua b/core/tooltip.lua index cc6eaf3..944f03e 100644 --- a/core/tooltip.lua +++ b/core/tooltip.lua @@ -1,6 +1,6 @@ module 'aux.core.tooltip' -include 'green_t' +include 'green_T' include 'aux' local info = require 'aux.util.info' @@ -20,7 +20,7 @@ local color = { _G.aux_tooltip_value = true -local game_tooltip_hooks, game_tooltip_money = t, 0 +local game_tooltip_hooks, game_tooltip_money = T, 0 function LOAD() do diff --git a/gui/auction_listing.lua b/gui/auction_listing.lua index dd48e62..8b282f9 100644 --- a/gui/auction_listing.lua +++ b/gui/auction_listing.lua @@ -1,6 +1,6 @@ module 'aux.gui.auction_listing' -include 'green_t' +include 'green_T' include 'aux' local info = require 'aux.util.info' @@ -703,13 +703,13 @@ local methods = { self.rowInfo[getn(self.rowInfo)].children[getn(self.rowInfo[getn(self.rowInfo)].children)].numAuctions = self.rowInfo[getn(self.rowInfo)].children[getn(self.rowInfo[getn(self.rowInfo)].children)].numAuctions + 1 elseif prevRecord and record.item_key == prevRecord.item_key then -- it's the same base item as the previous row so insert a new auction - tinsert(self.rowInfo[getn(self.rowInfo)].children, T('numAuctions', 1, 'record', record)) + tinsert(self.rowInfo[getn(self.rowInfo)].children, O('numAuctions', 1, 'record', record)) if self.expanded[self.rowInfo[getn(self.rowInfo)].expandKey] then self.rowInfo.numDisplayRows = self.rowInfo.numDisplayRows + 1 end else -- it's a different base item from the previous row - tinsert(self.rowInfo, T('item_key', record.item_key, 'expandKey', record.item_key, 'children', A(T('numAuctions', 1, 'record', record)))) + tinsert(self.rowInfo, O('item_key', record.item_key, 'expandKey', record.item_key, 'children', A(O('numAuctions', 1, 'record', record)))) self.rowInfo.numDisplayRows = self.rowInfo.numDisplayRows + 1 end end @@ -918,7 +918,8 @@ local methods = { end end, - SetSort = function(self, ...) auto_release(arg, true) + SetSort = function(self, ...) + auto_release(arg, true) for k = 1, arg.n do for i, sort in self.sorts do if sort.index == abs(arg[k]) then @@ -988,10 +989,10 @@ function M.CreateAuctionResultsTable(parent, config) local numRows = 16 rt.ROW_HEIGHT = (parent:GetHeight() - HEAD_HEIGHT - HEAD_SPACE) / numRows rt.scrollDisabled = nil - rt.expanded = t - rt.handlers = t - rt.sorts = t - rt.records = t + rt.expanded = T + rt.handlers = T + rt.sorts = T + rt.records = T rt.rowInfo = {numDisplayRows=0} for name, func in methods do @@ -1036,7 +1037,7 @@ function M.CreateAuctionResultsTable(parent, config) _G[scrollBar:GetName() .. 'ScrollDownButton']:Hide() -- create the header cells - rt.headCells = t + rt.headCells = T for i, column_config in rt.config do local cell = CreateFrame('Button', nil, rt.contentFrame) cell:SetHeight(HEAD_HEIGHT) @@ -1079,7 +1080,7 @@ function M.CreateAuctionResultsTable(parent, config) end -- create the rows - rt.rows = t + rt.rows = T for i = 1, numRows do local row = CreateFrame('Frame', nil, rt.contentFrame) row:SetHeight(rt.ROW_HEIGHT) @@ -1097,7 +1098,7 @@ function M.CreateAuctionResultsTable(parent, config) row.highlight = highlight row.rt = rt - row.cells = t + row.cells = T for j = 1, getn(rt.config) do local cell = CreateFrame('Button', nil, row) local text = cell:CreateFontString() diff --git a/gui/core.lua b/gui/core.lua index 9df5ed7..4d6db81 100644 --- a/gui/core.lua +++ b/gui/core.lua @@ -1,6 +1,6 @@ module 'aux.gui' -include 'green_t' +include 'green_T' include 'aux' M.font = [[Fonts\ARIALN.TTF]] @@ -24,7 +24,8 @@ function LOAD() aux_background:SetTexture(color.content.background()) aux_background:SetAllPoints(DropDownList1Backdrop) blizzard_backdrop = DropDownList1Backdrop:GetBackdrop() - hook('ToggleDropDownMenu', function(...) auto_release(arg, true) + hook('ToggleDropDownMenu', function(...) + auto_release(arg, true) local ret = temp-A(orig.ToggleDropDownMenu(unpack(arg))) local dropdown = _G[arg[4] or ''] or this:GetParent() if strfind(dropdown:GetName() or '', '^AuxFrame%d+$') then @@ -96,7 +97,7 @@ end do local menu = CreateFrame('Frame', unique_name, UIParent, 'UIMenuTemplate') local orig = menu:GetScript'OnShow' - local structure = t + local structure = T menu:SetScript('OnShow', function() UIMenu_Initialize() for i = 1, getn(structure), 2 do @@ -203,7 +204,7 @@ function M.button(parent, text_height) end do - local mt = {__index=t} + local mt = {__index=T} function mt.__index:create_tab(text) local id = getn(self._tabs) + 1 @@ -290,7 +291,7 @@ do local self = { _frame = parent, _orientation = orientation, - _tabs = t, + _tabs = T, } return setmetatable(self, mt) end @@ -335,7 +336,7 @@ function M.editbox(parent) end) editbox:SetScript('OnChar', function() (this.char or nop)() end) do - local last_click = T('t', 0) + local last_click = O('t', 0) editbox:SetScript('OnMouseDown', function() if arg1 == 'RightButton' then this:SetText('') diff --git a/gui/item_listing.lua b/gui/item_listing.lua index 871da3b..b99c2fb 100644 --- a/gui/item_listing.lua +++ b/gui/item_listing.lua @@ -1,6 +1,6 @@ module 'aux.gui.item_listing' -include 'green_t' +include 'green_T' include 'aux' local info = require 'aux.util.info' @@ -63,7 +63,7 @@ function M.create(parent, on_click, selected) _G[scrollBar:GetName() .. 'ScrollUpButton']:Hide() _G[scrollBar:GetName() .. 'ScrollDownButton']:Hide() - local rows = t + local rows = T local row_index = 1 local max_height = content:GetHeight() local total_height = 0 diff --git a/gui/listing.lua b/gui/listing.lua index 59b3f0f..2bb3462 100644 --- a/gui/listing.lua +++ b/gui/listing.lua @@ -1,6 +1,6 @@ module 'aux.gui.listing' -include 'green_t' +include 'green_T' include 'aux' local gui = require 'aux.gui' @@ -442,11 +442,11 @@ function M.CreateScrollingTable(parent) -- setup default values st.isTSMScrollingTable = true - st.sizes = t - st.headCols = t - st.rows = t - st.handlers = t - st.sortInfo = t + st.sizes = T + st.headCols = T + st.rows = T + st.handlers = T + st.sortInfo = T st.colInfo = DEFAULT_COL_INFO return st diff --git a/libs/green_t.lua b/libs/green_t.lua index bb4304b..70c7be5 100644 --- a/libs/green_t.lua +++ b/libs/green_t.lua @@ -1,4 +1,4 @@ -library 'green_t' +library 'green_T' local next, getn, setn, tremove, type, setmetatable = next, getn, table.setn, tremove, type, setmetatable @@ -62,13 +62,7 @@ do M.dep_release = dep_release end -M.get_t = acquire - -function M.get_tt() - local t = acquire() - auto_release(t, true) - return t -end +M.get_T = acquire M.temp = setmetatable({}, { __metatable = false, @@ -152,7 +146,7 @@ M.S = vararg(function(arg) end return t end) -M.T = vararg(function(arg) +M.O = vararg(function(arg) local t = acquire() for i = 1, getn(arg), 2 do t[arg[i]] = arg[i + 1] diff --git a/tabs/auctions/core.lua b/tabs/auctions/core.lua index 325a6c2..017fe53 100644 --- a/tabs/auctions/core.lua +++ b/tabs/auctions/core.lua @@ -1,6 +1,6 @@ module 'aux.tabs.auctions' -include 'green_t' +include 'green_T' include 'aux' local info = require 'aux.util.info' @@ -9,7 +9,7 @@ local scan = require 'aux.core.scan' TAB 'Auctions' -auction_records = t +auction_records = T function OPEN() frame:Show() @@ -34,7 +34,7 @@ function M.scan_auctions() update_listing() scan.start{ type = 'owner', - queries = {{blizzard_query = t}}, + queries = {{blizzard_query = T}}, on_page_loaded = function(page, total_pages) status_bar:update_status((page - 1) / total_pages, 0) status_bar:set_text(format('Scanning (Page %d / %d)', page, total_pages)) @@ -56,7 +56,7 @@ end do local scan_id = 0 - local IDLE, SEARCHING, FOUND = t, t, t + local IDLE, SEARCHING, FOUND = T, T, T local state = IDLE local found_index diff --git a/tabs/bids/core.lua b/tabs/bids/core.lua index 3e1f870..930e5e3 100644 --- a/tabs/bids/core.lua +++ b/tabs/bids/core.lua @@ -1,6 +1,6 @@ module 'aux.tabs.bids' -include 'green_t' +include 'green_T' include 'aux' local info = require 'aux.util.info' @@ -9,7 +9,7 @@ local scan = require 'aux.core.scan' TAB 'Bids' -auction_records = t +auction_records = T function OPEN() frame:Show() @@ -34,7 +34,7 @@ function M.scan_bids() update_listing() scan.start{ type = 'bidder', - queries = A(T('blizzard_query', t)), + queries = A(O('blizzard_query', T)), on_page_loaded = function(page, total_pages) status_bar:update_status((page - 1) / total_pages, 0) status_bar:set_text(format('Scanning (Page %d / %d)', page, total_pages)) diff --git a/tabs/post/core.lua b/tabs/post/core.lua index cf5c311..17fbe87 100644 --- a/tabs/post/core.lua +++ b/tabs/post/core.lua @@ -1,6 +1,6 @@ module 'aux.tabs.post' -include 'green_t' +include 'green_T' include 'aux' local info = require 'aux.util.info' @@ -20,7 +20,7 @@ local DURATION_4, DURATION_8, DURATION_24 = 120, 480, 1440 local settings_schema = {'tuple', '#', {stack_size='number'}, {duration='number'}, {start_price='number'}, {buyout_price='number'}, {hidden='boolean'}} function get_default_settings() - return T('duration', DURATION_8 , 'stack_size', 1, 'start_price', 0, 'buyout_price', 0, 'hidden', false) + return O('duration', DURATION_8 , 'stack_size', 1, 'start_price', 0, 'buyout_price', 0, 'hidden', false) end do @@ -28,7 +28,7 @@ do function get_data() if not data then local dataset = persistence.dataset - data = dataset.post or t + data = dataset.post or T dataset.post = data end return data @@ -45,7 +45,7 @@ function write_settings(settings, item_key) data[item_key] = persistence.write(settings_schema, settings) end -local scan_id, inventory_records, existing_auctions = 0, t, t +local scan_id, inventory_records, existing_auctions = 0, T, T function refresh_button_click() scan.abort(scan_id) @@ -108,12 +108,12 @@ end function update_auction_listing() if not ACTIVE then return end - local auction_rows = t + local auction_rows = T if selected_item then local unit_start_price = get_unit_start_price() local unit_buyout_price = get_unit_buyout_price() - for i, auction_record in existing_auctions[selected_item.key] or tt do + for i, auction_record in existing_auctions[selected_item.key] or temp-T 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)) @@ -144,15 +144,15 @@ function update_auction_listing() buyout_color = inline_color.yellow end - tinsert(auction_rows, T( + tinsert(auction_rows, O( 'cols', A( - T('value', auction_record.own and color.yellow(auction_record.count) or auction_record.count), - T('value', al.time_left(auction_record.duration)), - T('value', auction_record.stack_size == stack_size and color.yellow(auction_record.stack_size) or auction_record.stack_size), - T('value', money.to_string(auction_record.unit_blizzard_bid, true, nil, 3, bid_color)), - T('value', historical_value and al.percentage_historical(round(auction_record.unit_blizzard_bid / historical_value * 100)) or '---'), - T('value', auction_record.unit_buyout_price > 0 and money.to_string(auction_record.unit_buyout_price, true, nil, 3, buyout_color) or '---'), - T('value', auction_record.unit_buyout_price > 0 and historical_value and al.percentage_historical(round(auction_record.unit_buyout_price / historical_value * 100)) or '---') + O('value', auction_record.own and color.yellow(auction_record.count) or auction_record.count), + O('value', al.time_left(auction_record.duration)), + O('value', auction_record.stack_size == stack_size and color.yellow(auction_record.stack_size) or auction_record.stack_size), + O('value', money.to_string(auction_record.unit_blizzard_bid, true, nil, 3, bid_color)), + O('value', historical_value and al.percentage_historical(round(auction_record.unit_blizzard_bid / historical_value * 100)) or '---'), + O('value', auction_record.unit_buyout_price > 0 and money.to_string(auction_record.unit_buyout_price, true, nil, 3, buyout_color) or '---'), + O('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 )) @@ -407,18 +407,18 @@ function update_item(item) end function update_inventory_records() - local auctionable_map = tt + local auctionable_map = temp-T for slot in info.inventory do auto_release(slot, true) for item_info in present(temp-info.container_item(unpack(slot))) do local charge_class = item_info.charges or 0 if info.auctionable(item_info.tooltip, nil, item_info.lootable) then if not auctionable_map[item_info.item_key] then - local availability = t + local availability = T for i = 0, 10 do availability[i] = 0 end availability[charge_class] = item_info.count - auctionable_map[item_info.item_key] = T( + auctionable_map[item_info.item_key] = O( 'item_id', item_info.item_id, 'suffix_id', item_info.suffix_id, 'key', item_info.item_key, @@ -481,7 +481,7 @@ function refresh_entries() status_bar:set_text('Scan aborted') end, on_complete = function() - existing_auctions[item_key] = existing_auctions[item_key] or t + existing_auctions[item_key] = existing_auctions[item_key] or T refresh = true status_bar:update_status(1, 1) status_bar:set_text('Scan complete') @@ -491,7 +491,7 @@ function refresh_entries() end function record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price, duration, owner) - existing_auctions[key] = existing_auctions[key] or t + existing_auctions[key] = existing_auctions[key] or T local entry for _, record in existing_auctions[key] do if unit_blizzard_bid == record.unit_blizzard_bid and unit_buyout_price == record.unit_buyout_price and aux_quantity == record.stack_size and duration == record.duration and is_player(owner) == record.own then @@ -499,7 +499,7 @@ function record_auction(key, aux_quantity, unit_blizzard_bid, unit_buyout_price, end end if not entry then - 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) + entry = O('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/core.lua b/tabs/search/core.lua index 53107f5..711cc69 100644 --- a/tabs/search/core.lua +++ b/tabs/search/core.lua @@ -1,6 +1,6 @@ module 'aux.tabs.search' -include 'green_t' +include 'green_T' include 'aux' TAB 'Search' diff --git a/tabs/search/filter.lua b/tabs/search/filter.lua index 093d11a..3bf0f71 100644 --- a/tabs/search/filter.lua +++ b/tabs/search/filter.lua @@ -10,7 +10,7 @@ function valid_level(str) return level and bounded(1, 60, level) end -blizzard_query = setmetatable(t, { +blizzard_query = setmetatable(T, { __index = function(_, key) if key == 'name' then return name_input:GetText() @@ -195,7 +195,7 @@ end function formatted_post_filter(components) local no_line_break - local stack = tt + local stack = temp-T local str = '' for i, component in components do @@ -241,8 +241,8 @@ function data_link(id, str) return '|H' .. id .. '|h' .. str .. '|h' end -post_filter = t -filter_builder_state = T('selected', 0) +post_filter = T +filter_builder_state = O('selected', 0) function data_link_click() local button = arg3 @@ -325,7 +325,7 @@ end function initialize_filter_dropdown() for filter in temp-S('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( + UIDropDownMenu_AddButton(O( 'text', filter, 'value', filter, 'func', function() @@ -354,9 +354,9 @@ function initialize_class_dropdown() update_form() end end - UIDropDownMenu_AddButton(T('text', ALL, 'value', 0, 'func', on_click)) + UIDropDownMenu_AddButton(O('text', ALL, 'value', 0, 'func', on_click)) for i, class in temp-A(GetAuctionItemClasses()) do - UIDropDownMenu_AddButton(T('text', class, 'value', i, 'func', on_click)) + UIDropDownMenu_AddButton(O('text', class, 'value', i, 'func', on_click)) end end @@ -367,9 +367,9 @@ function initialize_subclass_dropdown() update_form() end end - UIDropDownMenu_AddButton(T('text', ALL, 'value', 0, 'func', on_click)) + UIDropDownMenu_AddButton(O('text', ALL, 'value', 0, 'func', on_click)) for i, subclass in temp-A(GetAuctionItemSubClasses(blizzard_query.class or 0)) do - UIDropDownMenu_AddButton(T('text', subclass, 'value', i, 'func', on_click)) + UIDropDownMenu_AddButton(O('text', subclass, 'value', i, 'func', on_click)) end end @@ -378,9 +378,9 @@ function initialize_slot_dropdown() UIDropDownMenu_SetSelectedValue(slot_dropdown, this.value) update_form() end - UIDropDownMenu_AddButton(T('text', ALL, 'value', '', 'func', on_click)) + UIDropDownMenu_AddButton(O('text', ALL, 'value', '', 'func', on_click)) for i, slot in temp-A(GetAuctionInvTypes(blizzard_query.class == 2 and 2 or 0, blizzard_query.subclass or 0)) do - UIDropDownMenu_AddButton(T('text', _G[slot], 'value', i, 'func', on_click)) + UIDropDownMenu_AddButton(O('text', _G[slot], 'value', i, 'func', on_click)) end end @@ -389,8 +389,8 @@ function initialize_quality_dropdown() UIDropDownMenu_SetSelectedValue(quality_dropdown, this.value) update_form() end - UIDropDownMenu_AddButton(T('text', ALL, 'value', -1, 'func', on_click)) + UIDropDownMenu_AddButton(O('text', ALL, 'value', -1, 'func', on_click)) for i = 0, 4 do - UIDropDownMenu_AddButton(T('text', _G['ITEM_QUALITY' .. i .. '_DESC'], 'value', i, 'func', on_click)) + UIDropDownMenu_AddButton(O('text', _G['ITEM_QUALITY' .. i .. '_DESC'], 'value', i, 'func', on_click)) end end diff --git a/tabs/search/frame.lua b/tabs/search/frame.lua index 34f6558..e5c9ad5 100644 --- a/tabs/search/frame.lua +++ b/tabs/search/frame.lua @@ -520,8 +520,8 @@ do filter_display = scroll_child end -status_bars = t -tables = t +status_bars = T +tables = T for _ = 1, 5 do local status_bar = gui.status_bar(frame) status_bar:SetAllPoints(status_bar_frame) diff --git a/tabs/search/results.lua b/tabs/search/results.lua index 4c55a39..7101d81 100644 --- a/tabs/search/results.lua +++ b/tabs/search/results.lua @@ -32,7 +32,7 @@ function update_real_time(enable) end do - local searches = t + local searches = T local search_index = 1 function get_current_search() @@ -75,7 +75,7 @@ do while getn(searches) > search_index do tremove(searches) end - local search = T('records', t, 'filter_string', filter_string, 'first_page', first_page, 'last_page', last_page, 'real_time', real_time) + local search = O('records', T, 'filter_string', filter_string, 'first_page', first_page, 'last_page', last_page, 'real_time', real_time) tinsert(searches, search) if getn(searches) > 5 then tremove(searches, 1) @@ -152,7 +152,7 @@ function start_real_time_scan(query, search, continuation) end local next_page - local new_records = t + local new_records = T search_scan_id = scan.start{ type = 'list', queries = {query}, @@ -173,7 +173,7 @@ function start_real_time_scan(query, search, continuation) end end, on_complete = function() - local map = tt + local map = temp-T for _, record in search.records do map[record.sniping_signature] = record end @@ -334,7 +334,7 @@ function M.execute(resume, real_time) end new_recent_search(filter_string, join(map(copy(queries), function(filter) return filter.prettified end), ';')) else - current_search.records = t + current_search.records = T current_search.table:SetDatabase(current_search.records) end current_search.first_page = first_page @@ -362,7 +362,7 @@ end do local scan_id = 0 - local IDLE, SEARCHING, FOUND = t, t, t + local IDLE, SEARCHING, FOUND = T, T, T local state = IDLE local found_index diff --git a/tabs/search/saved.lua b/tabs/search/saved.lua index 6cea75c..b2d8c2a 100644 --- a/tabs/search/saved.lua +++ b/tabs/search/saved.lua @@ -2,38 +2,38 @@ module 'aux.tabs.search' local filter_util = require 'aux.util.filter' -_G.aux_auto_buy_filters = t -_G.aux_favorite_searches = t -_G.aux_recent_searches = t +_G.aux_auto_buy_filters = T +_G.aux_favorite_searches = T +_G.aux_recent_searches = T function update_search_listings() - local autobuy_filter_rows = t + local autobuy_filter_rows = T for i, autobuy_filter in aux_auto_buy_filters do local name = strsub(autobuy_filter.prettified, 1, 250) - tinsert(autobuy_filter_rows, T( - 'cols', A(T('value', name)), + tinsert(autobuy_filter_rows, O( + 'cols', A(O('value', name)), 'search', autobuy_filter, 'index', i )) end auto_buy_listing:SetData(autobuy_filter_rows) - local favorite_search_rows = t + local favorite_search_rows = T for i, favorite_search in aux_favorite_searches do local name = strsub(favorite_search.prettified, 1, 250) - tinsert(favorite_search_rows, T( - 'cols', A(T('value', name)), + tinsert(favorite_search_rows, O( + 'cols', A(O('value', name)), 'search', favorite_search, 'index', i )) end favorite_searches_listing:SetData(favorite_search_rows) - local recent_search_rows = t + local recent_search_rows = T for i, recent_search in aux_recent_searches do local name = strsub(recent_search.prettified, 1, 250) - tinsert(recent_search_rows, T( - 'cols', A(T('value', name)), + tinsert(recent_search_rows, O( + 'cols', A(O('value', name)), 'search', recent_search, 'index', i )) @@ -42,7 +42,7 @@ function update_search_listings() end function new_recent_search(filter_string, prettified) - tinsert(aux_recent_searches, 1, T( + tinsert(aux_recent_searches, 1, O( 'filter_string', filter_string, 'prettified', prettified )) @@ -105,7 +105,7 @@ handlers = { } function get_auto_buy_validator() - local validators = t + local validators = T for _, filter in aux_auto_buy_filters do local queries, error = filter_util.queries(filter.filter_string) if queries then @@ -122,7 +122,7 @@ end function add_favorite(filter_string) local queries, error = filter_util.queries(filter_string) if queries then - tinsert(aux_favorite_searches, 1, T( + tinsert(aux_favorite_searches, 1, O( 'filter_string', filter_string, 'prettified', join(map(queries, function(query) return query.prettified end), ';') )) @@ -140,7 +140,7 @@ function add_auto_buy(filter_string) elseif size(queries[1].blizzard_query) > 0 and not filter_util.parse_filter_string(filter_string).blizzard.exact then print('Error: The automatic buyout filter does not support Blizzard filters') else - tinsert(aux_auto_buy_filters, 1, T( + tinsert(aux_auto_buy_filters, 1, O( 'filter_string', filter_string, 'prettified', join(map(queries, function(query) return query.prettified end), ';') )) diff --git a/util.lua b/util.lua index b48a9df..e7a4f2b 100644 --- a/util.lua +++ b/util.lua @@ -34,17 +34,27 @@ do end do - local _state = setmetatable(t, T('__mode', 'kv')) + local _state = setmetatable({}, {__mode='kv'}) local __index = function(self, k) return _state[self].handler({public=self, private=_state[self].state}, k) end function M.index_function(state, handler) -- TODO rename table-accessor, use predicate to stop - local state, self = {handler=handler, state=state}, t + local state, self = {handler=handler, state=state}, T _state[self] = state return setmetatable(self, {__metatable=false, __index=__index, state=state}) end end +do + local mt = {__metatable=false, __newindex=nop} + function mt:__sub(table) + return setmetatable(T, O('__metatable', false, '__newindex', nop, '__index', table)) + end + function M.wrapper() + return setmetatable(T, mt) + end +end + M.select = vararg-function(arg) for _ = 1, arg[1] do tremove(arg, 1) @@ -92,7 +102,7 @@ function M.get_modified() end function M.copy(t) - local copy = _M.t + local copy = T for k, v in t do copy[k] = v end table.setn(copy, getn(t)) return setmetatable(copy, getmetatable(t)) @@ -109,13 +119,13 @@ function M.key(value, t) end function M.keys(t) - local keys = _M.t + local keys = T for k in t do tinsert(keys, k) end return keys end function M.values(t) - local values = _M.t + local values = T for _, v in t do tinsert(values, v) end return values end @@ -170,7 +180,7 @@ function M.trim(str) end function M.split(str, separator) - local parts = t + local parts = T while true do local start_index = strfind(str, separator, 1, true) if start_index then @@ -186,7 +196,7 @@ function M.split(str, separator) end function M.tokenize(str) - local tokens = t + local tokens = T for token in string.gfind(str, '%S+') do tinsert(tokens, token) end return tokens end diff --git a/util/completion.lua b/util/completion.lua index c05d64b..8d3fef5 100644 --- a/util/completion.lua +++ b/util/completion.lua @@ -1,6 +1,6 @@ module 'aux.util.completion' -include 'green_t' +include 'green_T' include 'aux' local filter_util = require 'aux.util.filter' diff --git a/util/filter.lua b/util/filter.lua index 71967eb..f8c9737 100644 --- a/util/filter.lua +++ b/util/filter.lua @@ -1,6 +1,6 @@ module 'aux.util.filter' -include 'green_t' +include 'green_T' include 'aux' local info = require 'aux.util.info' @@ -265,7 +265,7 @@ do end, } function blizzard_filter_parser() - return setmetatable(t, mt) + return setmetatable(T, mt) end end @@ -284,10 +284,10 @@ function parse_parameter(input_type, str) end function M.parse_filter_string(str) - local filter, post_filter = t, t + local filter, post_filter = T, T local blizzard_filter_parser = blizzard_filter_parser() - local parts = str and map(split(str, '/'), function(part) return strlower(trim(part)) end) or t + local parts = str and map(split(str, '/'), function(part) return strlower(trim(part)) end) or T local i = 1 while parts[i] do @@ -327,14 +327,14 @@ function M.parse_filter_string(str) i = i + 1 end - return T('components', filter, 'blizzard', blizzard_filter_parser(), 'post', post_filter) + return O('components', filter, 'blizzard', blizzard_filter_parser(), 'post', post_filter) end function M.query(filter_string) local filter, error, suggestions = parse_filter_string(filter_string) if not filter then - return nil, suggestions or t, error + return nil, suggestions or T, error end local polish_notation_counter = 0 @@ -348,7 +348,7 @@ function M.query(filter_string) end if polish_notation_counter > 0 then - local suggestions = t + local suggestions = T for key in filters do tinsert(suggestions, strlower(key)) end @@ -367,7 +367,7 @@ end function M.queries(filter_string) local parts = split(filter_string, ';') - local queries = t + local queries = T for _, str in parts do str = trim(str) local query, _, error = query(str) @@ -381,7 +381,7 @@ function M.queries(filter_string) end function suggestions(filter) - local suggestions = t + local suggestions = T if filter.blizzard.name and size(filter.blizzard) == 1 then tinsert(suggestions, 'exact') end @@ -498,7 +498,7 @@ end function blizzard_query(filter) local filters = filter.blizzard - local query = T('name', filters.name and filters.name[2]) + local query = O('name', filters.name and filters.name[2]) local item_info, class_index, subclass_index, slot_index local item_id = filters.name and cache.item_id(filters.name[2]) item_info = item_id and info.item(item_id) @@ -526,7 +526,7 @@ end function validator(filter) - local validators = t + local validators = T for i, component in filter.post do local type, name, param = unpack(component) if type == 'filter' then @@ -538,11 +538,11 @@ function validator(filter) if filter.blizzard.exact and strlower(info.item(record.item_id).name) ~= filter.blizzard.name[2] then return false end - local stack = tt + local stack = temp-T for i = getn(filter.post), 1, -1 do local type, name, param = unpack(filter.post[i]) if type == 'operator' then - local args = tt + local args = temp-T while (not param or param > 0) and getn(stack) > 0 do tinsert(args, tremove(stack)) param = param and param - 1 @@ -564,7 +564,7 @@ end function M.query_builder() local filter - return T( + return O( 'append', function(part) filter = not filter and part or filter .. '/' .. part end, diff --git a/util/info.lua b/util/info.lua index 330868d..3b8a545 100644 --- a/util/info.lua +++ b/util/info.lua @@ -1,6 +1,6 @@ module 'aux.util.info' -include 'green_t' +include 'green_T' include 'aux' local cache = require 'aux.core.cache' @@ -38,7 +38,7 @@ do INVTYPE_TABARD = {19}, } function M.inventory_index(slot) - return unpack(inventory_index_map[slot] or tt) + return unpack(inventory_index_map[slot] or temp-T) end end @@ -53,7 +53,7 @@ function M.container_item(bag, slot) local max_charges = max_item_charges(item_id) local charges = max_charges and item_charges(tooltip) local aux_quantity = charges or count - return T( + return O( 'item_id', item_id, 'suffix_id', suffix_id, 'unique_id', unique_id, @@ -88,7 +88,7 @@ end function M.auction_sell_item() for name, texture, count, quality, usable, vendor_price in GetAuctionSellItemInfo do - return T( + return O( 'name', name, 'texture', texture, 'quality', quality, @@ -116,7 +116,7 @@ function M.auction(index, query_type) local blizzard_bid = high_bid > 0 and high_bid or start_price local bid_price = high_bid > 0 and (high_bid + min_increment) or start_price - return T( + return O( 'item_id', item_id, 'suffix_id', suffix_id, 'unique_id', unique_id, @@ -180,7 +180,7 @@ end function M.set_shopping_tooltip(slot) local index1, index2 = inventory_index(slot) - local tooltips = tt + local tooltips = temp-T if index1 then local tooltip = tooltip('inventory', 'player', index1) if getn(tooltip) > 0 then @@ -195,7 +195,7 @@ function M.set_shopping_tooltip(slot) end if tooltips[1] then - tinsert(tooltips[1], 1, temp-T('left_text', 'Currently Equipped', 'left_color', temp-A(.5, .5, .5))) + tinsert(tooltips[1], 1, temp-O('left_text', 'Currently Equipped', 'left_color', temp-A(.5, .5, .5))) ShoppingTooltip1:SetOwner(GameTooltip, 'ANCHOR_BOTTOMRIGHT') load_tooltip(ShoppingTooltip1, tooltips[1]) ShoppingTooltip1:Show() @@ -203,7 +203,7 @@ function M.set_shopping_tooltip(slot) end if tooltips[2] then - tinsert(tooltips[2], 1, temp-T('left_text', 'Currently Equipped', 'left_color', temp-A(.5, .5, .5))) + tinsert(tooltips[2], 1, temp-O('left_text', 'Currently Equipped', 'left_color', temp-A(.5, .5, .5))) ShoppingTooltip2:SetOwner(ShoppingTooltip1, 'ANCHOR_BOTTOMRIGHT') load_tooltip(ShoppingTooltip2, tooltips[2]) ShoppingTooltip2:Show() @@ -283,9 +283,9 @@ function M.tooltip(setter, arg1, arg2) elseif setter == 'link' then AuxTooltip:SetHyperlink(arg1) end - local tooltip = t + local tooltip = T for i = 1, AuxTooltip:NumLines() do - tinsert(tooltip, weak-T( + tinsert(tooltip, weak-O( 'left_text', _G['AuxTooltipTextLeft' .. i]:GetText(), 'left_color', weak-A(_G['AuxTooltipTextLeft' .. i]:GetTextColor()), 'right_text', _G['AuxTooltipTextRight' .. i]:IsVisible() and _G['AuxTooltipTextRight' .. i]:GetText(), @@ -367,7 +367,7 @@ end function M.item(item_id, suffix_id) local itemstring = 'item:' .. (item_id or 0) .. ':0:' .. (suffix_id or 0) .. ':0' local name, itemstring, quality, level, class, subclass, max_stack, slot, texture = GetItemInfo(itemstring) - return name and T( + return name and O( 'name', name, 'itemstring', itemstring, 'quality', quality, diff --git a/util/money.lua b/util/money.lua index 7e9bdd9..65ebb5f 100644 --- a/util/money.lua +++ b/util/money.lua @@ -1,6 +1,6 @@ module 'aux.util.money' -include 'green_t' +include 'green_T' include 'aux' M.GOLD_TEXT = '|cffffd70ag|r' @@ -83,7 +83,7 @@ function M.to_string(money, pad, trim, decimal_points, color, no_color) local text if trim then - local parts = tt + local parts = temp-T if gold > 0 then tinsert(parts, format_number(gold, false, nil, color) .. gold_text) end diff --git a/util/persistence.lua b/util/persistence.lua index 44cb8c7..6733e31 100644 --- a/util/persistence.lua +++ b/util/persistence.lua @@ -1,16 +1,16 @@ module 'aux.util.persistence' -include 'green_t' +include 'green_T' include 'aux' -_G.aux_datasets = t +_G.aux_datasets = T do local dataset function M.get_dataset() if not dataset then local dataset_key = format('%s|%s', GetCVar'realmName', UnitFactionGroup'player') - dataset = aux_datasets[dataset_key] or t + dataset = aux_datasets[dataset_key] or T aux_datasets[dataset_key] = dataset end return dataset @@ -50,7 +50,7 @@ function M.write(schema, obj) end function read_list(schema, str) - if str == '' then return t end + if str == '' then return T end local separator = schema[2] local element_type = schema[3] return map(split(str, separator), function(part) @@ -69,7 +69,7 @@ end function read_tuple(schema, str) local separator = schema[2] - local tuple = t + local tuple = T local parts = temp-split(str, separator) for i = 3, getn(schema) do local key, type = next(schema[i]) @@ -80,7 +80,7 @@ end function write_tuple(schema, tuple) local separator = schema[2] - local parts = tt + local parts = temp-T for i = 3 , getn(schema) do local key, type = next(schema[i]) tinsert(parts, write(type, tuple[key])) diff --git a/util/scan.lua b/util/scan.lua index 2a24eee..141afbd 100644 --- a/util/scan.lua +++ b/util/scan.lua @@ -1,6 +1,6 @@ module 'aux.util.scan' -include 'green_t' +include 'green_T' include 'aux' local info = require 'aux.util.info' @@ -14,19 +14,19 @@ end function M.find(auction_record, status_bar, on_abort, on_failure, on_success) - local queries = A(t) + local queries = A(T) if auction_record.blizzard_query then local blizzard_query1 = copy(auction_record.blizzard_query) blizzard_query1.first_page = auction_record.page blizzard_query1.last_page = auction_record.page - tinsert(queries, T('blizzard_query', blizzard_query1)) + tinsert(queries, O('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, T('blizzard_query', blizzard_query2)) + tinsert(queries, O('blizzard_query', blizzard_query2)) end local item_query = item_query(auction_record.item_id, 0, 0) @@ -77,6 +77,6 @@ function M.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 T('validator', query.validator, 'blizzard_query', query.blizzard_query) + return O('validator', query.validator, 'blizzard_query', query.blizzard_query) end end \ No newline at end of file diff --git a/util/sort.lua b/util/sort.lua index 07be7e8..61bd98c 100644 --- a/util/sort.lua +++ b/util/sort.lua @@ -1,6 +1,6 @@ module 'aux.util.sort' -include 'green_t' +include 'green_T' include 'aux' M.EQ = 0