From 87c8cf421e6d511f5ae81effc19cd22aaa19a857 Mon Sep 17 00:00:00 2001 From: gretchen Date: Mon, 8 Jan 2024 22:18:40 +0100 Subject: [PATCH] only share data if not full scan, add off toggle --- aux-addon.lua | 1 + core/history.lua | 16 ++++------------ core/scan.lua | 3 ++- core/slash.lua | 4 ++++ 4 files changed, 11 insertions(+), 13 deletions(-) diff --git a/aux-addon.lua b/aux-addon.lua index 75802f5..05e7e61 100644 --- a/aux-addon.lua +++ b/aux-addon.lua @@ -65,6 +65,7 @@ function handle.LOAD() auctionable_items = {}, merchant_buy = {}, merchant_sell = {}, + sharing = true, }) do local key = format('%s|%s', GetCVar'realmName', UnitName'player') diff --git a/core/history.lua b/core/history.lua index fdef543..cba02d7 100644 --- a/core/history.lua +++ b/core/history.lua @@ -76,7 +76,7 @@ AUXplayerName = UnitName("player") AUX_data_sharer:SetScript("OnEvent", function() - if event == "CHAT_MSG_CHANNEL" then + if event == "CHAT_MSG_CHANNEL" and aux.account_data.sharing == true then local _,_,source = string.find(arg4,"(%d+)%.") if source then _,name = GetChannelName(source) @@ -85,8 +85,6 @@ AUX_data_sharer:SetScript("OnEvent", function() local msg, item_key, munit_buyout_price = AuxAddon_strsplit(",", arg1) --using , as a seperator because item_key contains a : if msg == "AuxData" then if arg2 ~= AUXplayerName then - --print(arg2) - --print(AUXplayerName) local unit_buyout_price = tonumber (munit_buyout_price) --print("received data:" .. msg .. "," .. item_key .. "," .. unit_buyout_price); --for testing (print comes from PFUI) local item_record = read_record(item_key) @@ -101,12 +99,7 @@ AUX_data_sharer:SetScript("OnEvent", function() end end) - local lastMessageTime = 0 - local messageCooldown = 0.01 --time between messages in seconds. Arbitrary value to stop people from getting chat restricted when doing full scans. Could probably be lower but that would lead to so much spam, full scan bad - - function M.process_auction(auction_record) - local currentTime = GetTime() - local elapsedTime = currentTime - lastMessageTime + function M.process_auction(auction_record, pages) local item_record = read_record(auction_record.item_key) local unit_buyout_price = ceil(auction_record.buyout_price / auction_record.aux_quantity) local item_key = auction_record.item_key @@ -114,13 +107,12 @@ AUX_data_sharer:SetScript("OnEvent", function() item_record.daily_min_buyout = unit_buyout_price write_record(auction_record.item_key, item_record) --AuxAddon:SendCommMessage("GUILD", item_key, unit_buyout_price) relies on acecomm - if elapsedTime >= messageCooldown then + if pages < 15 and aux.account_data.sharing == true then if GetChannelName("LFT") ~= 0 then SendChatMessage("AuxData," .. item_key .."," .. unit_buyout_price , "CHANNEL", nil, GetChannelName("LFT")) + --print("sent") end - lastMessageTime = currentTime end - --print("sent/wrote data"); --for testing end end diff --git a/core/scan.lua b/core/scan.lua index f0b8edc..1a1ab1f 100644 --- a/core/scan.lua +++ b/core/scan.lua @@ -138,6 +138,7 @@ function scan_page(i) end end + local pages = last_page(get_state().total_auctions) local auction_info = info.auction(i, get_state().params.type) if auction_info and (auction_info.owner or get_state().params.ignore_owner or aux.account_data.ignore_owner) then auction_info.index = i @@ -145,7 +146,7 @@ function scan_page(i) auction_info.blizzard_query = get_query().blizzard_query auction_info.query_type = get_state().params.type - history.process_auction(auction_info) + history.process_auction(auction_info, pages) if (get_state().params.auto_buy_validator or pass)(auction_info) and auction_info.buyout_price >0 and auction_info.owner ~= UnitName("player") then local send_signal, signal_received = aux.signal() diff --git a/core/slash.lua b/core/slash.lua index a8b5b9b..7f989c8 100644 --- a/core/slash.lua +++ b/core/slash.lua @@ -58,6 +58,9 @@ function SlashCmdList.AUX(command) aux.print('Item cache cleared.') elseif arguments[1] == 'populate' and arguments[2] == 'wdb' then info.populate_wdb() + elseif arguments[1] == 'sharing' then + aux.account_data.sharing = not aux.account_data.sharing + aux.print('sharing ' .. status(aux.account_data.sharing)) else aux.print('Usage:') aux.print('- scale [' .. aux.color.blue(aux.account_data.scale) .. ']') @@ -74,5 +77,6 @@ function SlashCmdList.AUX(command) aux.print('- tooltip disenchant distribution [' .. status(tooltip_settings.disenchant_distribution) .. ']') aux.print('- clear item cache') aux.print('- populate wdb') + aux.print('- sharing [' .. status(aux.account_data.sharing) .. ']') end end \ No newline at end of file