diff --git a/components/cache.lua b/components/cache.lua index 239b102..6e530fc 100644 --- a/components/cache.lua +++ b/components/cache.lua @@ -6,12 +6,12 @@ MAX_ITEM_ID = 30000 items_schema = {'record', '#', {name='string'}, {quality='number'}, {level='number'}, {class='string'}, {subclass='string'}, {slot='string'}, {max_stack='number'}, {texture='string'}} merchant_buy_schema = {'record', '#', {unit_price='number'}, {limited='boolean'} } -g.aux_items = {} -g.aux_item_ids = {} -g.aux_auctionable_items = {} -g.aux_merchant_buy = {} -g.aux_merchant_sell = {} -g.aux_characters = {} +_g.aux_items = {} +_g.aux_item_ids = {} +_g.aux_auctionable_items = {} +_g.aux_merchant_buy = {} +_g.aux_merchant_sell = {} +_g.aux_characters = {} function LOAD() scan_wdb() @@ -26,7 +26,7 @@ function LOAD() control.event_listener('NEW_AUCTION_UPDATE', function() for _, info in {info.auction_sell_item()} do for _, item_id in {cache.item_id(info.name)} do - g.aux_merchant_sell[cache.item_id(info.name)] = info.vendor_price / (info.max_item_charges(item_id) or info.count) + _g.aux_merchant_sell[cache.item_id(info.name)] = info.vendor_price / (info.max_item_charges(item_id) or info.count) end end end) @@ -78,15 +78,15 @@ end function public.merchant_info(item_id) local buy_info - if g.aux_merchant_buy[item_id] then - buy_info = persistence.read(merchant_buy_schema, g.aux_merchant_buy[item_id]) + if _g.aux_merchant_buy[item_id] then + buy_info = persistence.read(merchant_buy_schema, _g.aux_merchant_buy[item_id]) end - return g.aux_merchant_sell[item_id], buy_info and buy_info.unit_price, buy_info and buy_info.limited + return _g.aux_merchant_sell[item_id], buy_info and buy_info.unit_price, buy_info and buy_info.limited end function public.item_info(item_id) - local data_string = g.aux_items[item_id] + local data_string = _g.aux_items[item_id] if data_string then local cached_data = persistence.read(items_schema, data_string) return { @@ -104,7 +104,7 @@ function public.item_info(item_id) end function public.item_id(item_name) - return g.aux_item_ids[strlower(item_name)] + return _g.aux_item_ids[strlower(item_name)] end function merchant_buy_scan() @@ -116,8 +116,8 @@ function merchant_buy_scan() if link then local item_id = info.parse_link(link) local new_unit_price, new_limited = price / count, stock >= 0 - if g.aux_merchant_buy[item_id] then - local buy_info = persistence.read(merchant_buy_schema, g.aux_merchant_buy[item_id]) + if _g.aux_merchant_buy[item_id] then + local buy_info = persistence.read(merchant_buy_schema, _g.aux_merchant_buy[item_id]) local unit_price if buy_info.limited and not new_limited then @@ -128,12 +128,12 @@ function merchant_buy_scan() unit_price = min(buy_info.unit_price, new_unit_price) end - g.aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, { + _g.aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, { unit_price = unit_price, limited = buy_info.limited and new_limited, }) else - g.aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, { + _g.aux_merchant_buy[item_id] = persistence.write(merchant_buy_schema, { unit_price = new_unit_price, limited = new_limited, }) @@ -150,7 +150,7 @@ function merchant_sell_scan() for slot in inventory do local item_info = info.container_item(unpack(slot)) if item_info then - g.aux_merchant_sell[item_info.item_id] = item_info.tooltip_money / item_info.aux_quantity + _g.aux_merchant_sell[item_info.item_id] = item_info.tooltip_money / item_info.aux_quantity end end end @@ -162,9 +162,9 @@ function scan_wdb(item_id) while processed <= 100 and item_id <= MAX_ITEM_ID do local itemstring = 'item:'..item_id local name, _, quality, level, class, subclass, max_stack, slot, texture = GetItemInfo(itemstring) - if name and not g.aux_item_ids[strlower(name)] then - g.aux_item_ids[strlower(name)] = item_id - g.aux_items[item_id] = persistence.write(items_schema, { + if name and not _g.aux_item_ids[strlower(name)] then + _g.aux_item_ids[strlower(name)] = item_id + _g.aux_items[item_id] = persistence.write(items_schema, { name = name, quality = quality, level = level, @@ -176,7 +176,7 @@ function scan_wdb(item_id) }) local tooltip = info.tooltip(function(tt) tt:SetHyperlink(itemstring) end) if info.auctionable(tooltip, quality) then - tinsert(g.aux_auctionable_items, strlower(name)) + tinsert(_g.aux_auctionable_items, strlower(name)) end processed = processed + 1 end @@ -187,7 +187,7 @@ function scan_wdb(item_id) local t0 = GetTime() control.thread(control.when, function() return GetTime() - t0 > 0.1 end, scan_wdb, item_id) else - sort(g.aux_auctionable_items, function(a, b) return strlen(a) < strlen(b) or (strlen(a) == strlen(b) and a < b) end) + sort(_g.aux_auctionable_items, function(a, b) return strlen(a) < strlen(b) or (strlen(a) == strlen(b) and a < b) end) end end diff --git a/components/disenchant.lua b/components/disenchant.lua index d3aac4f..bf31601 100644 --- a/components/disenchant.lua +++ b/components/disenchant.lua @@ -40,7 +40,7 @@ do end end -function m.LOAD() +function LOAD() armor = set( 'INVTYPE_HEAD', 'INVTYPE_NECK', @@ -72,7 +72,7 @@ end function public.value(slot, quality, level) local expectation - for _, event in m.distribution(slot, quality, level) do + for _, event in distribution(slot, quality, level) do local value = history.value(event.item_id..':'..0) if not value then return @@ -84,19 +84,19 @@ function public.value(slot, quality, level) end function public.distribution(slot, quality, level) - if not (m.armor(slot) or m.weapon(slot)) or level == 0 then + if not (armor(slot) or weapon(slot)) or level == 0 then return {} end local function p(probability_armor, probability_weapon) - if m.armor(slot) then + if armor(slot) then return probability_armor - elseif m.weapon(slot) then + elseif weapon(slot) then return probability_weapon end end - if quality == m.UNCOMMON then + if quality == UNCOMMON then if level <= 10 then return { {item_id=10940, min_quantity=1, max_quantity=2, probability=p(0.8, 0.2)}, @@ -163,7 +163,7 @@ function public.distribution(slot, quality, level) {item_id=14344, min_quantity=1, max_quantity=1, probability=p(0.05, 0.03)}, } end - elseif quality == m.RARE then + elseif quality == RARE then if level <= 20 then return {{item_id=10978, min_quantity=1, max_quantity=1, probability=1}} elseif level <= 25 then @@ -183,7 +183,7 @@ function public.distribution(slot, quality, level) elseif level <= 60 then return {{item_id=14344, min_quantity=1, max_quantity=1, probability=0.995}, {item_id=20725, min_quantity=1, max_quantity=1, probability=0.005}} end - elseif quality == m.EPIC then + elseif quality == EPIC then if level <= 40 then return {{item_id=11177, min_quantity=2, max_quantity=4, probability=1}} elseif level <= 45 then diff --git a/components/history.lua b/components/history.lua index 78bf8b5..27f2305 100644 --- a/components/history.lua +++ b/components/history.lua @@ -10,7 +10,7 @@ function next_push() end function new_record() - return { next_push = m.next_push(), data_points = {} } + return { next_push = next_push(), data_points = {} } end function load_data() @@ -20,31 +20,31 @@ function load_data() end function read_record(item_key) - local data = m.load_data() + local data = load_data() local record if data[item_key] then record = persistence.read(history_schema, data[item_key]) else - record = m.new_record() + record = new_record() end if record.next_push <= time() then - m.push_record(record) - m.write_record(item_key, record) + push_record(record) + write_record(item_key, record) end return record end function write_record(item_key, record) - m.value_cache[item_key] = nil - local data = m.load_data() + value_cache[item_key] = nil + local data = load_data() data[item_key] = persistence.write(history_schema, record) end function public.process_auction(auction_record) - local item_record = m.read_record(auction_record.item_key) + local item_record = read_record(auction_record.item_key) local unit_bid_price = ceil(auction_record.bid_price / auction_record.aux_quantity) local unit_buyout_price = ceil(auction_record.buyout_price / auction_record.aux_quantity) @@ -55,17 +55,17 @@ function public.process_auction(auction_record) item_record.daily_max_price = max(item_record.daily_max_price or 0, unit_buyout_price, unit_bid_price) - m.write_record(auction_record.item_key, item_record) + write_record(auction_record.item_key, item_record) end function public.price_data(item_key) - local item_record = m.read_record(item_key) + local item_record = read_record(item_key) return item_record.daily_min_buyout, item_record.daily_max_price, item_record.data_points end function public.value(item_key) - if not m.value_cache[item_key] or m.value_cache[item_key].next_push <= time() then - local item_record = m.read_record(item_key) + if not value_cache[item_key] or value_cache[item_key].next_push <= time() then + local item_record = read_record(item_key) local value if getn(item_record.data_points) > 0 then @@ -80,20 +80,20 @@ function public.value(item_key) weighted_value.weight = weighted_value.weight / total_weight end - value = m.weighted_median(weighted_values) + value = weighted_median(weighted_values) else - value = m.calculate_market_value(item_record) + value = calculate_market_value(item_record) end - m.value_cache[item_key] = {value=value, next_push=item_record.next_push} + value_cache[item_key] = {value=value, next_push=item_record.next_push} end - return m.value_cache[item_key].value + return value_cache[item_key].value end function public.market_value(item_key) - local item_record = m.read_record(item_key) - return m.calculate_market_value(item_record) + local item_record = read_record(item_key) + return calculate_market_value(item_record) end function calculate_market_value(item_record) @@ -118,7 +118,7 @@ end function push_record(item_record) - local market_value = m.calculate_market_value(item_record) + local market_value = calculate_market_value(item_record) if market_value then tinsert(item_record.data_points, 1, { market_value = market_value, time = item_record.next_push }) while getn(item_record.data_points) > 11 do @@ -128,5 +128,5 @@ function push_record(item_record) item_record.daily_min_buyout = nil item_record.daily_max_price = nil - item_record.next_push = m.next_push() + item_record.next_push = next_push() end \ No newline at end of file diff --git a/components/post.lua b/components/post.lua index 5e2b668..ee506fc 100644 --- a/components/post.lua +++ b/components/post.lua @@ -3,7 +3,7 @@ aux.module 'post' state = nil function process() - if m.state.posted < m.state.count then + if state.posted < state.count then local stacking_complete @@ -11,21 +11,21 @@ function process() control.when(signal_received, function() local slot = signal_received()[1] if slot then - return m.post_auction(slot, m.process) + return post_auction(slot, process) else - return m.stop() + return stop() end end) - return stack.start(m.state.item_key, m.state.stack_size, send_signal) + return stack.start(state.item_key, state.stack_size, send_signal) end - return m.stop() + return stop() end function post_auction(slot, k) local item_info = info.container_item(unpack(slot)) - if item_info.item_key == m.state.item_key and info.auctionable(item_info.tooltip) and item_info.aux_quantity == m.state.stack_size then + if item_info.item_key == state.item_key and info.auctionable(item_info.tooltip) and item_info.aux_quantity == state.stack_size then ClearCursor() ClickAuctionSellItemButton() @@ -34,11 +34,11 @@ function post_auction(slot, k) ClickAuctionSellItemButton() ClearCursor() - StartAuction(max(1, round(m.state.unit_start_price * item_info.aux_quantity)), round(m.state.unit_buyout_price * item_info.aux_quantity), m.state.duration) + StartAuction(max(1, round(state.unit_start_price * item_info.aux_quantity)), round(state.unit_buyout_price * item_info.aux_quantity), state.duration) local send_signal, signal_received = signal() control.when(signal_received, function() - m.state.posted = m.state.posted + 1 + state.posted = state.posted + 1 return k() end) @@ -50,18 +50,18 @@ function post_auction(slot, k) end end) else - return m.stop() + return stop() end end function public.stop() - if m.state then - control.kill_thread(m.state.thread_id) + if state then + control.kill_thread(state.thread_id) - local callback = m.state.callback - local posted = m.state.posted + local callback = state.callback + local posted = state.posted - m.state = nil + state = nil if callback then callback(posted) @@ -70,11 +70,11 @@ function public.stop() end function public.start(item_key, stack_size, duration, unit_start_price, unit_buyout_price, count, callback) - m.stop() + stop() - local thread_id = control.thread(m.process) + local thread_id = control.thread(process) - m.state = { + state = { thread_id = thread_id, item_key = item_key, stack_size = stack_size, diff --git a/components/scan.lua b/components/scan.lua index a7fc8f8..54e12a0 100644 --- a/components/scan.lua +++ b/components/scan.lua @@ -145,7 +145,7 @@ function scan_page(i) end local auction_info = info.auction(i, state.params.type) - if auction_info and (auction_info.owner or state.params.ignore_owner or g.aux_ignore_owner) then + if auction_info and (auction_info.owner or state.params.ignore_owner or _g.aux_ignore_owner) then auction_info.index = i auction_info.page = state.page auction_info.blizzard_query = query.blizzard_query @@ -216,7 +216,7 @@ function wait_for_list_results(send_signal, signal_received) last_update = GetTime() updated = true end) - local ignore_owner = state.params.ignore_owner or g.aux_ignore_owner + local ignore_owner = state.params.ignore_owner or _g.aux_ignore_owner return control.thread(control.when, function() -- short circuiting order important, owner_data_complete must be called iif an update has happened. local ok = updated and (ignore_owner or owner_data_complete('list')) or last_update and GetTime() - last_update > 5 diff --git a/components/slash.lua b/components/slash.lua index 2e2657d..e6ef51e 100644 --- a/components/slash.lua +++ b/components/slash.lua @@ -9,71 +9,71 @@ function SlashCmdList.AUX(command) persistence.load_dataset().post = nil log 'Post settings cleared.' elseif arguments[1] == 'clear' and arguments[2] == 'datasets' then - g.aux_datasets = {} + _g.aux_datasets = {} log 'Datasets cleared.' elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'buy' then - g.aux_merchant_buy = {} + _g.aux_merchant_buy = {} log 'Merchant buy prices cleared.' elseif arguments[1] == 'clear' and arguments[2] == 'merchant' and arguments[3] == 'sell' then - g.aux_merchant_sell = {} + _g.aux_merchant_sell = {} log 'Merchant sell prices cleared.' elseif arguments[1] == 'clear' and arguments[2] == 'item' and arguments[3] == 'cache' then - g.aux_items = {} - g.aux_item_ids = {} - g.aux_auctionable_items = {} + _g.aux_items = {} + _g.aux_item_ids = {} + _g.aux_auctionable_items = {} log 'Item cache cleared.' elseif arguments[1] == 'populate' and arguments[2] == 'wdb' then cache.populate_wdb() elseif arguments[1] == 'tooltip' and arguments[2] == 'value' then - g.aux_tooltip_value = not g.aux_tooltip_value - log('Historical value in tooltip '..(g.aux_tooltip_value and 'enabled' or 'disabled')..'.') + _g.aux_tooltip_value = not _g.aux_tooltip_value + log('Historical value in tooltip '..(_g.aux_tooltip_value and 'enabled' or 'disabled')..'.') elseif arguments[1] == 'tooltip' and arguments[2] == 'daily' then - g.aux_tooltip_daily = not g.aux_tooltip_daily - log('Market value in tooltip '..(g.aux_tooltip_daily and 'enabled' or 'disabled')..'.') + _g.aux_tooltip_daily = not _g.aux_tooltip_daily + log('Market value in tooltip '..(_g.aux_tooltip_daily and 'enabled' or 'disabled')..'.') elseif arguments[1] == 'tooltip' and arguments[2] == 'vendor' and arguments[3] == 'buy' then - g.aux_tooltip_vendor_buy = not g.aux_tooltip_vendor_buy - log('Vendor buy price in tooltip '..(g.aux_tooltip_vendor_buy and 'enabled' or 'disabled')..'.') + _g.aux_tooltip_vendor_buy = not _g.aux_tooltip_vendor_buy + log('Vendor buy price in tooltip '..(_g.aux_tooltip_vendor_buy and 'enabled' or 'disabled')..'.') elseif arguments[1] == 'tooltip' and arguments[2] == 'vendor' and arguments[3] == 'sell' then - g.aux_tooltip_vendor_sell = not g.aux_tooltip_vendor_sell - log('Vendor sell price in tooltip '..(g.aux_tooltip_vendor_sell and 'enabled' or 'disabled')..'.') + _g.aux_tooltip_vendor_sell = not _g.aux_tooltip_vendor_sell + log('Vendor sell price in tooltip '..(_g.aux_tooltip_vendor_sell and 'enabled' or 'disabled')..'.') elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'value' then - g.aux_tooltip_disenchant_value = not g.aux_tooltip_disenchant_value - log('Disenchant value in tooltip '..(g.aux_tooltip_disenchant_value and 'enabled' or 'disabled')..'.') + _g.aux_tooltip_disenchant_value = not _g.aux_tooltip_disenchant_value + log('Disenchant value in tooltip '..(_g.aux_tooltip_disenchant_value and 'enabled' or 'disabled')..'.') elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'distribution' then - g.aux_tooltip_disenchant_distribution = not g.aux_tooltip_disenchant_distribution - log('Disenchant distribution in tooltip '..(g.aux_tooltip_disenchant_distribution and 'enabled' or 'disabled')..'.') + _g.aux_tooltip_disenchant_distribution = not _g.aux_tooltip_disenchant_distribution + log('Disenchant distribution in tooltip '..(_g.aux_tooltip_disenchant_distribution and 'enabled' or 'disabled')..'.') elseif arguments[1] == 'tooltip' and arguments[2] == 'disenchant' and arguments[3] == 'source' then - g.aux_tooltip_disenchant_source = not g.aux_tooltip_disenchant_source - log('Disenchant source in tooltip '..(g.aux_tooltip_disenchant_source and 'enabled' or 'disabled')..'.') + _g.aux_tooltip_disenchant_source = not _g.aux_tooltip_disenchant_source + log('Disenchant source in tooltip '..(_g.aux_tooltip_disenchant_source and 'enabled' or 'disabled')..'.') elseif arguments[1] == 'ignore' and arguments[2] == 'owner' then - g.aux_ignore_owner = not g.aux_ignore_owner - log('Ignoring of owner '..(g.aux_ignore_owner and 'enabled' or 'disabled')..'.') + _g.aux_ignore_owner = not _g.aux_ignore_owner + log('Ignoring of owner '..(_g.aux_ignore_owner and 'enabled' or 'disabled')..'.') elseif arguments[1] == 'chars' and arguments[2] == 'add' then local realm = GetCVar 'realmName' - g.aux_characters[realm] = g.aux_characters[realm] or {} + _g.aux_characters[realm] = _g.aux_characters[realm] or {} for i=3,getn(arguments) do local name = string.gsub(strlower(arguments[i]), '^%l', strupper) - if not g.aux_characters[realm][name] then - g.aux_characters[realm][name] = true + if not _g.aux_characters[realm][name] then + _g.aux_characters[realm][name] = true log('Character "'..name..'" added.') end end elseif arguments[1] == 'chars' and arguments[2] == 'remove' then local realm = GetCVar 'realmName' - if not g.aux_characters[realm] then + if not _g.aux_characters[realm] then return end for i=3,getn(arguments) do local name = string.gsub(strlower(arguments[i]), '^%l', strupper) - if g.aux_characters[realm][name] then - g.aux_characters[realm][name] = nil + if _g.aux_characters[realm][name] then + _g.aux_characters[realm][name] = nil log('Character "'..name..'" removed.') end end elseif arguments[1] == 'chars' then local realm = GetCVar 'realmName' local chars = {} - for name in g.aux_characters[realm] or {} do + for name in _g.aux_characters[realm] or {} do tinsert(chars, name) end if getn(chars) > 0 then diff --git a/components/stack.lua b/components/stack.lua index 3ea8954..b243474 100644 --- a/components/stack.lua +++ b/components/stack.lua @@ -24,7 +24,7 @@ end function find_item_slot(partial) for slot in inventory do - if m.matching_item(slot, partial) and not eq(slot, m.state.target_slot) then + if matching_item(slot, partial) and not eq(slot, state.target_slot) then return slot end end @@ -32,7 +32,7 @@ end function matching_item(slot, partial) local item_info = info.container_item(unpack(slot)) - return item_info and item_info.item_key == m.state.item_key and info.auctionable(item_info.tooltip) and (not partial or item_info.count < item_info.max_stack) + return item_info and item_info.item_key == state.item_key and info.auctionable(item_info.tooltip) and (not partial or item_info.count < item_info.max_stack) end function find_empty_slot() @@ -45,81 +45,81 @@ end function find_charge_item_slot() for slot in inventory do - if m.matching_item(slot) and m.charges(slot) == m.state.target_size then + if matching_item(slot) and charges(slot) == state.target_size then return slot end end end function move_item(from_slot, to_slot, amount, k) - if m.locked(from_slot) or m.locked(to_slot) then + if locked(from_slot) or locked(to_slot) then return control.wait(k) end - amount = min(m.max_stack(from_slot) - m.stack_size(to_slot), m.stack_size(from_slot), amount) - local expected_size = m.stack_size(to_slot) + amount + amount = min(max_stack(from_slot) - stack_size(to_slot), stack_size(from_slot), amount) + local expected_size = stack_size(to_slot) + amount ClearCursor() SplitContainerItem(from_slot[1], from_slot[2], amount) PickupContainerItem(unpack(to_slot)) - return control.when(function() return m.stack_size(to_slot) == expected_size end, k) + return control.when(function() return stack_size(to_slot) == expected_size end, k) end function process() - if not m.state.target_slot or not m.matching_item(m.state.target_slot) then - m.state.target_slot = m.find_item_slot() - if not m.state.target_slot then - return m.stop() + if not state.target_slot or not matching_item(state.target_slot) then + state.target_slot = find_item_slot() + if not state.target_slot then + return stop() end end - if m.charges(m.state.target_slot) then - m.state.target_slot = m.find_charge_item_slot() - return m.stop() + if charges(state.target_slot) then + state.target_slot = find_charge_item_slot() + return stop() end - if m.stack_size(m.state.target_slot) > m.state.target_size then - local slot = m.find_item_slot(true) or m.find_empty_slot() + if stack_size(state.target_slot) > state.target_size then + local slot = find_item_slot(true) or find_empty_slot() if slot then - return m.move_item( - m.state.target_slot, + return move_item( + state.target_slot, slot, - m.stack_size(m.state.target_slot) - m.state.target_size, - m.process + stack_size(state.target_slot) - state.target_size, + process ) end - elseif m.stack_size(m.state.target_slot) < m.state.target_size then - local slot = m.find_item_slot() + elseif stack_size(state.target_slot) < state.target_size then + local slot = find_item_slot() if slot then - return m.move_item( + return move_item( slot, - m.state.target_slot, - m.state.target_size - m.stack_size(m.state.target_slot), - m.process + state.target_slot, + state.target_size - stack_size(state.target_slot), + process ) end end - return m.stop() + return stop() end function public.stop() - if m.state then - control.kill_thread(m.state.thread_id) - local callback, slot = m.state.callback, m.state.target_slot - if slot and not m.matching_item(slot) then + if state then + control.kill_thread(state.thread_id) + local callback, slot = state.callback, state.target_slot + if slot and not matching_item(slot) then slot = nil end - m.state = nil + state = nil call(callback, slot) end end function public.start(item_key, size, callback) - m.stop() + stop() - local thread_id = control.thread(m.process) - m.state = { + local thread_id = control.thread(process) + state = { thread_id = thread_id, item_key = item_key, target_size = size, diff --git a/components/tooltip.lua b/components/tooltip.lua index 7618857..03a2e11 100644 --- a/components/tooltip.lua +++ b/components/tooltip.lua @@ -1,6 +1,6 @@ aux.module 'tooltip' -g.aux_tooltip_value = true +_g.aux_tooltip_value = true game_tooltip_hooks = {} hooked_setter = nil @@ -47,7 +47,7 @@ function extend_tooltip(tooltip, link, quantity) local item_id, suffix_id = info.parse_link(link) quantity = IsShiftKeyDown() and quantity or 1 - if g.aux_tooltip_disenchant_source then + if _g.aux_tooltip_disenchant_source then local color = {r=0.7, g=0.7, b=0.7} local type, range = disenchant.source(item_id) @@ -69,7 +69,7 @@ function extend_tooltip(tooltip, link, quantity) if getn(distribution) > 0 then - if g.aux_tooltip_disenchant_distribution then + if _g.aux_tooltip_disenchant_distribution then local color = {r=0.8, g=0.8, b=0.2} tooltip:AddLine('Disenchants into:', color.r, color.g, color.b) @@ -79,7 +79,7 @@ function extend_tooltip(tooltip, link, quantity) end end - if g.aux_tooltip_disenchant_value then + if _g.aux_tooltip_disenchant_value then local color = {r=0.1, g=0.6, b=0.6} local disenchant_value = disenchant.value(item_info.slot, item_info.quality, item_info.level) @@ -88,7 +88,7 @@ function extend_tooltip(tooltip, link, quantity) end end - if g.aux_tooltip_vendor_buy then + if _g.aux_tooltip_vendor_buy then local color = {r=0.8, g=0.5, b=0.1} local _, price, limited = cache.merchant_info(item_id) @@ -96,7 +96,7 @@ function extend_tooltip(tooltip, link, quantity) tooltip:AddLine('Vendor Buy '..(limited and '(limited): ' or ': ')..money.to_string2(price * quantity), color.r, color.g, color.b) end end - if g.aux_tooltip_vendor_sell then + if _g.aux_tooltip_vendor_sell then local color = {r=0.8, g=0.5, b=0.1} local price = cache.merchant_info(item_id) @@ -112,10 +112,10 @@ function extend_tooltip(tooltip, link, quantity) local value = history.value(item_key) if auctionable then - if g.aux_tooltip_value then + if _g.aux_tooltip_value then tooltip:AddLine('Value: '..(value and money.to_string2(value * quantity) or GRAY_FONT_COLOR_CODE..'---'..FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b) end - if g.aux_tooltip_daily then + if _g.aux_tooltip_daily then local market_value = history.market_value(item_key) tooltip:AddLine('Today: '..(market_value and money.to_string2(market_value * quantity)..' ('..auction_listing.percentage_historical(round(market_value / value * 100))..')' or GRAY_FONT_COLOR_CODE..'---'..FONT_COLOR_CODE_CLOSE), color.r, color.g, color.b) end diff --git a/core.lua b/core.lua index ea1fcb5..a13ede9 100644 --- a/core.lua +++ b/core.lua @@ -77,10 +77,10 @@ do end end -public.orig = setmetatable({}, {__index=function(self, key) return self[g][key] end}) +public.orig = setmetatable({}, {__index=function(self, key) return self[_g][key] end}) function public.hook(name, handler, object) handler = handler or getfenv(2)[name] - object = object or g + object = object or _g orig[object] = orig[object] or {} assert(not orig[object][name] '"'..name..'" is already hooked into.') orig[object][name], object[name] = object[name], handler @@ -129,7 +129,7 @@ end function public.is_player(name, current) local realm = GetCVar 'realmName' - return not current and index(g.aux_characters, realm, name) or UnitName 'player' == name + return not current and index(_g.aux_characters, realm, name) or UnitName 'player' == name end function public.neutral_faction() diff --git a/module.lua b/module.lua index 6acbda5..75dc7b8 100644 --- a/module.lua +++ b/module.lua @@ -1,10 +1,10 @@ -local type, setmetatable, setfenv, unpack, mask, g = type, setmetatable, setfenv, unpack, bit.band, getfenv(0) +local type, setmetatable, setfenv, unpack, mask, _g = type, setmetatable, setfenv, unpack, bit.band, getfenv(0) local PRIVATE, PUBLIC, MUTABLE, PROPERTY = 0, 1, 2, 4 local MODIFIER = {private=PRIVATE, public=PUBLIC, mutable=MUTABLE, property=PROPERTY} local MODIFIER_MASK, PROPERTY_MASK = {private=MUTABLE+PROPERTY, public=MUTABLE+PROPERTY, mutable=PRIVATE+PUBLIC}, PRIVATE+PUBLIC local error, import, define_property, lock_mt, env_mt, interface_mt, declarator_mt local _state, _modules = {}, {} -function error(message, level, ...) g.error(format(message, unpack(arg))..'\n'..debugstack(3, 5, 0), (level or 1) + 1) end +function error(message, level, ...) _g.error(format(message, unpack(arg))..'\n'..debugstack(3, 5, 0), (level or 1) + 1) end function import(imports, t) for k, v in t do imports[type(k) == 'number' and v or k] = v end end declarator_mt = {__metatable=false} function define_property(self, key, t) @@ -44,7 +44,7 @@ do end end end - env_mt = {__metatable=false, __index=index(PRIVATE, g)} + env_mt = {__metatable=false, __index=index(PRIVATE, _g)} function env_mt.__newindex(self, key, value) local state = _state[self] if not state.metadata[key] then @@ -66,14 +66,14 @@ do end end end -function g.aux_module(name) +function _g.aux_module(name) if not _state[name] then local state, declarator, env, interface, imports env, interface, declarator, imports = setmetatable({}, env_mt), setmetatable({}, interface_mt), setmetatable({}, declarator_mt), {} state = { name = name, env = env, interface = interface, declarator = declarator, imports = {}, declarator_state = PRIVATE, metadata={_g=PRIVATE, _m=PRIVATE, _i=PRIVATE, import=PRIVATE, private=PROPERTY, public=PROPERTY, getter=PROPERTY, setter=PROPERTY, mutable=PROPERTY}, - data = {_g=g, _m=env, _i=interface, import=function(t) import(imports, t) end}, + data = {_g=_g, _m=env, _i=interface, import=function(t) import(imports, t) end}, getters = {private=function() state.modifiers = PRIVATE return declarator end, public=function() state.modifiers = PUBLIC return declarator end, mutable=function() state.modifiers = MUTABLE return declarator end}, setters = {}, } @@ -107,5 +107,5 @@ frame:SetScript('OnEvent', function() end end end - g.aux.log('imported: '..count..' in '..(GetTime()-t0)) + _g.aux.log('imported: '..count..' in '..(GetTime()-t0)) end) \ No newline at end of file diff --git a/tables/auction_listing.lua b/tables/auction_listing.lua index 38f283a..a726c8c 100644 --- a/tables/auction_listing.lua +++ b/tables/auction_listing.lua @@ -1,6 +1,6 @@ aux.module 'auction_listing' -g.aux_price_per_unit = false +_g.aux_price_per_unit = false local RT_COUNT = 1 local HEAD_HEIGHT = 27 @@ -166,24 +166,24 @@ public.search_config = { end local price if record.high_bidder then - price = g.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid + price = _g.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid else - price = g.aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price + price = _g.aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price end cell:SetText(money.to_string(price, true, false, nil, color)) end, cmp = function(record_a, record_b, desc) local price_a if record_a.high_bidder then - price_a = g.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid + price_a = _g.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid else - price_a = g.aux_price_per_unit and record_a.unit_bid_price or record_a.bid_price + price_a = _g.aux_price_per_unit and record_a.unit_bid_price or record_a.bid_price end local price_b if record_b.high_bidder then - price_b = g.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid + price_b = _g.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid else - price_b = g.aux_price_per_unit and record_b.unit_bid_price or record_b.bid_price + price_b = _g.aux_price_per_unit and record_b.unit_bid_price or record_b.bid_price end return sorting.compare(price_a, price_b, desc) end, @@ -194,12 +194,12 @@ public.search_config = { align = 'RIGHT', isPrice = true, fill = function(cell, record) - local price = g.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price + local price = _g.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price cell:SetText(price > 0 and money.to_string(price, true, false) or '---') end, cmp = function(record_a, record_b, desc) - local price_a = g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price - local price_b = g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price + local price_a = _g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price + local price_b = _g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price price_a = price_a > 0 and price_a or (desc and -huge or huge) price_b = price_b > 0 and price_b or (desc and -huge or huge) @@ -308,24 +308,24 @@ public.auctions_config = { fill = function(cell, record) local price if record.high_bidder then - price = g.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid + price = _g.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid else - price = g.aux_price_per_unit and ceil(record.start_price / record.aux_quantity) or record.start_price + price = _g.aux_price_per_unit and ceil(record.start_price / record.aux_quantity) or record.start_price end cell:SetText(money.to_string(price, true, false)) end, cmp = function(record_a, record_b, desc) local price_a if record_a.high_bidder then - price_a = g.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid + price_a = _g.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid else - price_a = g.aux_price_per_unit and record_a.start_price / record_b.aux_quantity or record_a.start_price + price_a = _g.aux_price_per_unit and record_a.start_price / record_b.aux_quantity or record_a.start_price end local price_b if record_b.high_bidder then - price_b = g.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid + price_b = _g.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid else - price_b = g.aux_price_per_unit and record_b.start_price / record_b.aux_quantity or record_b.start_price + price_b = _g.aux_price_per_unit and record_b.start_price / record_b.aux_quantity or record_b.start_price end return sorting.compare(price_a, price_b, desc) end, @@ -336,12 +336,12 @@ public.auctions_config = { align = 'RIGHT', isPrice = true, fill = function(cell, record) - local price = g.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price + local price = _g.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price cell:SetText(price > 0 and money.to_string(price, true, false) or '---') end, cmp = function(record_a, record_b, desc) - local price_a = g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price - local price_b = g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price + local price_a = _g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price + local price_b = _g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price price_a = price_a > 0 and price_a or (desc and -huge or huge) price_b = price_b > 0 and price_b or (desc and -huge or huge) @@ -461,24 +461,24 @@ public.bids_config = { fill = function(cell, record) local price if record.high_bidder then - price = g.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid + price = _g.aux_price_per_unit and ceil(record.high_bid / record.aux_quantity) or record.high_bid else - price = g.aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price + price = _g.aux_price_per_unit and ceil(record.unit_bid_price) or record.bid_price end cell:SetText(money.to_string(price)) end, cmp = function(record_a, record_b, desc) local price_a if record_a.high_bidder then - price_a = g.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid + price_a = _g.aux_price_per_unit and record_a.high_bid / record_a.aux_quantity or record_a.high_bid else - price_a = g.aux_price_per_unit and record_a.unit_bid_price or record_a.bid_price + price_a = _g.aux_price_per_unit and record_a.unit_bid_price or record_a.bid_price end local price_b if record_b.high_bidder then - price_b = g.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid + price_b = _g.aux_price_per_unit and record_b.high_bid / record_b.aux_quantity or record_b.high_bid else - price_b = g.aux_price_per_unit and record_b.unit_bid_price or record_b.bid_price + price_b = _g.aux_price_per_unit and record_b.unit_bid_price or record_b.bid_price end return sorting.compare(price_a, price_b, desc) end, @@ -489,12 +489,12 @@ public.bids_config = { align = 'RIGHT', isPrice = true, fill = function(cell, record) - local price = g.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price + local price = _g.aux_price_per_unit and ceil(record.unit_buyout_price) or record.buyout_price cell:SetText(price > 0 and money.to_string(price, true, false) or '---') end, cmp = function(record_a, record_b, desc) - local price_a = g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price - local price_b = g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price + local price_a = _g.aux_price_per_unit and record_a.unit_buyout_price or record_a.buyout_price + local price_b = _g.aux_price_per_unit and record_b.unit_buyout_price or record_b.buyout_price price_a = price_a > 0 and price_a or (desc and -huge or huge) price_b = price_b > 0 and price_b or (desc and -huge or huge) @@ -567,10 +567,10 @@ local methods = { if rt.disabled then return end if button == 'RightButton' and rt.headCells[this.columnIndex].info.isPrice then - g.aux_price_per_unit = not g.aux_price_per_unit + _g.aux_price_per_unit = not _g.aux_price_per_unit for _, cell in rt.headCells do if cell.info.isPrice then - cell:SetText(cell.info.title[g.aux_price_per_unit and 1 or 2]) + cell:SetText(cell.info.title[_g.aux_price_per_unit and 1 or 2]) end end rt:SetSort() @@ -1009,7 +1009,7 @@ function public.CreateAuctionResultsTable(parent, config) rt:SetScript('OnShow', function() for _, cell in this.headCells do if cell.info.isPrice then - cell:SetText(cell.info.title[g.aux_price_per_unit and 1 or 2]) + cell:SetText(cell.info.title[_g.aux_price_per_unit and 1 or 2]) end end end) diff --git a/tables/item_listing.lua b/tables/item_listing.lua index d6a9406..26edeaa 100644 --- a/tables/item_listing.lua +++ b/tables/item_listing.lua @@ -37,21 +37,13 @@ function public.render(item_listing) end function public.create(parent, on_click, selected) - local name = 'g.aux_item_list' - - local id = 1 - while getglobal(name..id) do - id = id + 1 - end - name = name..id - local content = CreateFrame('Frame', nil, parent) content:SetPoint('TOPLEFT', 0, -51) content:SetPoint('BOTTOMRIGHT', -15, 0) - local scroll_frame = CreateFrame('ScrollFrame', name..'ScrollFrame', parent, 'FauxScrollFrameTemplate') + local scroll_frame = CreateFrame('ScrollFrame', gui.name..'ScrollFrame', parent, 'FauxScrollFrameTemplate') scroll_frame:SetScript('OnVerticalScroll', function(self, offset) - FauxScrollFrame_OnVerticalScroll(ROW_HEIGHT, function() m.render(this.item_listing) end) + FauxScrollFrame_OnVerticalScroll(ROW_HEIGHT, function() render(this.item_listing) end) end) scroll_frame:SetPoint('TOPLEFT', content, 'TOPLEFT', 0, 15) scroll_frame:SetPoint('BOTTOMRIGHT', content, 'BOTTOMRIGHT', -4, -15) @@ -60,7 +52,7 @@ function public.create(parent, on_click, selected) scrollBar:SetWidth(12) local thumbTex = scrollBar:GetThumbTexture() thumbTex:SetPoint('CENTER', 0, 0) - thumbTex:SetTexture(unpack(gui.color.content.background)) + thumbTex:SetTexture(gui.color.content.background()) thumbTex:SetHeight(50) thumbTex:SetWidth(12) getglobal(scrollBar:GetName()..'ScrollUpButton'):Hide() @@ -93,9 +85,7 @@ function public.create(parent, on_click, selected) row.item.button:SetScript('OnEnter', function() info.set_tooltip(row.item_record.itemstring, this, 'ANCHOR_RIGHT') end) - row.item.button:SetScript('OnLeave', function() - GameTooltip:Hide() - end) + row.item.button:SetScript('OnLeave', function() GameTooltip:Hide() end) local highlight = row:CreateTexture() highlight:SetAllPoints(row) @@ -120,5 +110,5 @@ end function public.populate(item_listing, item_records) item_listing.item_records = item_records - m.render(item_listing) + render(item_listing) end diff --git a/tabs/auctions/core.lua b/tabs/auctions/core.lua index e82662b..2e59108 100644 --- a/tabs/auctions/core.lua +++ b/tabs/auctions/core.lua @@ -1,5 +1,5 @@ aux.module 'auctions_tab' -g.aux.tab(3, 'Auctions') +aux.tab(3, 'Auctions') auction_records = nil diff --git a/tabs/bids/core.lua b/tabs/bids/core.lua index 5e7645b..1781e3e 100644 --- a/tabs/bids/core.lua +++ b/tabs/bids/core.lua @@ -1,5 +1,5 @@ aux.module 'bids_tab' -g.aux.tab(4, 'Bids') +aux.tab(4, 'Bids') auction_records = nil diff --git a/tabs/post/core.lua b/tabs/post/core.lua index 92d20e0..b7b6d7c 100644 --- a/tabs/post/core.lua +++ b/tabs/post/core.lua @@ -1,5 +1,5 @@ aux.module 'post_tab' -g.aux.tab(2, 'Post') +aux.tab(2, 'Post') 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'}} diff --git a/tabs/search/core.lua b/tabs/search/core.lua index d93a35e..5ac5065 100644 --- a/tabs/search/core.lua +++ b/tabs/search/core.lua @@ -1,5 +1,5 @@ aux.module 'search_tab' -g.aux.tab(1, 'Search') +aux.tab(1, 'Search') StaticPopupDialogs['AUX_SEARCH_TABLE_FULL'] = { text = 'Table full!\nFurther results from this search will still be processed but no longer displayed in the table.', @@ -20,7 +20,7 @@ StaticPopupDialogs['AUX_SEARCH_AUTO_BUY'] = { } do local function action() - g.aux_auto_buy_filter = getglobal(this:GetParent():GetName()..'EditBox'):GetText() + _g.aux_auto_buy_filter = getglobal(this:GetParent():GetName()..'EditBox'):GetText() update_auto_buy_filter() end diff --git a/tabs/search/frames.lua b/tabs/search/frames.lua index df23950..8e0ffd0 100644 --- a/tabs/search/frames.lua +++ b/tabs/search/frames.lua @@ -118,9 +118,9 @@ function create_frames() btn:SetText('Real Time Mode') btn:SetScript('OnClick', function() this:SetChecked(not this:GetChecked()) - g.this = first_page_input + _g.this = first_page_input first_page_input:GetScript('OnTextChanged')() - g.this = last_page_input + _g.this = last_page_input last_page_input:GetScript('OnTextChanged')() end) public.real_time_button = btn @@ -149,7 +149,7 @@ function create_frames() btn:SetScript('OnClick', function() if this:GetChecked() then this:SetChecked(false) - g.aux_auto_buy_filter = nil + _g.aux_auto_buy_filter = nil this.prettified = nil auto_buy_validator = nil else @@ -313,7 +313,7 @@ function create_frames() btn:SetScript('OnClick', function() local filters = filter.queries(search_box:GetText()) if filters then - tinsert(g.aux_favorite_searches, 1, { + tinsert(_g.aux_favorite_searches, 1, { filter_string = search_box:GetText(), prettified = table.concat(map(filters, function(filter) return filter.prettified end), ';'), }) @@ -345,7 +345,7 @@ function create_frames() end do local editbox = gui.editbox(frame.filter) - editbox.complete_item = completion.complete(function() return g.aux_auctionable_items end) + editbox.complete_item = completion.complete(function() return _g.aux_auctionable_items end) editbox:SetPoint('TOPLEFT', 14, -FILTER_SPACING) editbox:SetWidth(260) editbox.char = function() @@ -623,16 +623,16 @@ function create_frames() add_filter(data.search.filter_string) elseif button == 'LeftButton' and IsControlKeyDown() then if st == favorite_searches_listing and data.index > 1 then - local temp = g.aux_favorite_searches[data.index - 1] - g.aux_favorite_searches[data.index - 1] = data.search - g.aux_favorite_searches[data.index] = temp + local temp = _g.aux_favorite_searches[data.index - 1] + _g.aux_favorite_searches[data.index - 1] = data.search + _g.aux_favorite_searches[data.index] = temp update_search_listings() end elseif button == 'RightButton' and IsControlKeyDown() then - if st == favorite_searches_listing and data.index < getn(g.aux_favorite_searches) then - local temp = g.aux_favorite_searches[data.index + 1] - g.aux_favorite_searches[data.index + 1] = data.search - g.aux_favorite_searches[data.index] = temp + if st == favorite_searches_listing and data.index < getn(_g.aux_favorite_searches) then + local temp = _g.aux_favorite_searches[data.index + 1] + _g.aux_favorite_searches[data.index + 1] = data.search + _g.aux_favorite_searches[data.index] = temp update_search_listings() end elseif button == 'LeftButton' then @@ -640,9 +640,9 @@ function create_frames() execute() elseif button == 'RightButton' then if st == recent_searches_listing then - tinsert(g.aux_favorite_searches, 1, data.search) + tinsert(_g.aux_favorite_searches, 1, data.search) elseif st == favorite_searches_listing then - tremove(g.aux_favorite_searches, data.index) + tremove(_g.aux_favorite_searches, data.index) end update_search_listings() end diff --git a/tabs/search/results.lua b/tabs/search/results.lua index c4d3b55..d5ba49d 100644 --- a/tabs/search/results.lua +++ b/tabs/search/results.lua @@ -1,6 +1,6 @@ aux.module 'search_tab' -g.aux_auto_buy_filter = '' +_g.aux_auto_buy_filter = '' search_scan_id = 0 auto_buy_validator = nil @@ -114,8 +114,8 @@ function update_start_stop() end function update_auto_buy_filter() - if g.aux_auto_buy_filter ~= '' then - local queries = filter.queries(g.aux_auto_buy_filter) + if _g.aux_auto_buy_filter ~= '' then + local queries = filter.queries(_g.aux_auto_buy_filter) if queries then if getn(queries) > 1 then log('Error: The automatic buyout filter may contain only one query') @@ -129,7 +129,7 @@ function update_auto_buy_filter() end end end - g.aux_auto_buy_filter = '' + _g.aux_auto_buy_filter = '' end function start_real_time_scan(query, search, continuation) diff --git a/tabs/search/saved.lua b/tabs/search/saved.lua index d72cec7..b73c3a1 100644 --- a/tabs/search/saved.lua +++ b/tabs/search/saved.lua @@ -1,11 +1,11 @@ aux.module 'search_tab' -g.aux_favorite_searches = {} -g.aux_recent_searches = {} +_g.aux_favorite_searches = {} +_g.aux_recent_searches = {} function update_search_listings() local favorite_search_rows = {} - for i, favorite_search in g.aux_favorite_searches do + for i, favorite_search in _g.aux_favorite_searches do local name = strsub(favorite_search.prettified, 1, 250) tinsert(favorite_search_rows, { cols = {{value=name}}, @@ -13,10 +13,10 @@ function update_search_listings() index = i, }) end - m.favorite_searches_listing:SetData(favorite_search_rows) + favorite_searches_listing:SetData(favorite_search_rows) local recent_search_rows = {} - for i, recent_search in g.aux_recent_searches do + for i, recent_search in _g.aux_recent_searches do local name = strsub(recent_search.prettified, 1, 250) tinsert(recent_search_rows, { cols = {{value=name}}, @@ -24,16 +24,16 @@ function update_search_listings() index = i, }) end - m.recent_searches_listing:SetData(recent_search_rows) + recent_searches_listing:SetData(recent_search_rows) end function new_recent_search(filter_string, prettified) - tinsert(g.aux_recent_searches, 1, { + tinsert(_g.aux_recent_searches, 1, { filter_string = filter_string, prettified = prettified, }) - while getn(g.aux_recent_searches) > 50 do - tremove(g.aux_recent_searches) + while getn(_g.aux_recent_searches) > 50 do + tremove(_g.aux_recent_searches) end - m.update_search_listings() + update_search_listings() end \ No newline at end of file diff --git a/util/core.lua b/util/core.lua index f42cab8..a2a6749 100644 --- a/util/core.lua +++ b/util/core.lua @@ -1,6 +1,6 @@ aux.module 'util' -local temp, recycle, getn = g.temp, g.recycle, g.getn +local temp, recycle, getn = temp, recycle, _g.getn function public.copy(t) local copy = {} @@ -9,7 +9,7 @@ function public.copy(t) return copy end -public.join = g.table.concat +public.join = _g.table.concat function public.replicate(count, value) if count > 0 then return value, replicate(count - 1, value) end diff --git a/util/filter.lua b/util/filter.lua index 911c88c..7bdaf51 100644 --- a/util/filter.lua +++ b/util/filter.lua @@ -292,7 +292,7 @@ function public.parse_query_string(str) if input_type ~= '' then if not parts[i + 1] or not parse_parameter(input_type, parts[i + 1]) then if parts[i] == 'item' then - return nil, 'Invalid item name', g.aux_auctionable_items + return nil, 'Invalid item name', _g.aux_auctionable_items elseif type(input_type) == 'table' then return nil, 'Invalid choice for '..parts[i], input_type else @@ -349,18 +349,15 @@ function public.query(query_string) blizzard_query = blizzard_query(components), validator = validator(components), prettified = prettified_query_string(components), - }, m.suggestions(components) + }, _m.suggestions(components) end function public.queries(query_string) local parts = split(query_string, ';') - local queries = {} for _, str in parts do str = trim(str) - local query, _, error = query(str) - if not query then log('Invalid filter:', error) return @@ -368,31 +365,21 @@ function public.queries(query_string) tinsert(queries, query) end end - return queries end function suggestions(components) local suggestions = {} - if components.blizzard.name and size(components.blizzard) == 1 then - tinsert(suggestions, 'exact') - end + if components.blizzard.name and size(components.blizzard) == 1 then tinsert(suggestions, 'exact') end - tinsert(suggestions, 'and') - tinsert(suggestions, 'or') - tinsert(suggestions, 'not') - tinsert(suggestions, 'tt') + tinsert(suggestions, 'and'); tinsert(suggestions, 'or'); tinsert(suggestions, 'not'); tinsert(suggestions, 'tt') - for key in filters do - tinsert(suggestions, key) - end + for key in filters do tinsert(suggestions, key) end -- classes if not components.blizzard.class then - for _, class in {GetAuctionItemClasses()} do - tinsert(suggestions, class) - end + for _, class in {GetAuctionItemClasses()} do tinsert(suggestions, class) end end -- subclasses @@ -410,20 +397,16 @@ function suggestions(components) end -- usable - if not components.blizzard.usable then - tinsert(suggestions, 'usable') - end + if not components.blizzard.usable then tinsert(suggestions, 'usable') end -- rarities if not components.blizzard.quality then - for i=0,4 do - tinsert(suggestions, getglobal('ITEM_QUALITY'..i..'_DESC')) - end + for i=0,4 do tinsert(suggestions, getglobal('ITEM_QUALITY'..i..'_DESC')) end end -- item names if size(components.blizzard) + getn(components.post) == 1 and components.blizzard.name == '' then - for _, name in g.aux_auctionable_items do + for _, name in _g.aux_auctionable_items do tinsert(suggestions, name..'/exact') end end diff --git a/util/info.lua b/util/info.lua index a6f994e..1347c0d 100644 --- a/util/info.lua +++ b/util/info.lua @@ -121,8 +121,8 @@ function public.auction(index, query_type) link = link, itemstring = item_info.itemstring, item_key = item_id..':'..suffix_id, - search_signature = join({item_id, suffix_id, enchant_id, start_price, buyout_price, bid_price, aux_quantity, duration, query_type == 'owner' and high_bidder or (high_bidder and 1 or 0), g.aux_ignore_owner and (is_player(owner) and 0 or 1) or (owner or '?')}, ':'), - sniping_signature = join({item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, g.aux_ignore_owner and (is_player(owner, true) and 0 or 1) or (owner or '?')}, ':'), + search_signature = join({item_id, suffix_id, enchant_id, start_price, buyout_price, bid_price, aux_quantity, duration, query_type == 'owner' and high_bidder or (high_bidder and 1 or 0), _g.aux_ignore_owner and (is_player(owner) and 0 or 1) or (owner or '?')}, ':'), + sniping_signature = join({item_id, suffix_id, enchant_id, start_price, buyout_price, aux_quantity, _g.aux_ignore_owner and (is_player(owner, true) and 0 or 1) or (owner or '?')}, ':'), name = name, texture = texture, @@ -166,7 +166,7 @@ function public.bid_update(auction_record) auction_record.unit_blizzard_bid = auction_record.blizzard_bid / auction_record.aux_quantity auction_record.unit_bid_price = auction_record.bid_price / auction_record.aux_quantity auction_record.high_bidder = 1 - auction_record.search_signature = table.concat({auction_record.item_id, auction_record.suffix_id, auction_record.enchant_id, auction_record.start_price, auction_record.buyout_price, auction_record.bid_price, auction_record.aux_quantity, auction_record.duration, 1, g.aux_ignore_owner and (is_player(auction_record.owner) and 0 or 1) or (auction_record.owner or '?')}, ':') + auction_record.search_signature = table.concat({auction_record.item_id, auction_record.suffix_id, auction_record.enchant_id, auction_record.start_price, auction_record.buyout_price, auction_record.bid_price, auction_record.aux_quantity, auction_record.duration, 1, _g.aux_ignore_owner and (is_player(auction_record.owner) and 0 or 1) or (auction_record.owner or '?')}, ':') end function public.set_tooltip(itemstring, owner, anchor) diff --git a/util/persistence.lua b/util/persistence.lua index f788435..0f08fcd 100644 --- a/util/persistence.lua +++ b/util/persistence.lua @@ -1,6 +1,6 @@ aux.module 'persistence' -g.aux_datasets = {} +_g.aux_datasets = {} do local realm, faction @@ -17,8 +17,8 @@ end function public.load_dataset() local dataset_key = dataset_key - g.aux_datasets[dataset_key] = g.aux_datasets[dataset_key] or {} - return g.aux_datasets[dataset_key] + _g.aux_datasets[dataset_key] = _g.aux_datasets[dataset_key] or {} + return _g.aux_datasets[dataset_key] end function public.read(schema, str)