I'm writing an addon that needs to be able to show/hide specific frames depending on whether or not the player has a certain spell or not. What's the best way of going about this? I've tried PlayerHasSpells("spell"), but it seems to say "true" even if the player does not have that spell.
from the first you can figure out how many tabs you have (should be 4) the second will get you number of spells in each tab (add them all up) and then traverse your spells form 0 to index with the 3rd function. use the last one with the info from the 3rd one to optain the spell link from which you can then extract the spellid which then you dont have to localize the spell to any other language just use the id :)
BTW: the 'not' operator has precedence over the '==' operator. so 'not playerHasStealth == nil' is equivalent to '(not playerHasStealth) == nil'. The 'not' operator itself works on boolean, and return either 'true' or 'false', wich both are different to 'nil'. So basically, 'not something == nil' is always false.
So to sum it up, "if variable then" will do it only if the player has the spell, while "if variable == nil then" will only do it if the player does NOT have the spell, correct?
I would write :
if not playerHasStealth then
instead. The difference is subtle, but you should be aware that the basic API standard that Blizzard is using is to output 'nil' for false value and '1' for true value, but they check it in code using the construct 'if something then' and 'if not something then', so it's possible that they change their API to return true or false instead. Their code would still work but 'if something == nil then' would not.