Posted by Myrroddin on Fri, 16 Dec 2011 18:42:35
I have read that sometimes the guild level gets cached, even if a player leaves a guild. To account for this, just in case, I check GetGuildInfo and GetGuildLevel.
function SmartRes2:BindMassRes() -- guild level may be cached, therefore redundant check if _G.GetGuildLevel() <= 24 or not _G.GetGuildInfo("player") then return end _G.SetOverrideBindingClick(self.massResButton, false, self.db.profile.massResKey, "SR2MassResButton") end
The question is if I am checking GetGuildInfo correctly. If you have no guild name, then the first return should be nil. What concerns me is that it may be an empty string, "" instead. Do I have it correct, or should I change the code?
Also, is it safe, or even a good practice, to change GetGuildLevel to simply check < 25? Afterall, a guild level must be 25 to have Mass Resurrection, and you must be in a level 25 guild to use the perk.
Posted by jnwhiteh on Mon, 19 Dec 2011 10:49:09
Regarding the first question, very few (if any) API functions would return a special value like the empty string, you can expect them to return nil if the value doesn't exist. As for the second, it's generally a hard-coded value, but you could instead use the GetSpellInfo API (I think) to check if the player has the Mass Resurrection spell, but I'm not entirely sure!