Hey there! It's me again- Didn't know whether it's best to make a new thread for a new question or not.
I've been having difficulty with getting the remaining time on a buff - I'm probably missing something obvious but all my many google searches keep bringing me to threads with solutions that don't work, but I noticed that these threads are from many years ago and things may have changed since then.
Essentially I just want something to happen when a particular buff has only 1 minute left (or 10 seconds, as i've been using for testing purposes on a shorter buff). I'm aware that expirationTime needs to be used along with GetTime() to convert it to seconds- but the methods that i've tried for doing this haven't worked. I had some luck using this snippet from a much older thread on this forum:
Code:
for i=1,40 do
local name, icon, _, _, _, etime = UnitBuff("player",i)
if name == "Summon Chauffeur" or name == "Ban-Lu, Grandmaster's Companion" then
--do things
end
end
But my attempts to change it to perform a function once the buff is about to run out have failed so many times I thought it best to just ask.
My last try was this: (please excuse my messy/probably wrong code, I'm a beginner at coding but I tried my best!)
Code:
for i=1,40 do
local name, icon, _, _, _, etime = UnitBuff("player",i)
timeleft = etime - GetTime()
if timeleft <= 10 then
print "test"
end
end
Thanks again for your time, i've learned a lot making this.