Created
October 14, 2020 03:56
-
-
Save Gethe/8fb2fdd5886aa17dfb5a2702aeb87f04 to your computer and use it in GitHub Desktop.
GetCooldownLeft
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--[[ | |
Returns the true cooldown of an ability or item, correcting for https://github.com/Stanzilla/WoWUIBugs/issues/47 | |
Credit to Eliote and Arkoniel in the WoW Addons discord | |
]] | |
local function GetCooldownLeft(start, duration) | |
if start < GetTime() then | |
local cdEndTime = start + duration | |
local cdLeftDuration = cdEndTime - GetTime() | |
return cdLeftDuration | |
end | |
local time = time() | |
local startupTime = time - GetTime() | |
local cdTime = (2 ^ 32) / 1000 - start | |
local cdStartTime = startupTime - cdTime | |
local cdEndTime = cdStartTime + duration | |
local cdLeftDuration = cdEndTime - time | |
return cdLeftDuration | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment