View Single Post
07/24/19, 06:51 AM   #3
cOOLsp0T
 
cOOLsp0T's Avatar
AddOn Author - Click to view addons
Join Date: Jul 2019
Posts: 17
Code:
function LootManager.ItemFilter(itemnumber,bagID,slotID)
	if bagID == nil or slotID == nil then
		local itemID,name,icon,amount,quality,value,isQuest,stolen = GetLootItemInfo(itemnumber)
		local itemlink = GetLootItemLink(itemID)
		local itemtype = GetItemLinkItemType(itemlink)
		local itemtrait = GetItemLinkTraitType(itemlink)
	end
	if itemnumber == nil then
		local itemlink = GetItemLink(bagID,slotID)
		local itemtype = GetItemType(bagID,slotID)
		local itemtrait = GetItemTrait(bagID,slotID)
		local value = GetItemLinkValue(itemlink)
		local itemfiltertype = GetItemLinkFilterTypeInfo(itemLink)
	end
	
	local notdestroyable = IsItemLinkForcedNotDeconstructable(itemlink)
	
	if itemtype == ITEMTYPE_WEAPON then
		if bagID == nil or slotID == nil then local itemtype2 = GetItemLinkWeaponType(itemlink) end
		if itemnumber == nil then local itemtype2 = GetItemWeaponType(bagID,slotID) end
						--- User Weapon Filter ---
		if itemtype2 == WEAPONTYPE_DAGGER and Config.WeaponFilterSettings.Dagger >= 1 then return true end
		if itemtype2 == WEAPONTYPE_SWORD and Config.WeaponFilterSettings.OHSword >= 1 then return true end
		if itemtype2 == WEAPONTYPE_HAMMER and Config.WeaponFilterSettings.OHHammer >= 1 then return true end
		if itemtype2 == WEAPONTYPE_AXE and Config.WeaponFilterSettings.OHAxe >= 1 then return true end
		if itemtype2 == WEAPONTYPE_SHIELD and Config.WeaponFilterSettings.Shield >= 1 then return true end
		if itemtype2 == WEAPONTYPE_TWO_HANDED_SWORD and Config.WeaponFilterSettings.THSword >= 1 then return true end
		if itemtype2 == WEAPONTYPE_TWO_HANDED_HAMMER and Config.WeaponFilterSettings.THHammer >= 1 then return true end
		if itemtype2 == WEAPONTYPE_TWO_HANDED_AXE and Config.WeaponFilterSettings.THAxe >= 1 then return true end
		if itemtype2 == WEAPONTYPE_BOW and Config.WeaponFilterSettings.Bow >= 1 then return true end
		if itemtype2 == WEAPONTYPE_FIRE_STAFF and Config.WeaponFilterSettings.FireStaff >= 1 then return true end
		if itemtype2 == WEAPONTYPE_FROST_STAFF and Config.WeaponFilterSettings.FrostStaff >= 1 then return true end
		if itemtype2 == WEAPONTYPE_LIGHTNING_STAFF and Config.WeaponFilterSettings.LightningStaff >= 1 then return true end
		if itemtype2 == WEAPONTYPE_HEALING_STAFF and Config.WeaponFilterSettings.HealingStaff >= 1 then return true end
						--- User Loot Ornate & Intricate Weapons ---
		if itemtrait == ITEM_TRAIT_TYPE_WEAPON_ORNATE and Config.GeneralFilterSettings.LootOrnate == true then return true end
		if itemtrait == ITEM_TRAIT_TYPE_WEAPON_INTRICATE then
			if Config.WeaponFilterSettings.MetalWeaponIntricate == true then
				if itemtype2 == WEAPONTYPE_DAGGER then return true end
				if itemtype2 == WEAPONTYPE_SWORD then return true end
				if itemtype2 == WEAPONTYPE_HAMMER then return true end
				if itemtype2 == WEAPONTYPE_AXE then return true end
				if itemtype2 == WEAPONTYPE_TWO_HANDED_SWORD then return true end
				if itemtype2 == WEAPONTYPE_TWO_HANDED_AXE then return true end
				if itemtype2 == WEAPONTYPE_TWO_HANDED_HAMMER then return true end
			end
			if Config.WeaponFilterSettings.WoodenWeaponIntricate == true then
				if itemtype2 == WEAPONTYPE_SHIELD then return true end
				if itemtype2 == WEAPONTYPE_BOW then return true end
				if itemtype2 == WEAPONTYPE_FIRE_STAFF then return true end
				if itemtype2 == WEAPONTYPE_FROST_STAFF then return true end
				if itemtype2 == WEAPONTYPE_LIGHTNING_STAFF then return true end
				if itemtype2 == WEAPONTYPE_HEALING_STAFF then return true end
			end
		end
	end
						--- User Armor Filter ---
	if itemtype == ITEMTYPE_ARMOR then
		if bagID == nil or slotID == nil then local itemtype2 = GetItemLinkArmorType(itemlink) end
		if itemnumber == nil then local itemtype2 = GetItemArmorType(bagID,slotID) end
		if itemtype2 == ARMORTYPE_LIGHT and Config.ArmorFilterSettings.LightArmor >= 1 then return true end
		if itemtype2 == ARMORTYPE_MEDIUM and Config.ArmorFilterSettings.MediumArmor >= 1 then return true end
		if itemtype2 == ARMORTYPE_HEAVY and Config.ArmorFilterSettings.HeavyArmor >= 1 then return true end
		
						--- User Loot Ornate & Intricate Weapons ---
		if itemtrait == ITEM_TRAIT_TYPE_ARMOR_ORNATE and Config.GeneralFilterSettings.LootOrnate == true then return true end
		if itemtrait == ITEM_TRAIT_TYPE_ARMOR_INTRICATE then
			if Config.ArmorFilterSettings.SmithArmorIntricate == true then
				if itemtype2 == ARMORTYPE_HEAVY then return true end
			end
			if Config.ArmorFilterSettings.ClothArmorIntricate == true then
				if itemtype2 == ARMORTYPE_LIGHT then return true end
				if itemtype2 == ARMORTYPE_MEDIUM then return true end
			end
		end	
	end
	
	if Config.MaterialFilterSettings.LootCooking == true then
		if itemtype == ITEMTYPE_FLAVORING then return true end
		if itemtype == ITEMTYPE_INGREDIENT then return true end
		if itemtype == ITEMTYPE_FISH then return true end
		if itemtype == ITEMTYPE_LURE then return true end
		if itemtype == ITEMTYPE_SPICE then return true end
	end
	if Config.MaterialFilterSettings.LootAlchemy == true then
		if itemtype == ITEMTYPE_POISON_BASE then return true end
		if itemtype == ITEMTYPE_POTION_BASE then return true end
		if itemtype == ITEMTYPE_REAGENT then return true end
	end
	if Config.MaterialFilterSettings.LootClothing == true then
		if itemtype == ITEMTYPE_CLOTHIER_RAW_MATERIAL then return true end
		if itemtype == ITEMTYPE_CLOTHIER_MATERIAL then return true end
		if itemtype == ITEMTYPE_CLOTHIER_BOOSTER then return true end
		if itemtype == ITEMTYPE_ARMOR_TRAIT then return true end
		if itemtype == ITEMTYPE_WEAPON_TRAIT then return true end
	end
	if Config.MaterialFilterSettings.LootSmithing == true then
		if itemtype == ITEMTYPE_BLACKSMITHING_RAW_MATERIAL then return true end
		if itemtype == ITEMTYPE_BLACKSMITHING_MATERIAL then return true end
		if itemtype == ITEMTYPE_BLACKSMITHING_BOOSTER then return true end
		if itemtype == ITEMTYPE_ARMOR_TRAIT then return true end
		if itemtype == ITEMTYPE_WEAPON_TRAIT then return true end
	end
	if Config.MaterialFilterSettings.LootWood == true then
		if itemtype == ITEMTYPE_WOODWORKING_RAW_MATERIAL then return true end
		if itemtype == ITEMTYPE_WOODWORKING_MATERIAL then return true end
		if itemtype == ITEMTYPE_WOODWORKING_BOOSTER then return true end
	end

	
	if Config.MaterialFilterSettings.LootRunes == true then
		if itemtype == ITEMTYPE_ENCHANTING_RUNE_ASPECT then return true end
		if itemtype == ITEMTYPE_ENCHANTING_RUNE_ESSENCE then return true end
		if itemtype == ITEMTYPE_ENCHANTING_RUNE_POTENCY then return true end
		if itemtype == ITEMTYPE_ENCHANTING_BOOSTER then return true end
	end
	if Config.MaterialFilterSettings.LootFurnish == true then
		if itemtype == ITEMTYPE_FURNISHING_MATERIAL then return true end
	end
	
	if Config.GeneralFilterSettings.LootSoulGems == true then return true end
