In this code:
Lua Code:
item_type = GetItemType(bagId,slotId)
if item_type == "ITEMTYPE_ARMOR" then
--...--
GetItemType(bagId,slotId) could return ITEMTYPE_ARMOR if the item is a piece of armor, but ITEMTYPE_ARMOR is actually an integer, so you can't compare it to a string with:
Lua Code:
if item_type == "ITEMTYPE_ARMOR" then
-- that wont work
You might want to change your tables to something like this:
Lua Code:
local junk_types =
{
[ITEMTYPE_ADDITIVE] = true,
[ITEMTYPE_ALCHEMY_BASE] = true,
[ITEMTYPE_AVA_REPAIR] = true,
[ITEMTYPE_CLOTHIER_BOOSTER] = true,
[ITEMTYPE_CLOTHIER_MATERIAL] = true,
[ITEMTYPE_CLOTHIER_RAW_MATERIAL] = true,
[ITEMTYPE_COLLECTIBLE] = true,
[ITEMTYPE_CONTAINER] = true,
[ITEMTYPE_DISGUISE] = true,
[ITEMTYPE_ENCHANTING_RUNE] = true,
[ITEMTYPE_ENCHANTMENT_BOOSTER] = true,
[ITEMTYPE_FLAVORING] = true,
[ITEMTYPE_FOOD] = true,
[ITEMTYPE_GLYPH_ARMOR] = true,
[ITEMTYPE_GLYPH_JEWELRY] = true,
[ITEMTYPE_GLYPH_WEAPON] = true,
[ITEMTYPE_INGREDIENT] = true,
[ITEMTYPE_LURE] = true,
[ITEMTYPE_NONE] = true,
[ITEMTYPE_PLUG] = true,
[ITEMTYPE_RAW_MATERIAL] = true,
[ITEMTYPE_STYLE_MATERIAL] = true,
[ITEMTYPE_TRASH] = true,
}
Since ItemTypes are all unique integers thier keys in the table will be unique. Set each of their values to true or false, based on whether or not the itemType is supposed to be junk.
Then when your trying to determine if something is junk or not you don't need to call an extra contains(...) function. you can just check that table to see if it is true/false (junk or not junk)
Lua Code:
item_type = GetItemType(bagId,slotId)
if junk_types[item_type] then
-- item is junk
end
Oh and so the other part of your code would have to be changed to:
Lua Code:
-- notice, no quotes around ITEMTYPE_ARMOR
if item_type == ITEMTYPE_ARMOR then
local armor_type= GetItemLinkArmorType(item_link)
end