Gaming
 

HelpLib.CategoryExists

From WoWWiki

This article is a part of the documentation of the HelpLib function library


Checks if a Category exists

categoryExists = HelpLib.CategoryExists(CategoryName)

Parameters

Arguments

CategoryName
String - Name of the category to check for

Returns

categoryExists
categoryExists 
Boolean - True if the category exists, false otherwise.

Example

 local ChangeColorQuestion={
  q="Can I change the color of my name?",
  a="No, it is not currently possible to change the color of your name",
  hot=true,
  new=false,
  subcat="TasteTheNaimbow",
 }
 local categoryExists=HelpLib.CategoryExists("Cosmos")
 if categoryExists then
   ChangeColorQuestion.cat="Cosmos"
 else
   ChangeColorQuestion.cat="Addons"
 end
 HelpLib.AddQuestion(ChangeColorQuestion)

Result

If the "Cosmos" category exists, the question will be added there. Otherwise, it will be added in the Addons category.

Example

 local ChangeColorQuestion={
  q="Can I change the color of my name?",
  a="No, it is not currently possible to change the color of your name",
  hot=true,
  new=false,
  cat=HelpLib.CategoryExists("Cosmos") and "Cosmos" or "Addons",
  subcat="TasteTheNaimbow",
 }
 HelpLib.AddQuestion(ChangeColorQuestion)

Result

Same as the previous but with less code.