--	CanBeResearched = CanItemLinkBeTraitResearched(itemlink)
--	if CanBeResearched == true then
--		d(LootManager.ManagerDebugMark.."Item can be researched!")
--		return true
--	end

	if value >= Config.GeneralFilterSettings.LootValue then
		if itemtype == ITEMTYPE_TRASH then return true end
		if itemtype == ITEMTYPE_TREASURE then return true end
		if itemtype == ITEMTYPE_TROPHY then return true end
		if itemtype == ITEMTYPE_FOOD then return true end
		if itemtype == ITEMTYPE_DRINK then return true end
		if itemtype == ITEMTYPE_TOOL then return true end
		if itemtype == ITEMTYPE_DYE_STAMP then return true end
		if itemtype == ITEMTYPE_DISGUISE then return true end
		if itemtype == ITEMTYPE_COSTUME then return true end
		if itemtype == ITEMTYPE_DEPRECATED then return true end
		if itemtype == ITEMTYPE_NONE then return true end
		if itemtype == ITEMTYPE_PLUG then return true end
		if itemtype == ITEMTYPE_SIEGE then return true end
		if itemtype == ITEMTYPE_SPELLCRAFTING_TABLET then return true end
		if itemtype == ITEMTYPE_MOUNT then return true end
		if itemtype == ITEMTYPE_CONTAINER then return true end
		if itemtype == ITEMTYPE_CONTAINER_CURRENCY then return true end
		if itemtype == ITEMTYPE_AVA_REPAIR then return true end
	end
	return false
