Quantcast WoWInterface - View Single Post - Check if debuff exists in game
View Single Post
08-19-14, 08:19 AM   #1
MaLarsson
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Aug 2014
Posts: 13
Check if debuff exists in game

As the title says, I need help with error control.
The player types in the name of a debuff and if this debuff exists in the game then store it in the array debuffList. Code example follows:
Lua Code:
  1. local debuffList = {}
  2.  
  3. SLASH_CMD1 = '/cmd'
  4. function SlashCmdList.CMD(msg, editbox)
  5.     local command, rest = msg:match("^(%S*)%s*(.-)$")
  6.     if command == "add" then
  7.         if GetSpellInfo(rest) then -- GetSpellInfo() returns nil (false) if the spell does not exist.
  8.             table.insert(debuffList, rest)
  9.         else
  10.             print("Unknown spell")
  11.         end
  12.     end
  13. end
This code works fine in most cases but when the debuff does not share the same name as the spell this code does not work. For example; there is a debuff called weakened armor but it is applied using the spell sunder armor. If I want to add the debuff weakened armor it tells me that weakened armor is an unknow spell. Is there any way to check if a debuff exists in the game instead of checking if the spell exists in the game?
  Reply With Quote