Thread Tools Display Modes
02-23-14, 09:41 AM   #1
linalawl
A Murloc Raider
Join Date: Dec 2013
Posts: 9
Looking for help : lua snippet lifebloom timeleft < 5

Hi there!

A few months ago I found here the perfect code for a WA icon, so I try again!

Basically I'm looking for a WA to track my lifebloom. Got one for track if one is active (target / duration / stacks). One if my lifebloom is missing / have less than 3 stacks. But i can't find a way to make an icon showing only when there is less than 5sec left.

TL;DR : looking for a function to return true if my lifebloom is active on any party member and duration <5 sec.

Thanks!
  Reply With Quote
02-23-14, 11:05 AM   #2
Duugu
Premium Member
 
Duugu's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 851
UnitAura("unitid", "Lifebloom") (http://www.wowwiki.com/API_UnitAura)should Returns the following:
name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId

Lua Code:
  1. GetTime() - expirationTime
should give you the remaining time.

Just iterate over the desired units, use UnitAura for lifebloom, test if unitCaster is you and calculate the remaining time.

Last edited by Duugu : 02-23-14 at 11:08 AM.
  Reply With Quote
02-23-14, 12:44 PM   #3
linalawl
A Murloc Raider
Join Date: Dec 2013
Posts: 9
Hi!

Edit : I was using getTime() and not GetTime(), so trying again.

Last edited by linalawl : 02-23-14 at 12:49 PM.
  Reply With Quote
02-23-14, 02:12 PM   #4
linalawl
A Murloc Raider
Join Date: Dec 2013
Posts: 9
It works!

Lua Code:
  1. function()
  2.     local ubase = IsInRaid() and "raid" or "party"
  3.     for i = 1, GetNumGroupMembers() do
  4.         local unit = ubase..i
  5.         local fdv,_,_,_,_,_,expirationTime,unitCaster=UnitAura(unit, "Fleur de vie", nil, "PLAYER|HELPFULL")
  6.         if not fdv then  break
  7.         end
  8.         if ( ((expirationTime - GetTime()) < 5) and (unitCaster=="player")) then return true
  9.         end
  10.     end
  11. end

Am I wrong or UnitAura(unit, "Fleur de vie", nil, "PLAYER|HELPFULL") makes (unitCaster=="player") useless?
  Reply With Quote
02-23-14, 03:51 PM   #5
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
The filter makes checking the caster pointless. You also don't need the 'helpful' filter if you use UnitBuff instead of UnitAura like this..
Lua Code:
  1. UnitBuff(unit, "Fleur de vie", nil, "PLAYER")
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » Looking for help : lua snippet lifebloom timeleft < 5


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