end
Code:
function LootManager.LootItemIdentifier(itemnumber)
	local itemID,name,icon,amount,quality,value,isQuest,stolen = GetLootItemInfo(itemnumber)
	local itemlink = GetLootItemLink(itemID)
	local itemtype = GetItemLinkItemType(itemlink)
	local itemtrait = GetItemLinkTraitType(itemlink)
	if itemtype == ITEMTYPE_WEAPON then
		local itemtype = "Weapon"
		local itemtype2 = GetItemLinkWeaponType(itemlink)
		if itemtype2 == WEAPONTYPE_DAGGER then local itemtype2 ="Dagger" end
		if itemtype2 == WEAPONTYPE_SWORD then local itemtype2 ="One-Hand Sword" end
		if itemtype2 == WEAPONTYPE_HAMMER then local itemtype2 ="One-Hand Hammer" end
		if itemtype2 == WEAPONTYPE_AXE then local itemtype2 ="One-Hand Axe" end
		if itemtype2 == WEAPONTYPE_SHIELD then local itemtype2 ="Shield" end
		if itemtype2 == WEAPONTYPE_TWO_HANDED_SWORD then local itemtype2 ="Two-Hand Sword" end
		if itemtype2 == WEAPONTYPE_TWO_HANDED_HAMMER then local itemtype2 ="Two-Hand Hammer" end
		if itemtype2 == WEAPONTYPE_TWO_HANDED_AXE then local itemtype2 ="Two-Hand Axe" end
		if itemtype2 == WEAPONTYPE_BOW then local itemtype2 ="Bow" end
		if itemtype2 == WEAPONTYPE_FIRE_STAFF then local itemtype2 ="Firestaff" end
		if itemtype2 == WEAPONTYPE_FROST_STAFF then local itemtype2 ="Froststaff" end
		if itemtype2 == WEAPONTYPE_LIGHTNING_STAFF then local itemtype2 ="Lightningstaff" end
		if itemtype2 == WEAPONTYPE_HEALING_STAFF then local itemtype2 ="Healingstaff" end
		if itemtrait == ITEM_TRAIT_TYPE_WEAPON_CHARGED then local itemtrait = "Charged" end
		if itemtrait == ITEM_TRAIT_TYPE_WEAPON_DECISIVE then local itemtrait = "Decisive" end
		if itemtrait == ITEM_TRAIT_TYPE_WEAPON_DEFENDING then local itemtrait = "Defending" end
		if itemtrait == ITEM_TRAIT_TYPE_WEAPON_INFUSED then local itemtrait = "Infused" end
		if itemtrait == ITEM_TRAIT_TYPE_WEAPON_NIRNHORNED then local itemtrait = "Nirnhorned" end
		if itemtrait == ITEM_TRAIT_TYPE_WEAPON_POWERED then local itemtrait = "Powered" end
		if itemtrait == ITEM_TRAIT_TYPE_WEAPON_PRECISE then local itemtrait = "Precise" end
		if itemtrait == ITEM_TRAIT_TYPE_WEAPON_SHARPENED then local itemtrait = "Sharpened" end
		if itemtrait == ITEM_TRAIT_TYPE_WEAPON_INTRICATE then local itemtrait = "Intricate" end
		if itemtrait == ITEM_TRAIT_TYPE_WEAPON_ORNATE then local itemtrait = "Ornate" end
	end
	if itemtype == ITEMTYPE_ARMOR then
		local itemtype = "Armor"
		local itemtype2 = GetItemLinkArmorType(itemlink)
		if itemtype2 == ARMORTYPE_LIGHT then local itemtype2 ="Light" end
		if itemtype2 == ARMORTYPE_MEDIUM then local itemtype2 ="Medium" end
		if itemtype2 == ARMORTYPE_HEAVY then local itemtype2 ="Heavy" end
		if itemtrait == ITEM_TRAIT_TYPE_ARMOR_DIVINES then local itemtrait = "Divine" end
		if itemtrait == ITEM_TRAIT_TYPE_ARMOR_REINFORCED then local itemtrait = "Reinforced" end
		if itemtrait == ITEM_TRAIT_TYPE_ARMOR_IMPENETRABLE then local itemtrait = "Impenetrable" end
		if itemtrait == ITEM_TRAIT_TYPE_ARMOR_INFUSED then local itemtrait = "Infused" end
		if itemtrait == ITEM_TRAIT_TYPE_ARMOR_NIRNHONED then local itemtrait = "Nirnhorned" end
		if itemtrait == ITEM_TRAIT_TYPE_ARMOR_PROSPEROUS then local itemtrait = "Prosperous" end
		if itemtrait == ITEM_TRAIT_TYPE_ARMOR_TRAINING then local itemtrait = "Training" end
		if itemtrait == ITEM_TRAIT_TYPE_ARMOR_STURDY then local itemtrait = "Sturdy" end
		if itemtrait == ITEM_TRAIT_TYPE_ARMOR_WELL_FITTED then local itemtrait = "Well Fitted" end
		if itemtrait == ITEM_TRAIT_TYPE_ARMOR_INTRICATE then local itemtrait = "Cloth Intricate" end
		if itemtrait == ITEM_TRAIT_TYPE_ARMOR_INTRICATE then local itemtrait = "Smith Intricate" end
		if itemtrait == ITEM_TRAIT_TYPE_ARMOR_ORNATE then local itemtrait = "Ornate" end
	end
		if itemtype == ITEMTYPE_FLAVORING then local itemtype = "Flavoring" end
		if itemtype == ITEMTYPE_INGREDIENT then local itemtype = "Ingredient" end
		if itemtype == ITEMTYPE_FISH then local itemtype = "Fish" end
		if itemtype == ITEMTYPE_LURE then local itemtype = "Lure" end
		if itemtype == ITEMTYPE_SPICE then local itemtype = "Spice" end
		if itemtype == ITEMTYPE_TRASH then local itemtype = "Trash" end
		if itemtype == ITEMTYPE_TREASURE then local itemtype = "Treasure" end
		if itemtype == ITEMTYPE_TROPHY then local itemtype = "Trophy" end
		if itemtype == ITEMTYPE_FOOD then local itemtype = "Food" end
		if itemtype == ITEMTYPE_DRINK then local itemtype = "Drink" end
		if itemtype == ITEMTYPE_TOOL then local itemtype = "Tool"end
		if itemtype == ITEMTYPE_DYE_STAMP then local itemtype = "Dye Stamp" end
		if itemtype == ITEMTYPE_DISGUISE then local itemtype = "Disguise" end
		if itemtype == ITEMTYPE_COSTUME then local itemtype = "Costume" end
		if itemtype == ITEMTYPE_DEPRECATED then local itemtype = "Deprecated" end
		if itemtype == ITEMTYPE_NONE then local itemtype = "None" end
		if itemtype == ITEMTYPE_PLUG then local itemtype = "Plug" end
		if itemtype == ITEMTYPE_SIEGE then local itemtype = "Siege"end
		if itemtype == ITEMTYPE_SPELLCRAFTING_TABLET then local itemtype = "Spellcrafting Table" end
		if itemtype == ITEMTYPE_MOUNT then local itemtype = "Mount" end
		if itemtype == ITEMTYPE_CONTAINER then local itemtype = "Container" end
		if itemtype == ITEMTYPE_CONTAINER_CURRENCY then local itemtype = "Container Currency" end
		if itemtype == ITEMTYPE_AVA_REPAIR then local itemtype = "Ava Repair"end
		if itemtype == ITEMTYPE_BLACKSMITHING_RAW_MATERIAL then local itemtype = "Blacksmith Raw Material" end
		if itemtype == ITEMTYPE_BLACKSMITHING_MATERIAL then local itemtype = "Blacksmith Material" end
		if itemtype == ITEMTYPE_BLACKSMITHING_BOOSTER then local itemtype = "Blacksmith Booster" end
		if itemtype == ITEMTYPE_ARMOR_TRAIT then local itemtype = "Armor Trait" end
		if itemtype == ITEMTYPE_WEAPON_TRAIT then local itemtype = "Weapon Trait" end
		if itemtype == ITEMTYPE_ENCHANTING_RUNE_ASPECT then local itemtype = "Aspect Rune" end
		if itemtype == ITEMTYPE_ENCHANTING_RUNE_ESSENCE then local itemtype = "Essence Rune" end
		if itemtype == ITEMTYPE_ENCHANTING_RUNE_POTENCY then local itemtype = "Potency Rune" end
		if itemtype == ITEMTYPE_ENCHANTING_BOOSTER then local itemtype = "Enchanting Booster" end
		if itemtype == ITEMTYPE_CLOTHIER_RAW_MATERIAL then local itemtype = "Clothier Raw Material" end
		if itemtype == ITEMTYPE_CLOTHIER_MATERIAL then local itemtype = "Clothier Material" end
		if itemtype == ITEMTYPE_CLOTHIER_BOOSTER then local itemtype = "Clothier Booster" end
		if itemtype == ITEMTYPE_FURNISHING_MATERIAL then local itemtype = "Furnishing Material" end
	return itemID,name,icon,amount,quality,value,isQuest,stolen,itemtype,itemtype2,itemtrait
