Thread Tools Display Modes
03-23-11, 01:50 PM   #1
vivi168
A Murloc Raider
Join Date: Mar 2011
Posts: 5
stun addon help

hello, i'm trying to improve the already existing addon stunbar that normaly only support one spell :

name, rank, icon, count, dispelType, duration, expires, caster, isStealable, shouldConsolidate, spellID = UnitAura("target", "Cheap Shot", nil, "HARMFUL|TARGET")

i did this :

http://codeviewer.org/view/code:189c

but i'm having some problem with line 81

i think those are the bugs : when i cast cheap shot, the stunbar is executed twice or more, when there is already an harmful spell (not necessarily one of the five predefined stuns) on the target, the stunbar doesn't appear.

when it works, it works fine (but that's not very often)

can you help me with detecting the predefined stun spells that are running on the target ?

thanks
  Reply With Quote
03-23-11, 08:52 PM   #2
kraftman
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 63
1. Make sure your functions are local unless they really need to be global, creating a global function called "OnUpdate" is a bad idea.

2. Check out how the function UnitAura actually works: if you give it a spell name, it will tell you whether the spell is on the target or not, if you give it an index it will return the info for that index. In the case of the code you linked, you are always providing an index of 1, so it will query the first buff only, which is why the bar only works when the first buff is the stun.
  Reply With Quote
03-24-11, 06:33 AM   #3
vivi168
A Murloc Raider
Join Date: Mar 2011
Posts: 5
is there a mean to check every debuff on the target, and then check if one of them is among the stun pre-listed ?
  Reply With Quote
03-24-11, 06:46 AM   #4
kraftman
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 63
Originally Posted by vivi168 View Post
is there a mean to check every debuff on the target, and then check if one of them is among the stun pre-listed ?
yup, just do a for loop changing the value of i inside UnitAura each time, for example:

Code:
for i = 1, 16 do
local name = UnitAura("target", i)
if name == "name of buff i want to check" then
--do stuff i want to do
end
end
  Reply With Quote
03-24-11, 12:38 PM   #5
vivi168
A Murloc Raider
Join Date: Mar 2011
Posts: 5
that doesn't work, the bar doesn't appear.
  Reply With Quote
03-24-11, 01:05 PM   #6
kraftman
A Theradrim Guardian
AddOn Author - Click to view addons
Join Date: Dec 2008
Posts: 63
Originally Posted by vivi168 View Post
that doesn't work, the bar doesn't appear.
well it was just an example. can you post your new lua file?
  Reply With Quote
03-24-11, 01:52 PM   #7
vivi168
A Murloc Raider
Join Date: Mar 2011
Posts: 5
there : http://codeviewer.org/view/code:18a5
  Reply With Quote
03-24-11, 02:57 PM   #8
daylesan
A Fallenroot Satyr
Join Date: Feb 2011
Posts: 22
lua Code:
  1. if (expires == nil) then
  2.    sbBarStatus:SetValue(0)
  3.    sbBar:Hide()
  4.  end

If I'm reading this right, the above is why you can't see the bar. The variable expires is nil because, being a local, it doesn't carry over into your OnUpdate function.

Last edited by daylesan : 03-24-11 at 03:08 PM.
  Reply With Quote
03-27-11, 08:30 AM   #9
vivi168
A Murloc Raider
Join Date: Mar 2011
Posts: 5
even if i make expire non local, it's still doesn't work.
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » stun addon help


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