Compare with Previous | Blame | View Log
--[[ NotBloated.03.02c Kesava, Auchindoun EU --]] -- Initialize -- Change this to false to disable the larger warning -- The number must correspond to another in the warningsDone table local bigWarning = { 5, 5 } -- local bigWarning = { false, false } -- As it says, the times are in minutes. If you want a warning at -- 25 minutes, add this line: -- [25] = false, local warningsDone = { ['big'] = { false, false }, -- In minutes: [120] = { false, false }, [60] = { false, false }, [30] = { false, false }, [15] = { false, false }, [5] = { false, false }, [0] = { false, false } } local Times = { [1] = { ['n'] = 'Wintergrasp' }, [2] = { ['n'] = 'Tol\'Barad' } } local lastSync, lastUpdate = 180, 1 local doBigWarning = false local debug = false local NotBloated = CreateFrame('Frame', 'NotBloated') local function print(msg) DEFAULT_CHAT_FRAME:AddMessage('NotBloated: ' .. msg) end --- Functions --- function NotBloated:OnUpdate(elapsed) lastSync = lastSync + elapsed lastUpdate = lastUpdate + elapsed if lastSync >= 60 then -- Every minute: -- Synchronize the timer with WoW self:Sync() lastSync = 0 end if lastUpdate >= 10 then -- Every ten seconds: -- Increment the timer [and warn the player] self:Update() lastUpdate = 0 end end -- Incrementing timer manually (not fetching from WoW) -- Also calls warnings function NotBloated:Update() -- TODO: should store the runtime (timestamp) on first update -- then here, do `CurrentTime - LastTime` to get time difference -- without messing up on slow systems/minimizing/zoning etc local a, i for i = 1, 2 do a = Times[i] a.waitTime = a.waitTime - 10 if a.waitTime < 0 then -- assume the battle is in progress a['inProgress'] = true return end -- Perform warnings! for warning, done in pairs(warningsDone) do done = done[i] if warning ~= 'big' and (a.waitTime <= (warning + 1) * 60 and not done) then warningsDone[warning][i] = true doWarning = true if bigWarning[i] and not warningsDone.big[i] and bigWarning[i] == warning then -- big warning will only be performed if a normal warning -- is also set to this time doBigWarning = i warningsDone.big[i] = true end end end --doWarning = true --doBigWarning = true if doWarning then self:PrintTime(i) doWarning = false end end end -- Synchronizes the timer with WoW (every minute) function NotBloated:Sync() lastTime = waitTime or 0 newTime = GetWintergraspWaitTime() for i = 1, 2 do Times[i]['lastTime'] = Times[i]['waitTime'] or 0 Times[i]['newTime'] = select(5, GetWorldPVPAreaInfo(i)) Times[i]['oldInProgress'] = Times[i]['inProgress'] Times[i]['inProgress'] = select(3, GetWorldPVPAreaInfo(i)) end _G['NotBloated'] = Times local a, area = nil, '' for i = 1, 2 do a = Times[i] a['waitTime'] = a.newTime if not a.inProgress and a.oldInProgress then -- the battle has ended since the last update self:ResetWarnings() print('The battle for ' .. a.n .. ' has ended.') end end end -- Prints the time remainng/status of the battle function NotBloated:PrintTime(index) local a, seconds, minutes, hours, warnText a = Times[index] if a.inProgress then print('The battle for ' .. a.n .. ' is currently in progress!') return end seconds = a.waitTime % 60 minutes = floor(a.waitTime / 60) % 60 hours = floor(a.waitTime / 60 / 60) if minutes <= 1 and hours == 0 then warnText = 'The battle for ' .. a.n .. ' is about to begin!' print(warnText) self:BigWarning(warnText) return elseif minutes == 0 and hours > 0 then if hours ~= 1 then warnText = hours .. ' hours' else warnText = hours .. ' hour' end elseif hours == 0 and minutes > 1 then warnText = minutes .. ' minutes' else -- cop-out warnText = hours .. 'h ' .. minutes .. 'm' end self:BigWarning(warnText, true) print(warnText .. ' to ' .. a.n) return true end function NotBloated:BigWarning(text, time) if not doBigWarning or not text then return end local a = Times[doBigWarning] if time then text = "The battle for " .. a.n .. " begins in " .. text .. "!" end RaidNotice_AddMessage(RaidBossEmoteFrame, text, ChatTypeInfo["RAID_BOSS_EMOTE"]) PlaySound("RaidBossEmoteWarning") doBigWarning = false end -- I think this resets warnings or something function NotBloated:ResetWarnings() for warning,_ in pairs(warningsDone) do warningsDone[warning] = { false, false } end end --[[ -- Global: function NotBloated_GetTime() if not waitTime then return false end -- Seconds, minutes, hours, raw seconds return waitTime % 60, floor(waitTime / 60) % 60, floor(waitTime / 60 / 60), waitTime end ]] --- Slash commands --- SlashCmdList["NOTBLOATED"] = function(arg) if arg == 'debug on' then print('debug on') debug = true elseif arg == 'debug off' then print('debug off') debug = false else for i = 1, 2 do NotBloated:PrintTime(i) end end end SLASH_NOTBLOATED1 = '/nb' SLASH_NOTBLOATED2 = '/wg' --- Finishing up --- NotBloated:SetScript('OnUpdate', NotBloated.OnUpdate)