end
I had a function for debug purpose.

Code:
function LootManager.Debugger(funcID,num,itemnumber,lootitem)
	itemID,name,icon,amount,quality,value,isQuest,stolen,itemtype,itemtype2,itemtrait = LootManager.LootItemIdentifier(itemnumber)
	
	if funcID == 1 and Config.GeneralSettings.Debug == "Virtual" then
		d(LootManager.ManagerDebugMark.."Items Found "..num.." —")
		d("——————————————————————————")
	end
	if funcID == 2 and Config.GeneralSettings.Debug == "Virtual" then
		d(LootManager.ManagerDebugMark.."ID: "..itemID)
		d(LootManager.ManagerDebugMark.."Name: "..name)
		d(LootManager.ManagerDebugMark.."Amount: "..amount)
		d(LootManager.ManagerDebugMark.."Quality: "..quality)
		d(LootManager.ManagerDebugMark.."Gold: "..value)
		d(LootManager.ManagerDebugMark.."Quest: "..tostring(isQuest))
		d(LootManager.ManagerDebugMark.."Stolen: "..tostring(stolen))
		d(LootManager.ManagerDebugMark.."ItemType: "..itemtype)
		if itemtype == "Armor" then d(LootManager.ManagerDebugMark.."ArmorType: "..itemtype2) end
		if itemtype == "Weapon" then d(LootManager.ManagerDebugMark.."WeaponType: "..itemtype2) end
		d(LootManager.ManagerDebugMark.."Trait: "..itemtrait)
		if lootitem == true then d(LootManager.ManagerDebugMark.."Loot this: |c33ff00"..tostring(lootitem)) else d(LootManager.ManagerDebugMark.."Loot this: |cdc1f1f"..tostring(lootitem)) end
		d("——————————————————————————")
	end
	if funcID == 3 and Config.GeneralSettings.Debug ~= "Virtual" then d("GarbageHandler registered") end
	if funcID == 4 and Config.GeneralSettings.Debug ~= "Virtual" then d("GarbageHandler unregistered") end
end
Please tell my if you can see improvements in the code. Sometimes I had the feeling the code can look better.

Last edited by cOOLsp0T : 07/24/19 at 06:56 AM. Reason: Forgot something
  Reply With Quote