View Single Post
07/24/19, 08:08 AM   #5
Baertram
Super Moderator
 
Baertram's Avatar
WoWInterface Super Mod
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 4,962
If you define a local inside an if end it's ONLY known inside this block.
So if you check the itemtype outside the if end it will be alwas NIL.

About improvements:
Instead of reusing the same if end code several times you can use a table like this:

Lua Code:
  1. local alchemyAllowedItemtypes = {
  2.    [ITEMTYPE_POISON] = true,
  3.   ...
  4. }
  5. local itemtypeIsAllowedForAlchemy = alchemyAllowedItemtypes[itemtype] or false

This will give you a boolean answer true/fals if the itemtype is allowed for your alchemy filter.
Apply the same for others and you can even use your own table with String values as key for your itemInformation function / debug output.

P.S.
If the itemtype2 is the weapontype you should really name your variables like weapontype then instead or you'll confuse yoursef after a few weeks if you read your own code :-p

Last edited by Baertram : 07/24/19 at 08:12 AM.
  Reply With Quote