Help with using expirationTime - WoWInterface
Thread Tools Display Modes
Prev Previous Post   Next Post Next
05-04-20, 06:28 PM   #1
A Murloc Raider
Join Date: Feb 2020
Posts: 9
Help with using expirationTime

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:

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
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!)

for i=1,40 do
    local name, icon, _, _, _, etime = UnitBuff("player",i)
    timeleft = etime - GetTime()
    if timeleft <= 10 then
        print "test"
Thanks again for your time, i've learned a lot making this.
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » Help with using expirationTime

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off