Adjust afk timer
This commit is contained in:
@@ -1,16 +1,16 @@
|
|||||||
-- TICKER_500
|
-- TICKER_500
|
||||||
function(e)
|
function(e)
|
||||||
local timeToKick = aura_env.KickTime - time()
|
local timeToKick = aura_env.KickTime - time()
|
||||||
if timeToKick > 0 and timeToKick < 5 * 60 then
|
if timeToKick > 0 and timeToKick < 10 * 60 then
|
||||||
WeakAuras.ScanEvents("PLAY_SOUND", "Interface\\Sounds\\quack.ogg")
|
WeakAuras.ScanEvents("PLAY_SOUND", "Interface\\Sounds\\quack.ogg")
|
||||||
-- SendChatMessage("QUACK", "WHISPER", nil, UnitName("player"))
|
-- SendChatMessage("QUACK", "WHISPER", nil, UnitName("player"))
|
||||||
end
|
end
|
||||||
|
|
||||||
local rewardClaimed = WeakAurasSaved.Cyka.LoginInfo[Today][UnitName("player")].claimed
|
local rewardClaimed = WeakAurasSaved.Cyka.LoginInfo[Today][UnitName("player")].claimed
|
||||||
local onlineTime = WeakAurasSaved.Cyka.LoginInfo[Today][UnitName("player")].onlineTimeInMinutes
|
local onlineTime = WeakAurasSaved.Cyka.LoginInfo[Today][UnitName("player")].onlineTimeInMinutes
|
||||||
if rewardClaimed == 0 and onlineTime >= 120 then
|
if rewardClaimed == 0 and onlineTime >= 120 then
|
||||||
WeakAuras.ScanEvents("PLAY_SOUND", "Interface\\Sounds\\quack.ogg")
|
WeakAuras.ScanEvents("PLAY_SOUND", "Interface\\Sounds\\quack.ogg")
|
||||||
end
|
end
|
||||||
|
|
||||||
return aura_env.KickTime > 0
|
return aura_env.KickTime > 0
|
||||||
end
|
end
|
@@ -1,114 +1,114 @@
|
|||||||
if not WeakAurasSaved.Cyka then WeakAurasSaved.Cyka = {} end
|
if not WeakAurasSaved.Cyka then WeakAurasSaved.Cyka = {} end
|
||||||
if not WeakAurasSaved.Cyka.LoginInfo then WeakAurasSaved.Cyka.LoginInfo = {} end
|
if not WeakAurasSaved.Cyka.LoginInfo then WeakAurasSaved.Cyka.LoginInfo = {} end
|
||||||
|
|
||||||
Today = date("%Y-%m-%d")
|
Today = date("%Y-%m-%d")
|
||||||
if not WeakAurasSaved.Cyka.LoginInfo[Today] then WeakAurasSaved.Cyka.LoginInfo[Today] = {} end
|
if not WeakAurasSaved.Cyka.LoginInfo[Today] then WeakAurasSaved.Cyka.LoginInfo[Today] = {} end
|
||||||
if not WeakAurasSaved.Cyka.LoginInfo[Today][UnitName("player")] then
|
if not WeakAurasSaved.Cyka.LoginInfo[Today][UnitName("player")] then
|
||||||
WeakAurasSaved.Cyka.LoginInfo[Today][UnitName("player")] = {
|
WeakAurasSaved.Cyka.LoginInfo[Today][UnitName("player")] = {
|
||||||
onlineTimeInMinutes = 0,
|
onlineTimeInMinutes = 0,
|
||||||
claimed = 0,
|
claimed = 0,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
local greenColor = "|cff00ff00"
|
local greenColor = "|cff00ff00"
|
||||||
local noColor = "|r"
|
local noColor = "|r"
|
||||||
BattlepassAccountInfo = ""
|
BattlepassAccountInfo = ""
|
||||||
local function UpdateAccountInfo()
|
local function UpdateAccountInfo()
|
||||||
local ret = {}
|
local ret = {}
|
||||||
for char, info in pairs(WeakAurasSaved.Cyka.LoginInfo[Today]) do
|
for char, info in pairs(WeakAurasSaved.Cyka.LoginInfo[Today]) do
|
||||||
if info.claimed == 1 then
|
if info.claimed == 1 then
|
||||||
char = string.format("%s%s %d%s", greenColor, char, info.onlineTimeInMinutes, noColor)
|
char = string.format("%s%s %d%s", greenColor, char, info.onlineTimeInMinutes, noColor)
|
||||||
else
|
else
|
||||||
char = string.format("%s %d", char, info.onlineTimeInMinutes)
|
char = string.format("%s %d", char, info.onlineTimeInMinutes)
|
||||||
end
|
end
|
||||||
ret[#ret + 1] = char
|
ret[#ret + 1] = char
|
||||||
end
|
end
|
||||||
BattlepassAccountInfo = table.concat(ret, "\n")
|
BattlepassAccountInfo = table.concat(ret, "\n")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- [02:37 PM] Bluepotato
|
-- [02:37 PM] Bluepotato
|
||||||
-- [02:37 PM] onlineTimeInMinutes=120,
|
-- [02:37 PM] onlineTimeInMinutes=120,
|
||||||
-- [02:37 PM] claimed=1
|
-- [02:37 PM] claimed=1
|
||||||
-- [02:37 PM] Smolpotato
|
-- [02:37 PM] Smolpotato
|
||||||
-- [02:37 PM] onlineTimeInMinutes=120,
|
-- [02:37 PM] onlineTimeInMinutes=120,
|
||||||
-- [02:37 PM] claimed=1
|
-- [02:37 PM] claimed=1
|
||||||
-- [02:37 PM] Thiccpotato
|
-- [02:37 PM] Thiccpotato
|
||||||
-- [02:37 PM] onlineTimeInMinutes=57,
|
-- [02:37 PM] onlineTimeInMinutes=57,
|
||||||
-- [02:37 PM] claimed=0
|
-- [02:37 PM] claimed=0
|
||||||
|
|
||||||
---@param input string
|
---@param input string
|
||||||
---@param deliminer string
|
---@param deliminer string
|
||||||
---@return table<string>
|
---@return table<string>
|
||||||
aura_env.Split = function(input, deliminer)
|
aura_env.Split = function(input, deliminer)
|
||||||
local ret = {}
|
local ret = {}
|
||||||
for str in string.gmatch(input, "([^" .. deliminer .. "]+)") do
|
for str in string.gmatch(input, "([^" .. deliminer .. "]+)") do
|
||||||
table.insert(ret, str)
|
table.insert(ret, str)
|
||||||
end
|
end
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
---@class BattlepassInfo
|
---@class BattlepassInfo
|
||||||
---@field week number
|
---@field week number
|
||||||
---@field getRew number
|
---@field getRew number
|
||||||
---@field dayRewardComplete number
|
---@field dayRewardComplete number
|
||||||
---@field lostDay number
|
---@field lostDay number
|
||||||
---@field cost number
|
---@field cost number
|
||||||
---@field currentDayOnlineTimeMinutes number
|
---@field currentDayOnlineTimeMinutes number
|
||||||
---@field currentDayOnlineTimeMilliseconds number
|
---@field currentDayOnlineTimeMilliseconds number
|
||||||
BattlepassInfo = {
|
BattlepassInfo = {
|
||||||
PingApi = function()
|
PingApi = function()
|
||||||
SendAddonMessage('UIMSG_TO_SERVER', "UIMSG_GET_ONLINETIME_DAY" .. "\t", 'WHISPER', UnitName('player'))
|
SendAddonMessage('UIMSG_TO_SERVER', "UIMSG_GET_ONLINETIME_DAY" .. "\t", 'WHISPER', UnitName('player'))
|
||||||
end,
|
end,
|
||||||
ParseApi = function(msg)
|
ParseApi = function(msg)
|
||||||
local packets = aura_env.Split(msg, ":")
|
local packets = aura_env.Split(msg, ":")
|
||||||
if packets[1] ~= "UISMSG_EVT_WEEK_TIME" then return end
|
if packets[1] ~= "UISMSG_EVT_WEEK_TIME" then return end
|
||||||
|
|
||||||
BattlepassInfo.currentDayOnlineTimeMilliseconds = tonumber(packets[2])
|
BattlepassInfo.currentDayOnlineTimeMilliseconds = tonumber(packets[2])
|
||||||
BattlepassInfo.week = tonumber(packets[3]) + 1
|
BattlepassInfo.week = tonumber(packets[3]) + 1
|
||||||
BattlepassInfo.getRew = tonumber(packets[4])
|
BattlepassInfo.getRew = tonumber(packets[4])
|
||||||
BattlepassInfo.dayRewardComplete = tonumber(packets[5])
|
BattlepassInfo.dayRewardComplete = tonumber(packets[5])
|
||||||
BattlepassInfo.lostDay = tonumber(packets[6])
|
BattlepassInfo.lostDay = tonumber(packets[6])
|
||||||
BattlepassInfo.cost = tonumber(packets[7])
|
BattlepassInfo.cost = tonumber(packets[7])
|
||||||
BattlepassInfo.currentDayOnlineTimeMinutes = math.floor(BattlepassInfo.currentDayOnlineTimeMilliseconds / 60000)
|
BattlepassInfo.currentDayOnlineTimeMinutes = math.floor(BattlepassInfo.currentDayOnlineTimeMilliseconds / 60000)
|
||||||
|
|
||||||
WeakAurasSaved.Cyka.LoginInfo[Today][UnitName("player")].onlineTimeInMinutes = BattlepassInfo
|
WeakAurasSaved.Cyka.LoginInfo[Today][UnitName("player")].onlineTimeInMinutes = BattlepassInfo
|
||||||
.currentDayOnlineTimeMinutes
|
.currentDayOnlineTimeMinutes
|
||||||
WeakAurasSaved.Cyka.LoginInfo[Today][UnitName("player")].claimed = BattlepassInfo.dayRewardComplete
|
WeakAurasSaved.Cyka.LoginInfo[Today][UnitName("player")].claimed = BattlepassInfo.dayRewardComplete
|
||||||
|
|
||||||
if BattlepassInfo.dayRewardComplete == 0 and BattlepassInfo.currentDayOnlineTimeMinutes >= 120 then
|
if BattlepassInfo.dayRewardComplete == 0 and BattlepassInfo.currentDayOnlineTimeMinutes >= 120 then
|
||||||
BattlepassInfo.DoClaim()
|
BattlepassInfo.DoClaim()
|
||||||
C_Timer.After(0.2, function()
|
C_Timer.After(0.2, function()
|
||||||
BattlepassInfo.PingApi()
|
BattlepassInfo.PingApi()
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
UpdateAccountInfo()
|
UpdateAccountInfo()
|
||||||
end,
|
end,
|
||||||
DoClaim = function()
|
DoClaim = function()
|
||||||
SendAddonMessage('UIMSG_TO_SERVER', "UIMSG_WEEKLY_REW_GET" .. "\t", 'WHISPER', UnitName('player'))
|
SendAddonMessage('UIMSG_TO_SERVER', "UIMSG_WEEKLY_REW_GET" .. "\t", 'WHISPER', UnitName('player'))
|
||||||
WeakAuras.ScanEvents("PLAY_SOUND", "Interface\\Sounds\\quack.ogg")
|
WeakAuras.ScanEvents("PLAY_SOUND", "Interface\\Sounds\\quack.ogg")
|
||||||
SendChatMessage("YEEE", "WHISPER", nil, UnitName("player"))
|
SendChatMessage("YEEE", "WHISPER", nil, UnitName("player"))
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
setmetatable(BattlepassInfo, {
|
setmetatable(BattlepassInfo, {
|
||||||
__call = BattlepassInfo.PingApi,
|
__call = BattlepassInfo.PingApi,
|
||||||
__index = BattlepassInfo,
|
__index = BattlepassInfo,
|
||||||
__tostring = function()
|
__tostring = function()
|
||||||
local ret = {}
|
local ret = {}
|
||||||
for k, v in pairs(BattlepassInfo) do
|
for k, v in pairs(BattlepassInfo) do
|
||||||
table.insert(ret, k .. ": " .. tostring(v))
|
table.insert(ret, k .. ": " .. tostring(v))
|
||||||
end
|
end
|
||||||
return table.concat(ret, "\n")
|
return table.concat(ret, "\n")
|
||||||
end
|
end
|
||||||
})
|
})
|
||||||
|
|
||||||
for k, v in pairs(BattlepassInfo) do
|
for k, v in pairs(BattlepassInfo) do
|
||||||
if type(v) == "number" then
|
if type(v) == "number" then
|
||||||
BattlepassInfo[k] = 0
|
BattlepassInfo[k] = 0
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
BattlepassInfo()
|
BattlepassInfo()
|
||||||
|
|
||||||
|
|
||||||
-- Claiming rewards works fine
|
-- Claiming rewards works fine
|
||||||
-- But the bar does not hide once rewards are claimed
|
-- But the bar does not hide once rewards are claimed
|
Reference in New Issue
Block a user