Jump to content
Sign in to follow this  
hdnine

Getting debuffType out of UnitDebuff()?!?

Recommended Posts

Been at it now soooooo long that it's driving me crazy. According to the API you should be able to retrieve the value of debuffType (which could be "Magic, Disease, Poison, Curse, or nothing for those with out a type") but i can't get it to work no matter what i do. >.<

I am trying to write a script that checks what type of debuff i have on me. Any help would be much appreciated.

Share this post


Link to post
Share on other sites

First of all, don't use that wiki. The name is misleading as the site contains information from all kinds of patches (at least up to WotLK). Save yourself some trouble by using http://wow.gamepedia.com/ instead and just click "History" in the top right and go back to around August of 2006 on the sites you're interested in (I know that TBC released in December, but many sites were being updated before that). In contrast to the vanilla-wow wiki, this one was actually trying to be accurate.

 

Regarding your problem:

http://wow.gamepedia.com/index.php?title=API_UnitDebuff&oldid=204497

for i = 1, 16 do
    local debuffTexture, debuffApplications, debuffDispelType = UnitDebuff("player", i);
    if debuffDispelType then
        DEFAULT_CHAT_FRAME:AddMessage(debuffDispelType);
    end
end

This is how you'd use the function.

 

Share this post


Link to post
Share on other sites

OMG you're my hero! Not much of a programmer but i do understand it to some extent. LUA felt a bit strange to me and i got super frustrated when all i got was "interface\icons\" and the spell name. Thanks!

Share this post


Link to post
Share on other sites

It also is common use to not assign names to return values you are not going to use. It would look like this then:

for i = 1, 16 do
    local _, _, debuffDispelType = UnitDebuff("player", i);
    if debuffDispelType then
        DEFAULT_CHAT_FRAME:AddMessage(debuffDispelType);
    end
end

 

Share this post


Link to post
Share on other sites

True, but since I figured he was new to this I wanted to make this as straightforward as possible. If he decides to go the extra mile and learns Lua he will inevitably read these more eccentric details eventually. If he doesn't then there's no reason to confuse him with this stuff as it makes no difference to the outcome.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×