diff --git a/libs/LibItemInfo-1.0/LibItemInfo-1.0.lua b/libs/LibItemInfo-1.0/LibItemInfo-1.0.lua deleted file mode 100644 index 52ef9f9..0000000 --- a/libs/LibItemInfo-1.0/LibItemInfo-1.0.lua +++ /dev/null @@ -1,492 +0,0 @@ - ---Register LAM with LibStub -local MAJOR, MINOR = "LibItemInfo-1.0", 7 -local lii, oldminor = LibStub:NewLibrary(MAJOR, MINOR) -if not lii then return end --the same or newer version of this lib is already loaded into memory - - -local tEquipTypes = { - [ITEMTYPE_ARMOR] = { - --[ARMORTYPE_NONE] = {}, -- jewelry is excluded -- - [ARMORTYPE_LIGHT] = { - ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_CLOTHIER, - [EQUIP_TYPE_CHEST] = 1, - [EQUIP_TYPE_FEET] = 2, - [EQUIP_TYPE_HAND] = 3, - [EQUIP_TYPE_HEAD] = 4, - [EQUIP_TYPE_LEGS] = 5, - [EQUIP_TYPE_SHOULDERS] = 6, - [EQUIP_TYPE_WAIST] = 7, - }, - [ARMORTYPE_MEDIUM] = { - ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_CLOTHIER, - [EQUIP_TYPE_CHEST] = 8, - [EQUIP_TYPE_FEET] = 9, - [EQUIP_TYPE_HAND] = 10, - [EQUIP_TYPE_HEAD] = 11, - [EQUIP_TYPE_LEGS] = 12, - [EQUIP_TYPE_SHOULDERS] = 13, - [EQUIP_TYPE_WAIST] = 14, - }, - [ARMORTYPE_HEAVY] = { - ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_BLACKSMITHING, - [EQUIP_TYPE_CHEST] = 8, - [EQUIP_TYPE_FEET] = 9, - [EQUIP_TYPE_HAND] = 10, - [EQUIP_TYPE_HEAD] = 11, - [EQUIP_TYPE_LEGS] = 12, - [EQUIP_TYPE_SHOULDERS] = 13, - [EQUIP_TYPE_WAIST] = 14, - }, - }, - [ITEMTYPE_WEAPON] = { - [WEAPONTYPE_SHIELD] = { - [EQUIP_TYPE_OFF_HAND] = 6, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_WOODWORKING}, - [WEAPONTYPE_AXE] = { - [EQUIP_TYPE_ONE_HAND] = 1, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_BLACKSMITHING}, - [WEAPONTYPE_DAGGER] = { - [EQUIP_TYPE_ONE_HAND] = 7, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_BLACKSMITHING}, - [WEAPONTYPE_HAMMER] = { - [EQUIP_TYPE_ONE_HAND] = 2, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_BLACKSMITHING}, - [WEAPONTYPE_SWORD] = { - [EQUIP_TYPE_ONE_HAND] = 3, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_BLACKSMITHING}, - [WEAPONTYPE_TWO_HANDED_AXE] = { - [EQUIP_TYPE_TWO_HAND] = 4, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_BLACKSMITHING}, - [WEAPONTYPE_TWO_HANDED_HAMMER] = { - [EQUIP_TYPE_TWO_HAND] = 5, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_BLACKSMITHING}, - [WEAPONTYPE_TWO_HANDED_SWORD] = { - [EQUIP_TYPE_TWO_HAND] = 6, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_BLACKSMITHING}, - [WEAPONTYPE_BOW] = { - [EQUIP_TYPE_TWO_HAND] = 1, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_WOODWORKING}, - [WEAPONTYPE_FIRE_STAFF] = { - [EQUIP_TYPE_TWO_HAND] = 2, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_WOODWORKING}, - [WEAPONTYPE_FROST_STAFF] = { - [EQUIP_TYPE_TWO_HAND] = 3, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_WOODWORKING}, - [WEAPONTYPE_LIGHTNING_STAFF] = { - [EQUIP_TYPE_TWO_HAND] = 4, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_WOODWORKING}, - [WEAPONTYPE_HEALING_STAFF] = { - [EQUIP_TYPE_TWO_HAND] = 5, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_WOODWORKING}, - }, -} - -local tIsTraitResearchable = { - [ITEM_TRAIT_TYPE_ARMOR_DIVINES] = true, - [ITEM_TRAIT_TYPE_ARMOR_EXPLORATION] = true, - [ITEM_TRAIT_TYPE_ARMOR_IMPENETRABLE] = true, - [ITEM_TRAIT_TYPE_ARMOR_INFUSED] = true, - [ITEM_TRAIT_TYPE_ARMOR_INTRICATE] = false, - [ITEM_TRAIT_TYPE_ARMOR_ORNATE] = false, - [ITEM_TRAIT_TYPE_ARMOR_REINFORCED] = true, - [ITEM_TRAIT_TYPE_ARMOR_STURDY] = true, - [ITEM_TRAIT_TYPE_ARMOR_TRAINING] = true, - [ITEM_TRAIT_TYPE_ARMOR_WELL_FITTED] = true, - [ITEM_TRAIT_TYPE_ARMOR_NIRNHONED] = true, - - [ITEM_TRAIT_TYPE_WEAPON_CHARGED] = true, - [ITEM_TRAIT_TYPE_WEAPON_DEFENDING] = true, - [ITEM_TRAIT_TYPE_WEAPON_INFUSED] = true, - [ITEM_TRAIT_TYPE_WEAPON_INTRICATE] = false, - [ITEM_TRAIT_TYPE_WEAPON_ORNATE] = false, - [ITEM_TRAIT_TYPE_WEAPON_POWERED] = true, - [ITEM_TRAIT_TYPE_WEAPON_PRECISE] = true, - [ITEM_TRAIT_TYPE_WEAPON_SHARPENED] = true, - [ITEM_TRAIT_TYPE_WEAPON_TRAINING] = true, - [ITEM_TRAIT_TYPE_WEAPON_WEIGHTED] = true, - [ITEM_TRAIT_TYPE_WEAPON_NIRNHONED] = true, - - [ITEM_TRAIT_TYPE_JEWELRY_ARCANE] = false, - [ITEM_TRAIT_TYPE_JEWELRY_HEALTHY] = false, - [ITEM_TRAIT_TYPE_JEWELRY_ORNATE] = false, - [ITEM_TRAIT_TYPE_JEWELRY_ROBUST] = false, - - [ITEM_TRAIT_TYPE_NONE] = false, -} - --- All functions may depend on lii:GetItemLink to function properly. --- Any other library dependent functions are marked with a preceding comment. - ------------------------------------------------------------------------- --- General Functions -- ------------------------------------------------------------------------- --- Returns an unformatted link of the item -function lii:GetItemLink(_BagIdOrLink, _iSlotId) - if _iSlotId then - return GetItemLink(_BagIdOrLink,_iSlotId) - end - return _BagIdOrLink -end - --- Returns a zo_strformat(..)'d Link -- -function lii:GetFormattedItemLink(_BagIdOrLink, _iSlotId) - if _iSlotId then - return zo_strformat("<<t:1>>", GetItemLink(_BagIdOrLink,_iSlotId)) - end - return zo_strformat("<<t:1>>", _BagIdOrLink) -end - --- Returns the zo_strformat(..)'d ToolTipName of the item -function lii:GetItemToolTipName(_BagIdOrLink, _iSlotId) - if _iSlotId then - return zo_strformat(SI_TOOLTIP_ITEM_NAME, GetItemName(_BagIdOrLink, _iSlotId)) - end - return zo_strformat(SI_TOOLTIP_ITEM_NAME, GetItemLinkName(_BagIdOrLink)) -end - -local function GetMyLinkItemInfo(_lItemLink) - local sIcon, iSellPrice, bMeetsUsageRequirement, iEquipType, iItemStyle = GetItemLinkInfo(_lItemLink) - local iItemQuality = GetItemLinkQuality(_lItemLink) - - return sIcon, iStack, iSellPrice, bMeetsUsageRequirement, bLocked, iEquipType, iItemStyle, iItemQuality -end - --- Same returns as the built in GetItemInfo --- sIcon, iStack, iSellPrice, bMeetsUsageRequirement, bLocked, iEquipType, iItemStyle, iItemQuality --- Links do not have stack sizes or a locked property --- If you pass in a link iStack & bLocked will return nil -function lii:GetItemInfo(_BagIdOrLink, _iSlotId) - if _iSlotId then - return GetItemInfo(_BagIdOrLink, _iSlotId) - end - return GetMyLinkItemInfo(_BagIdOrLink) -end - - - ------------------------------------------------------------------------- --- Item SubType (ArmorType/WeaponType) Info -- ------------------------------------------------------------------------- --- GetSubType is depended on by several functions --- Returns the appropriate ArmorType, WeaponType, --- or 0 if not a piece of Armor or Weapon --- 0 is the same value as WEAPONTYPE_NONE & ARMORTYPE_NONE -function lii:GetSubType(_BagIdOrLink, _iSlotId) - local lLink = self:GetItemLink(_BagIdOrLink, _iSlotId) - local iItemType = GetItemLinkItemType(lLink) - - if iItemType == ITEMTYPE_ARMOR then - return GetItemLinkArmorType(lLink) - elseif iItemType == ITEMTYPE_WEAPON then - return GetItemLinkWeaponType(lLink) - end - -- 0 is the same return as WEAPONTYPE_NONE & ARMORTYPE_NONE - return 0 -end - - - ------------------------------------------------------------------------- --- ItemType Group Properties -- ------------------------------------------------------------------------- --- Returns: True/False if the item is jewelry -function lii:IsJewelry(_BagIdOrLink, _iSlotId) - local lLink = self:GetItemLink(_BagIdOrLink, _iSlotId) - local iItemType = GetItemLinkItemType(lLink) - - if iItemType == ITEMTYPE_ARMOR then - local iArmorType = GetItemLinkArmorType(lLink) - if iArmorType == ARMORTYPE_NONE then - return true - end - end - return false -end - --- Returns true/false if the item is a one handed weapon -function lii:IsWeaponOneHanded(_BagIdOrLink, _iSlotId) - local lLink = self:GetItemLink(_BagIdOrLink, _iSlotId) - local iItemType = GetItemLinkItemType(lLink) - local iEquipType = GetItemLinkEquipType(lLink) - - if ((iItemType == ITEMTYPE_WEAPON) and (iEquipType == EQUIP_TYPE_ONE_HAND)) then - return true - end - return false -end - --- Returns true/false if the item is a two handed weapon -function lii:IsWeaponTwoHanded(_BagIdOrLink, _iSlotId) - local lLink = self:GetItemLink(_BagIdOrLink, _iSlotId) - local iItemType = GetItemLinkItemType(lLink) - local iEquipType = GetItemLinkEquipType(lLink) - - if ((iItemType == ITEMTYPE_WEAPON) and (iEquipType == EQUIP_TYPE_TWO_HAND)) then - return true - end - return false -end - --- Returns true/false if the item is a crafting mat -function lii:IsCrafingMaterial(_BagIdOrLink, _iSlotId) - local lLink = self:GetItemLink(_BagIdOrLink, _iSlotId) - - if GetItemLinkCraftingSkillType(lLink) ~= CRAFTING_TYPE_INVALID then - return true - end - return false -end - --- returns true/false if the item is a glyph -function lii:IsGlyph(_BagIdOrLink, _iSlotId) - local lLink = self:GetItemLink(_BagIdOrLink, _iSlotId) - local iItemType = GetItemLinkItemType(lLink) - - if ((iItemType == ITEMTYPE_GLYPH_ARMOR) or (iItemType == ITEMTYPE_GLYPH_WEAPON) - or (iItemType == ITEMTYPE_GLYPH_JEWELRY)) then - return true - end - return false -end - - - ------------------------------------------------------------------------- --- Crafting Info Functions -- ------------------------------------------------------------------------- --- Returns a zo_strFormat(..)'d name for the CraftingSkillType in the games current language or CRAFTING_TYPE_INVALID --- In English it returns: --- CRAFTING_TYPE_ALCHEMY returns "Alchemy" --- CRAFTING_TYPE_BLACKSMITHING returns "Blacksmithing" --- CRAFTING_TYPE_CLOTHIER returns "Clothing" --- CRAFTING_TYPE_ENCHANTING returns "Enchanting" --- CRAFTING_TYPE_INVALID returns CRAFTING_TYPE_INVALID (NOT a formatted string, which is 0) --- CRAFTING_TYPE_PROVISIONING returns "Provisioning" --- CRAFTING_TYPE_WOODWORKING returns "Woodworking" -function lii:GetCraftingSkillTypeLabelName(_iCraftingSkillType) --- Returns Name of Crafting Skill Type. Used for labelling things -- - -- 0 is CRAFTING_TYPE_INVALID & there are only 6 consecutively numbered crafting skill types -- - if ((_iCraftingSkillType > 0) and (_iCraftingSkillType < 7)) then - local SkillType, skillIndex = GetCraftingSkillLineIndices(_iCraftingSkillType) - local name, rank = GetSkillLineInfo(SkillType, skillIndex) - return zo_strformat(SI_TOOLTIP_ITEM_NAME, name) - end - return CRAFTING_TYPE_INVALID -end - --- Dependence on lii:GetSubType & IsResearchableItemType --- Possible Returns: CRAFTING_TYPE_CLOTHIER, CRAFTING_TYPE_BLACKSMITHING, CRAFTING_TYPE_WOODWORKING, or CRAFTING_TYPE_INVALID --- Returns: the CraftingSkillType of an item IF it is a researchable ItemType --- Returns: CRAFTING_TYPE_INVALID if it is not a researchable ItemType -function lii:GetResearchableCraftingSkillType(_BagIdOrLink, _iSlotId) - if not self:IsResearchableItemType(_BagIdOrLink, _iSlotId) then return CRAFTING_TYPE_INVALID end - - local lLink = self:GetItemLink(_BagIdOrLink, _iSlotId) - local iSubType = self:GetSubType(_BagIdOrLink, _iSlotId) - local iItemType = GetItemLinkItemType(lLink) - - return tEquipTypes[iItemType][iSubType]["CRAFTINGSKILLTYPE"] -end - --- Dependecy on: GetResearchableCraftingSkillType(...) --- RETURNS: the items corresponding crafting skill type or CRAFTING_TYPE_INVALID --- This is for fully created items like actual armor/weapon, food, drink, potions --- DOES NOT WORK ON CRAFTING MATERIALS, if you want that info just use the built in --- API function: GetItemLinkCraftingSkillType(string ItemLink) --- ** NOTE: just because it returns a CraftingSkillType does not mean it is a crafted, it may have been looted or bought. -function lii:GetItemCraftingSkillType(_BagIdOrLink, _iSlotId) - local lLink = self:GetItemLink(_BagIdOrLink, _iSlotId) - local iItemType = GetItemLinkItemType(lLink) - - local allowedReturnTypes = { - [ITEMTYPE_FOOD] = CRAFTING_TYPE_PROVISIONING, - [ITEMTYPE_DRINK] = CRAFTING_TYPE_PROVISIONING, - [ITEMTYPE_POTION] = CRAFTING_TYPE_ALCHEMY, - [ITEMTYPE_GLYPH_ARMOR] = CRAFTING_TYPE_ENCHANTING, - [ITEMTYPE_GLYPH_WEAPON] = CRAFTING_TYPE_ENCHANTING, - [ITEMTYPE_GLYPH_JEWELRY] = CRAFTING_TYPE_ENCHANTING, - [ITEMTYPE_ENCHANTING_RUNE_ASPECT] = CRAFTING_TYPE_ENCHANTING, - [ITEMTYPE_ENCHANTING_RUNE_ESSENCE] = CRAFTING_TYPE_ENCHANTING, - [ITEMTYPE_ENCHANTING_RUNE_POTENCY] = CRAFTING_TYPE_ENCHANTING, - } - - local iCraftingSkillType = allowedReturnTypes[iItemType] - - if iCraftingSkillType then - return iCraftingSkillType - end - - return self:GetResearchableCraftingSkillType(_BagIdOrLink, _iSlotId) -end - - - ------------------------------------------------------------------------- --- Research Specific Functions -- ------------------------------------------------------------------------- --- Dependence on IsResearchableItem, GetResearchLineIndex, GetTraitIndex, GetResearchableCraftingSkillType --- Returns: bool IsResearchableItem, integer CraftingSkillType, Integer ResearchLineIndex, integer TraitIndex --- IsResearchableItem: Returns: True if itemType is researchable AND has a researchable trait on it, But that does not mean it is an unknown trait -- --- CraftingSkillType: Returns the CraftingSkillType of an item IF it is a researchable ItemType or CRAFTING_TYPE_INVALID (item does not have to have a trait on it to return a CraftingSkillType) --- GetResearchLineIndex: Returns the ResearchLineIndex for an item if it is a researchable ItemType Or returns CRAFTING_TYPE_INVALID (item does not have to have a trait on it to return a ResearchLineIndex) -- --- TraitIndex: Returns the TraitIndex of the trait on the item or CRAFTING_TYPE_INVALID (Armor/Weapon Trait Stones will return a TraitIndex) -function lii:GetResearchInfo(_BagIdOrLink, _iSlotId) - local bIsResearchableItem = self:IsResearchableItem(_BagIdOrLink, _iSlotId) - local iCraftingSkillType = self:GetResearchableCraftingSkillType(_BagIdOrLink, _iSlotId) - local iResearchLineIndex = self:GetResearchLineIndex(_BagIdOrLink, _iSlotId) - local iTraitIndex = self:GetTraitIndex(_BagIdOrLink, _iSlotId) - - return bIsResearchableItem, iCraftingSkillType, iResearchLineIndex, iTraitIndex -end - --- Dependence on lii:GetSubType --- Returns: True if the ItemType is Armor or Weapon and the subtype is handled (in the equipTypes table) -function lii:IsResearchableItemType(_BagIdOrLink, _iSlotId) - local lLink = self:GetItemLink(_BagIdOrLink, _iSlotId) - local iItemType = GetItemLinkItemType(lLink) - if ((iItemType ~= ITEMTYPE_ARMOR) and (iItemType ~= ITEMTYPE_WEAPON)) then return false end - - local iSubType = self:GetSubType(lLink) - - if tEquipTypes[iItemType][iSubType] then - return true - end - return false -end - --- Dependence on lii:GetSubType & IsResearchableItemType --- Returns: True if itemType is researchable AND has a researchable trait on it -- --- That does not mean it is an unknown trait -- --- Make sure you note the distinction between this & HasResearchableTrait, they are not the same -- -function lii:IsResearchableItem(_BagIdOrLink, _iSlotId) - if not self:IsResearchableItemType(_BagIdOrLink, _iSlotId) then return false end - local lLink = self:GetItemLink(_BagIdOrLink, _iSlotId) - - return tIsTraitResearchable[GetItemLinkTraitInfo(lLink)] -end - --- Dependence on GetResearchInfo --- Returns: True or False --- True if the item is a researchable ItemType, it has a researchable trait --- on it that is unknown, and that trait is not currently being researched -function lii:NeedForResearch(_BagIdOrLink, _iSlotId) - local bIsResearchableItem, iCraftingSkillType, iResearchLineIndex, iTraitIndex = self:GetResearchInfo(_BagIdOrLink, _iSlotId) - local _, _, bIsTraitKnown = GetSmithingResearchLineTraitInfo(iCraftingSkillType, iResearchLineIndex, iTraitIndex) - - if (bIsResearchableItem and (not bIsTraitKnown) and - (GetSmithingResearchLineTraitTimes(iCraftingSkillType, iResearchLineIndex, iTraitIndex) == nil)) then - return true - end - return false -end - --- Dependence on lii:GetSubType & IsResearchableItemType --- Possible Returns: The Items ResearchLine Index or CRAFTING_TYPE_INVALID --- Returns: The ResearchLineIndex for an item if it is a researchable ItemType --- This does not mean it has a trait on it. --- Returns: CRAFTING_TYPE_INVALID if the item is not a Researchable ItemType -function lii:GetResearchLineIndex(_BagIdOrLink, _iSlotId) - if not self:IsResearchableItemType(_BagIdOrLink, _iSlotId) then return CRAFTING_TYPE_INVALID end - - local lLink = self:GetItemLink(_BagIdOrLink, _iSlotId) - local iSubType = self:GetSubType(_BagIdOrLink, _iSlotId) - local iItemType = GetItemLinkItemType(lLink) - local iEquipType = GetItemLinkEquipType(lLink) - - return tEquipTypes[iItemType][iSubType][iEquipType] -end - - - ------------------------------------------------------------------------- --- Item Trait Specific Functions -- ------------------------------------------------------------------------- --- Returns: the TraitIndex of the trait on an item or CRAFTING_TYPE_INVALID --- Does not mean the ItemType is researchable (Armor/Weapon Trait Stones will return a TraitIndex) -function lii:GetTraitIndex(_BagIdOrLink, _iSlotId) - local lLink = self:GetItemLink(_BagIdOrLink, _iSlotId) - local iTraitType = GetItemLinkTraitInfo(lLink) - if not tIsTraitResearchable[iTraitType] then return CRAFTING_TYPE_INVALID end - - if ((iTraitType == ITEM_TRAIT_TYPE_WEAPON_NIRNHONED) - or (iTraitType == ITEM_TRAIT_TYPE_ARMOR_NIRNHONED)) then - return 9 - end - return (iTraitType % 10) -end - --- Dependence on GetResearchInfo --- Returns true if the item is researchable and has a known researchable trait -function lii:HasKnownTrait(_BagIdOrLink, _iSlotId) - local bIsResearchableItem, iCraftingSkillType, iResearchLineIndex, iTraitIndex = self:GetResearchInfo(_BagIdOrLink, _iSlotId) - local _, _, bHasKnownTrait = GetSmithingResearchLineTraitInfo(iCraftingSkillType, iResearchLineIndex, iTraitIndex) - - return bHasKnownTrait -end - --- Dependence on GetResearchInfo --- Returns true/false if the item is researchable and has an unknown researchable trait -function lii:HasUnKnownTrait(_BagIdOrLink, _iSlotId) - local bIsResearchableItem, iCraftingSkillType, iResearchLineIndex, iTraitIndex = self:GetResearchInfo(_BagIdOrLink, _iSlotId) - - if bIsResearchableItem then - local _, _, bIsKnown = GetSmithingResearchLineTraitInfo(iCraftingSkillType, iResearchLineIndex, iTraitIndex) - return not bIsKnown - end - return false -end - --- Returns true/false if the item has a researchable trait --- This does not mean the trait is unknown to you or that it is --- a researchable ItemType only that it is one of the researchable --- TraitTypes (Armor/Weapon Trait Stones will return true) --- Make sure you note the distinction between this & IsResearchableItem, they are not the same -- -function lii:HasResearchableTrait(_BagIdOrLink, _iSlotId) - local lLink = self:GetItemLink(_BagIdOrLink, _iSlotId) - return tIsTraitResearchable[GetItemLinkTraitInfo(lLink)] -end - --- Dependence on GetResearchInfo --- If the TraitType on the item is currently being researched --- Returns: True, TotalResearchTime, timeLeftInSeconds --- If the TraitType on the item is not currently being researched --- Returns: False, nil, nil -function lii:IsItemTraitBeingResearched(_BagIdOrLink, _iSlotId) - local bIsResearchableItem, iCraftingSkillType, iResearchLineIndex, iTraitIndex = self:GetResearchInfo(_BagIdOrLink, _iSlotId) - local iTotalResearchTime, iTimeLeftInSecs = GetSmithingResearchLineTraitTimes(iCraftingSkillType, iResearchLineIndex, iTraitIndex) - - if iTotalResearchTime then - return true, iTotalResearchTime, iTimeLeftInSecs - end - return false -end - - - ------------------------------------------------------------------------- --- Recipe Functions -- ------------------------------------------------------------------------- - --- Returns: bool IsKnownRecipe, string (ToolTipFormatted)RecipeName, integer RecipeListIndex, integer RecipeIndex --- Returns: false, nil, nil, nil if the recipe is unknown or if the item is not a recipe --- Returns: true, (ToolTipFormatted)RecipeName, RecipeListIndex, RecipeIndex if the recipe is known -function lii:GetRecipeInfo(_BagIdOrLink, _iSlotId) - local lLink = self:GetItemLink(_BagIdOrLink, _iSlotId) - local iItemType = GetItemLinkItemType(lLink) - if iItemType ~= ITEMTYPE_RECIPE then return false end - - local lRecipeResultItemLink = GetItemLinkRecipeResultItemLink(lLink) - local iNumRecipeLists = GetNumRecipeLists() - - for iRecipeListIndex = 1, iNumRecipeLists do - local _, iNumRecipes = GetRecipeListInfo(iRecipeListIndex) - - for iRecipeIndex = 1, iNumRecipes do - local sRecipeResultIndexLink = GetRecipeResultItemLink(iRecipeListIndex,iRecipeIndex) - if lRecipeResultItemLink == sRecipeResultIndexLink then - local _,sRecipeName = GetRecipeInfo(iRecipeListIndex,iRecipeIndex) - local sFormattedRecipeName = zo_strformat(SI_TOOLTIP_ITEM_NAME, sRecipeName) - - return true, sFormattedRecipeName, iRecipeListIndex, iRecipeIndex - end - end - end - return false -end - - - - - - - - - diff --git a/libs/LibItemInfo-1.0/LibItemInfo-1.0.txt b/libs/LibItemInfo-1.0/LibItemInfo-1.0.txt deleted file mode 100644 index ade03a4..0000000 --- a/libs/LibItemInfo-1.0/LibItemInfo-1.0.txt +++ /dev/null @@ -1,10 +0,0 @@ -## APIVersion: 100009 -## Title: LibItemInfo-1.0 -## Version: 1.0 r7 -## Author: Circonian -## Description: A library used to aid in gathering item information. - - -LibStub\LibStub.lua - -LibItemInfo-1.0.lua diff --git a/libs/LibMsgWin-1.0/LibMsgWin-1.0.lua b/libs/LibMsgWin-1.0/LibMsgWin-1.0.lua deleted file mode 100644 index 4d80f63..0000000 --- a/libs/LibMsgWin-1.0/LibMsgWin-1.0.lua +++ /dev/null @@ -1,236 +0,0 @@ - ---Register LAM with LibStub -local MAJOR, MINOR = "LibMsgWin-1.0", 8 -local libmw, oldminor = LibStub:NewLibrary(MAJOR, MINOR) -if not libmw then return end --the same or newer version of this lib is already loaded into memory - - -local function AdjustSlider(self) - local numHistoryLines = self:GetNamedChild("Buffer"):GetNumHistoryLines() - local numVisHistoryLines = self:GetNamedChild("Buffer"):GetNumVisibleLines() - local bufferScrollPos = self:GetNamedChild("Buffer"):GetScrollPosition() - local sliderMin, sliderMax = self:GetNamedChild("Slider"):GetMinMax() - local sliderValue = self:GetNamedChild("Slider"):GetValue() - - self:GetNamedChild("Slider"):SetMinMax(0, numHistoryLines) - - -- If the sliders at the bottom, stay at the bottom to show new text - if sliderValue == sliderMax then - self:GetNamedChild("Slider"):SetValue(numHistoryLines) - -- If the buffer is full start moving the slider up - elseif numHistoryLines == self:GetNamedChild("Buffer"):GetMaxHistoryLines() then - self:GetNamedChild("Slider"):SetValue(sliderValue-1) - end -- Else the slider does not move - - -- If there are more history lines than visible lines show the slider - if numHistoryLines > numVisHistoryLines then - self:GetNamedChild("Slider"):SetHidden(false) - else - -- else hide the slider - self:GetNamedChild("Slider"):SetHidden(true) - end -end - -function libmw:CreateMsgWindow(_UniqueName, _LabelText, _FadeDelay, _FadeTime) - -- Dimension Constraits - local minWidth = 200 - local minHeight = 150 - - local tlw = WINDOW_MANAGER:CreateTopLevelWindow(_UniqueName) - tlw:SetMouseEnabled(true) - tlw:SetMovable(true) - tlw:SetHidden(false) - tlw:SetClampedToScreen(true) - tlw:SetDimensions(350, 400) - tlw:SetClampedToScreenInsets(-24) - tlw:SetAnchor(TOPLEFT, GuiRoot, TOPLEFT, 50,50) - tlw:SetDimensionConstraints(minWidth, minHeight) - tlw:SetResizeHandleSize(16) - - -- Set Fade Delay/Times - tlw.fadeDelayWindow = _FadeDelay or 0 - tlw.fadeTimeWindow = _FadeTime or 0 - tlw.fadeDelayTextLines = tlw.fadeDelayWindow/1000 - tlw.fadeTimeTextLines = tlw.fadeTimeWindow/1000 - - -- Create window fade timeline/animation - tlw.timeline = ANIMATION_MANAGER:CreateTimeline() - tlw.animation = tlw.timeline:InsertAnimation(ANIMATION_ALPHA, tlw, tlw.fadeDelayWindow) - tlw.animation:SetAlphaValues(1, 0) - tlw.animation:SetDuration(tlw.fadeTimeWindow) - tlw.timeline:PlayFromStart() - - - function tlw:AddText(_Message, _Red, _Green, _Blue) - local Red = _Red or 1 - local Green = _Green or 1 - local Blue = _Blue or 1 - - if not _Message then return end - -- Add message first - self:GetNamedChild("Buffer"):AddMessage(_Message, Red, Green, Blue) - -- Set new slider value & check visibility - AdjustSlider(self) - -- Reset Fade Timers - tlw:SetAlpha(1) - tlw.timeline:PlayFromStart() - end - function tlw:ChangeWinFade(_FadeDelay, _FadeTime) - if not (type(_FadeDelay) == "number" and type(_FadeTime) == "number") then return end - tlw.fadeDelayWindow = _FadeDelay - tlw.fadeTimeWindow = _FadeTime - - tlw.timeline:SetAnimationOffset(tlw.animation, _FadeDelay) - tlw.animation:SetDuration(_FadeTime) - end - function tlw:ChangeTextFade(_FadeDelay, _FadeTime) - if not (type(_FadeDelay) == "number" and type(_FadeTime) == "number") then return end - tlw.fadeDelayTextLines = _FadeDelay/1000 - tlw.fadeTimeTextLines = _FadeTime/1000 - self:GetNamedChild("Buffer"):SetLineFade(_FadeDelay/1000, _FadeTime/1000) - end - function tlw:ClearText() - self:GetNamedChild("Buffer"):Clear() - end - - local bg = WINDOW_MANAGER:CreateControl(_UniqueName.."Bg", tlw, CT_BACKDROP) - bg:SetAnchor(TOPLEFT, tlw, TOPLEFT, -8, -6) - bg:SetAnchor(BOTTOMRIGHT, tlw, BOTTOMRIGHT, 4, 4) - bg:SetEdgeTexture("EsoUI/Art/ChatWindow/chat_BG_edge.dds", 256, 256, 32) - bg:SetCenterTexture("EsoUI/Art/ChatWindow/chat_BG_center.dds") - bg:SetInsets(32, 32, -32, -32) - bg:SetDimensionConstraints(minWidth, minHeight) - - - local divider = WINDOW_MANAGER:CreateControl(_UniqueName.."Divider", tlw, CT_TEXTURE) - divider:SetDimensions(4, 8) - divider:SetAnchor(TOPLEFT, tlw, TOPLEFT, 20, 40) - divider:SetAnchor(TOPRIGHT, tlw, TOPRIGHT, -20, 40) - divider:SetTexture("EsoUI/Art/Miscellaneous/horizontalDivider.dds") - divider:SetTextureCoords(0.181640625, 0.818359375, 0, 1) - - - local buffer = WINDOW_MANAGER:CreateControl(_UniqueName.."Buffer", tlw, CT_TEXTBUFFER) - buffer:SetFont("ZoFontChat") - buffer:SetMaxHistoryLines(200) - buffer:SetMouseEnabled(true) - buffer:SetLinkEnabled(true) - buffer:SetAnchor(TOPLEFT, tlw, TOPLEFT, 20, 42) - buffer:SetAnchor(BOTTOMRIGHT, tlw, BOTTOMRIGHT, -35, -20) - buffer:SetLineFade(tlw.fadeDelayTextLines, tlw.fadeTimeTextLines) - buffer:SetHandler("OnLinkMouseUp", function(self, linkText, link, button) - -- ZO_PopupTooltip_SetLink(link) - ZO_LinkHandler_OnLinkMouseUp(link, button, self) - end) - ---[[ - buffer:SetHandler("OnMouseUp", function(self, linkText, link, button, temp1, temp2, temp3, temp4) - d("self: "..tostring(self:GetName())) - d("linkText: "..tostring(linkText)) - d("link: "..tostring(link)) - d("button: "..tostring(button)) - d("temp1: "..tostring(temp1)) - d("temp2: "..tostring(temp2)) - d("temp3: "..tostring(temp3)) - d("temp4: "..tostring(temp4)) - end) - - - --]] - - buffer:SetDimensionConstraints(minWidth-55, minHeight-62) - - buffer:SetHandler("OnMouseWheel", function(self, delta, ctrl, alt, shift) - local offset = delta - local slider = buffer:GetParent():GetNamedChild("Slider") - if shift then - offset = offset * buffer:GetNumVisibleLines() - elseif ctrl then - offset = offset * buffer:GetNumHistoryLines() - end - buffer:SetScrollPosition(buffer:GetScrollPosition() + offset) - slider:SetValue(slider:GetValue() - offset) - end) - - buffer:SetHandler("OnMouseEnter", function(...) - tlw.timeline:Stop() - buffer:SetLineFade(0, 0) - buffer:ShowFadedLines() - tlw:SetAlpha(1) - end) - buffer:SetHandler("OnMouseExit", function(...) - buffer:SetLineFade(tlw.fadeDelayTextLines, tlw.fadeTimeTextLines) - tlw.timeline:PlayFromStart() - end) - - local slider = WINDOW_MANAGER:CreateControl(_UniqueName.."Slider", tlw, CT_SLIDER) - slider:SetDimensions(15, 32) - slider:SetAnchor(TOPRIGHT, tlw, TOPRIGHT, -25, 60) - slider:SetAnchor(BOTTOMRIGHT, tlw, BOTTOMRIGHT, -15, -80) - slider:SetMinMax(1, 1) - slider:SetMouseEnabled(true) - slider:SetValueStep(1) - slider:SetValue(1) - slider:SetHidden(true) - slider:SetThumbTexture("EsoUI/Art/ChatWindow/chat_thumb.dds", "EsoUI/Art/ChatWindow/chat_thumb_disabled.dds", nil, 8, 22, nil, nil, 0.6875, nil) - slider:SetBackgroundMiddleTexture("EsoUI/Art/ChatWindow/chat_scrollbar_track.dds") - - slider:SetHandler("OnValueChanged", function(self,value, eventReason) - local numHistoryLines = self:GetParent():GetNamedChild("Buffer"):GetNumHistoryLines() - local sliderValue = slider:GetValue() - - if eventReason == EVENT_REASON_HARDWARE then - buffer:SetScrollPosition(numHistoryLines-sliderValue) - end - end) - - - local scrollUp = WINDOW_MANAGER:CreateControlFromVirtual(_UniqueName.."SliderScrollUp", slider, "ZO_ScrollUpButton") - scrollUp:SetAnchor(BOTTOM, slider, TOP, -1, 0) - scrollUp:SetNormalTexture("EsoUI/Art/ChatWindow/chat_scrollbar_upArrow_up.dds") - scrollUp:SetPressedTexture("EsoUI/Art/ChatWindow/chat_scrollbar_upArrow_down.dds") - scrollUp:SetMouseOverTexture("EsoUI/Art/ChatWindow/chat_scrollbar_upArrow_over.dds") - scrollUp:SetDisabledTexture("EsoUI/Art/ChatWindow/chat_scrollbar_upArrow_disabled.dds") - scrollUp:SetHandler("OnMouseDown", function(...) - buffer:SetScrollPosition(buffer:GetScrollPosition()+1) - slider:SetValue(slider:GetValue()-1) - end) - - - local scrollDown = WINDOW_MANAGER:CreateControlFromVirtual(_UniqueName.."SliderScrollDown", slider, "ZO_ScrollDownButton") - scrollDown:SetAnchor(TOP, slider, BOTTOM, -1, 0) - scrollDown:SetNormalTexture("EsoUI/Art/ChatWindow/chat_scrollbar_downArrow_up.dds") - scrollDown:SetPressedTexture("EsoUI/Art/ChatWindow/chat_scrollbar_downArrow_down.dds") - scrollDown:SetMouseOverTexture("EsoUI/Art/ChatWindow/chat_scrollbar_downArrow_over.dds") - scrollDown:SetDisabledTexture("EsoUI/Art/ChatWindow/chat_scrollbar_downArrow_disabled.dds") - scrollDown:SetHandler("OnMouseDown", function(...) - buffer:SetScrollPosition(buffer:GetScrollPosition()-1) - slider:SetValue(slider:GetValue()+1) - end) - - - local scrollEnd = WINDOW_MANAGER:CreateControlFromVirtual(_UniqueName.."SliderScrollEnd", slider, "ZO_ScrollEndButton") - scrollEnd:SetDimensions(16, 16) - scrollEnd:SetAnchor(TOP, scrollDown, BOTTOM, 0, 0) - scrollEnd:SetHandler("OnMouseDown", function(...) - buffer:SetScrollPosition(0) - slider:SetValue(buffer:GetNumHistoryLines()) - end) - - if _LabelText and _LabelText ~= "" then - local label = WINDOW_MANAGER:CreateControl(_UniqueName.."Label", tlw, CT_LABEL) - label:SetText(_LabelText) - label:SetFont("$(ANTIQUE_FONT)|24") - label:SetWrapMode(TEXT_WRAP_MODE_ELLIPSIS) - local textHeight = label:GetTextHeight() - label:SetDimensionConstraints(minWidth-60, textHeight, nil, textHeight) - label:ClearAnchors() - label:SetAnchor(TOPLEFT, tlw, TOPLEFT, 30, (40-textHeight)/2+5) - label:SetAnchor(TOPRIGHT, tlw, TOPRIGHT, -30, (40-textHeight)/2+5) - end - return tlw -end - - - - - diff --git a/libs/LibMsgWin-1.0/LibMsgWin-1.0.txt b/libs/LibMsgWin-1.0/LibMsgWin-1.0.txt deleted file mode 100644 index a13abe6..0000000 --- a/libs/LibMsgWin-1.0/LibMsgWin-1.0.txt +++ /dev/null @@ -1,10 +0,0 @@ -## APIVersion: 100010 -## Title: LibMsgWin-1.0 -## Version: 1.0 r3 -## Author: Circonian -## Description: A library used to aid in creating message windows - - -LibStub\LibStub.lua - -LibMsgWin-1.0.lua diff --git a/libs/LibNeed4Research/LibNeed4Research.lua b/libs/LibNeed4Research/LibNeed4Research.lua deleted file mode 100644 index 9bb9685..0000000 --- a/libs/LibNeed4Research/LibNeed4Research.lua +++ /dev/null @@ -1,427 +0,0 @@ - - ----[[ ---Register LAM with LibStub -local MAJOR, MINOR = "LibNeed4Research", 5 -local ln4r, oldminor = LibStub:NewLibrary(MAJOR, MINOR) -if not ln4r then return end --the same or newer version of this lib is already loaded into memory ---]] - -local ASV -local LIBNEED4RESEARCHVARVERSION = 2 -- DO NOT CHANGE - -local varDefaults = { - KnownTraitTable = {}, - KnownRecipeTable = {}, - PlayerNames = {}, -} - -local tIsTraitResearchable = { - [ITEM_TRAIT_TYPE_ARMOR_DIVINES] = true, - [ITEM_TRAIT_TYPE_ARMOR_EXPLORATION] = true, - [ITEM_TRAIT_TYPE_ARMOR_IMPENETRABLE] = true, - [ITEM_TRAIT_TYPE_ARMOR_INFUSED] = true, - [ITEM_TRAIT_TYPE_ARMOR_INTRICATE] = false, - [ITEM_TRAIT_TYPE_ARMOR_ORNATE] = false, - [ITEM_TRAIT_TYPE_ARMOR_REINFORCED] = true, - [ITEM_TRAIT_TYPE_ARMOR_STURDY] = true, - [ITEM_TRAIT_TYPE_ARMOR_TRAINING] = true, - [ITEM_TRAIT_TYPE_ARMOR_WELL_FITTED] = true, - [ITEM_TRAIT_TYPE_ARMOR_NIRNHONED] = true, - - [ITEM_TRAIT_TYPE_WEAPON_CHARGED] = true, - [ITEM_TRAIT_TYPE_WEAPON_DEFENDING] = true, - [ITEM_TRAIT_TYPE_WEAPON_INFUSED] = true, - [ITEM_TRAIT_TYPE_WEAPON_INTRICATE] = false, - [ITEM_TRAIT_TYPE_WEAPON_ORNATE] = false, - [ITEM_TRAIT_TYPE_WEAPON_POWERED] = true, - [ITEM_TRAIT_TYPE_WEAPON_PRECISE] = true, - [ITEM_TRAIT_TYPE_WEAPON_SHARPENED] = true, - [ITEM_TRAIT_TYPE_WEAPON_TRAINING] = true, - [ITEM_TRAIT_TYPE_WEAPON_WEIGHTED] = true, - [ITEM_TRAIT_TYPE_WEAPON_NIRNHONED] = true, - - [ITEM_TRAIT_TYPE_JEWELRY_ARCANE] = false, - [ITEM_TRAIT_TYPE_JEWELRY_HEALTHY] = false, - [ITEM_TRAIT_TYPE_JEWELRY_ORNATE] = false, - [ITEM_TRAIT_TYPE_JEWELRY_ROBUST] = false, - - [ITEM_TRAIT_TYPE_NONE] = false, -} - --- Used to find the crafting type & research Index for items -local tEquipTypes = { - [ITEMTYPE_ARMOR] = { - --[ARMORTYPE_NONE] = {}, -- jewelry is excluded -- - [ARMORTYPE_LIGHT] = { - ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_CLOTHIER, - [EQUIP_TYPE_CHEST] = 1, - [EQUIP_TYPE_FEET] = 2, - [EQUIP_TYPE_HAND] = 3, - [EQUIP_TYPE_HEAD] = 4, - [EQUIP_TYPE_LEGS] = 5, - [EQUIP_TYPE_SHOULDERS] = 6, - [EQUIP_TYPE_WAIST] = 7, - }, - [ARMORTYPE_MEDIUM] = { - ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_CLOTHIER, - [EQUIP_TYPE_CHEST] = 8, - [EQUIP_TYPE_FEET] = 9, - [EQUIP_TYPE_HAND] = 10, - [EQUIP_TYPE_HEAD] = 11, - [EQUIP_TYPE_LEGS] = 12, - [EQUIP_TYPE_SHOULDERS] = 13, - [EQUIP_TYPE_WAIST] = 14, - }, - [ARMORTYPE_HEAVY] = { - ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_BLACKSMITHING, - [EQUIP_TYPE_CHEST] = 8, - [EQUIP_TYPE_FEET] = 9, - [EQUIP_TYPE_HAND] = 10, - [EQUIP_TYPE_HEAD] = 11, - [EQUIP_TYPE_LEGS] = 12, - [EQUIP_TYPE_SHOULDERS] = 13, - [EQUIP_TYPE_WAIST] = 14, - }, - }, - [ITEMTYPE_WEAPON] = { - [WEAPONTYPE_SHIELD] = { - [EQUIP_TYPE_OFF_HAND] = 6, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_WOODWORKING}, - [WEAPONTYPE_AXE] = { - [EQUIP_TYPE_ONE_HAND] = 1, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_BLACKSMITHING}, - [WEAPONTYPE_DAGGER] = { - [EQUIP_TYPE_ONE_HAND] = 7, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_BLACKSMITHING}, - [WEAPONTYPE_HAMMER] = { - [EQUIP_TYPE_ONE_HAND] = 2, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_BLACKSMITHING}, - [WEAPONTYPE_SWORD] = { - [EQUIP_TYPE_ONE_HAND] = 3, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_BLACKSMITHING}, - [WEAPONTYPE_TWO_HANDED_AXE] = { - [EQUIP_TYPE_TWO_HAND] = 4, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_BLACKSMITHING}, - [WEAPONTYPE_TWO_HANDED_HAMMER] = { - [EQUIP_TYPE_TWO_HAND] = 5, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_BLACKSMITHING}, - [WEAPONTYPE_TWO_HANDED_SWORD] = { - [EQUIP_TYPE_TWO_HAND] = 6, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_BLACKSMITHING}, - [WEAPONTYPE_BOW] = { - [EQUIP_TYPE_TWO_HAND] = 1, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_WOODWORKING}, - [WEAPONTYPE_FIRE_STAFF] = { - [EQUIP_TYPE_TWO_HAND] = 2, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_WOODWORKING}, - [WEAPONTYPE_FROST_STAFF] = { - [EQUIP_TYPE_TWO_HAND] = 3, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_WOODWORKING}, - [WEAPONTYPE_LIGHTNING_STAFF] = { - [EQUIP_TYPE_TWO_HAND] = 4, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_WOODWORKING}, - [WEAPONTYPE_HEALING_STAFF] = { - [EQUIP_TYPE_TWO_HAND] = 5, ["CRAFTINGSKILLTYPE"] = CRAFTING_TYPE_WOODWORKING}, - }, -} - - ------------------------------------------------------------------------- --- Get Trait Index -- ------------------------------------------------------------------------- -local function GetTraitIndex(_BagIdOrLink, _iSlotId) - local lLink = _BagIdOrLink - if _iSlotId then - lLink = GetItemLink(_BagIdOrLink,_iSlotId) - end - local iTraitType = GetItemLinkTraitInfo(lLink) - if not tIsTraitResearchable[iTraitType] then return end - - if ((iTraitType == ITEM_TRAIT_TYPE_WEAPON_NIRNHONED) - or (iTraitType == ITEM_TRAIT_TYPE_ARMOR_NIRNHONED)) then - return 9 - end - return (iTraitType % 10) -end - -local function GetResearchInfo(_BagIdOrLink, _iSlotId) - local lLink = _BagIdOrLink - if _iSlotId then - lLink = GetItemLink(_BagIdOrLink, _iSlotId) - end - - local iTraitType = GetItemLinkTraitInfo(lLink) - if not tIsTraitResearchable[iTraitType] then return end - - local iItemType = GetItemLinkItemType(lLink) - local iSubType = 0 -- 0 is the same return as WEAPONTYPE_NONE & ARMORTYPE_NONE - - if iItemType == ITEMTYPE_ARMOR then - iSubType = GetItemLinkArmorType(lLink) - elseif iItemType == ITEMTYPE_WEAPON then - iSubType = GetItemLinkWeaponType(lLink) - else - return - end - - if not (tEquipTypes[iItemType] and tEquipTypes[iItemType][iSubType]) then return end - - local iEquipType = GetItemLinkEquipType(lLink) - local iCraftingSkillType = tEquipTypes[iItemType][iSubType]["CRAFTINGSKILLTYPE"] - local iResearchLineIndex = tEquipTypes[iItemType][iSubType][iEquipType] - local iTraitIndex = GetTraitIndex(_BagIdOrLink, _iSlotId) - - return iCraftingSkillType, iResearchLineIndex, iTraitIndex -end - ---[[ -ZO_CraftingUtils_IsTraitAppliedToWeapons(traitType) -ZO_CraftingUtils_IsTraitAppliedToArmor(traitType) ---]] - -local function IsTraitNeeded(_sPlayerName, _iCraftingSkillType, _iResearchLineIndex, _iTraitIndex) - --[[ checks to make sure were not getting called to early by an addon, before the libraries saved vars have loaded. Even though this is local, this is called from a function they can access. - --]] - if not (ASV and ASV.KnownTraitTable and ASV.KnownTraitTable[_sPlayerName]) then return true end - if not ASV.KnownTraitTable[_sPlayerName][_iCraftingSkillType] then return true end - if not ASV.KnownTraitTable[_sPlayerName][_iCraftingSkillType][_iResearchLineIndex] then return true end - - if ASV.KnownTraitTable[_sPlayerName][_iCraftingSkillType][_iResearchLineIndex][_iTraitIndex] then - return false - end - return true -end - -function ln4r:DoesPlayerNeedTrait(_sPlayerName, _iBagIdOrLink, _iSlotId) - local iCraftingSkillType, iResearchLineIndex, iTraitIndex = GetResearchInfo(_iBagIdOrLink, _iSlotId) - - -- Its either not a researchable ItemType or doesn't have a researchable trait - if not (iCraftingSkillType and iResearchLineIndex and iTraitIndex) then return false end - - if IsTraitNeeded(_sPlayerName, iCraftingSkillType, iResearchLineIndex, iTraitIndex) then - return true, iCraftingSkillType, iResearchLineIndex, iTraitIndex - end - return false -end - -function ln4r:DoAnyPlayersNeedTrait(_iBagIdOrLink, _iSlotId) - local iCraftingSkillType, iResearchLineIndex, iTraitIndex = GetResearchInfo(_iBagIdOrLink, _iSlotId) - - -- Its either not a researchable ItemType or doesn't have a researchable trait - if not (iCraftingSkillType and iResearchLineIndex and iTraitIndex) then return end - - --[[ check to make sure were not getting called to early by an addon, before the libraries saved vars have loaded. Default to true, player needs, so nothing bad happens to the item. - --]] - if not (ASV and ASV.PlayerNames) then return end - - local sCurrentPlayerName = GetUnitName("player") - - local tPlayersThatNeed = { - CraftingSkillType = iCraftingSkillType, - ResearchLineIndex = iResearchLineIndex, - TraitIndex = iTraitIndex, - PlayerCount = 0, - PlayerNames = {}, - PlayerNeeds = false, - OtherNeeds = false, - } - - for sPlayerName,v in pairs(ASV.PlayerNames) do - if IsTraitNeeded(sPlayerName, iCraftingSkillType, iResearchLineIndex, iTraitIndex) then - tPlayersThatNeed.PlayerCount = tPlayersThatNeed.PlayerCount + 1 - - if sPlayerName == sCurrentPlayerName then - tPlayersThatNeed.PlayerNeeds = true - else - tPlayersThatNeed.OtherNeeds = true - end - tPlayersThatNeed.PlayerNames[sPlayerName] = true - end - end - if tPlayersThatNeed.PlayerCount > 0 then - return tPlayersThatNeed - end -end ---[[ -function ln4r:GetRecipeIndices(_iBagIdOrLink, _iSlotId) - local lLink = _iBagIdOrLink - if _iSlotId then - lLink = GetItemLink(_iBagIdOrLink, _iSlotId) - end - - local iItemType = GetItemLinkItemType(lLink) - if iItemType ~= ITEMTYPE_RECIPE then return end - - local lRecipeResultItemLink = GetItemLinkRecipeResultItemLink(lLink) - local iNumRecipeLists = GetNumRecipeLists() - - for iRecipeListIndex = 1, iNumRecipeLists do - local _, iNumRecipes = GetRecipeListInfo(iRecipeListIndex) - for iRecipeIndex = 1, iNumRecipes do - local lRecipeResultTableLink = GetRecipeResultItemLink(iRecipeListIndex, iRecipeIndex) - if lRecipeResultItemLink == lRecipeResultTableLink then - return iRecipeListIndex, iRecipeIndex, lRecipeResultItemLink - end - end - end -end ---]] -function ln4r:DoesPlayerNeedRecipe(_sPlayerName, _iBagIdOrLink, _iSlotId) - --[[ check to make sure were not getting called to early by an addon, before the libraries saved vars have loaded. --]] - if not (ASV and ASV.KnownRecipeTable and ASV.KnownRecipeTable[_sPlayerName]) then return end - - local lLink = _iBagIdOrLink - if _iSlotId then - lLink = GetItemLink(_iBagIdOrLink, _iSlotId) - end - - local iItemType = GetItemLinkItemType(lLink) - if iItemType ~= ITEMTYPE_RECIPE then return false end - - local lRecipeResultItemLink = GetItemLinkRecipeResultItemLink(lLink) - local sItemId = select(4,ZO_LinkHandler_ParseLink(lRecipeResultItemLink)) - local iItemId = tonumber(sItemId) - - if type(iItemId) == "number" and ASV.KnownRecipeTable[_sPlayerName][iItemId] then - return false - end - return true -end - -function ln4r:DoAnyPlayersNeedRecipe(_iBagIdOrLink, _iSlotId) - local lLink = _iBagIdOrLink - if _iSlotId then - lLink = GetItemLink(_iBagIdOrLink, _iSlotId) - end - - local iItemType = GetItemLinkItemType(lLink) - if iItemType ~= ITEMTYPE_RECIPE then return end - -- check to make sure were not getting called to early by an addon, before the libraries saved - -- vars have loaded. - if not (ASV and ASV.PlayerNames) then return end - - local sCurrentPlayerName = GetUnitName("player") - - local tPlayersThatNeed = { - CraftingSkillType = CRAFTING_TYPE_PROVISIONING, - PlayerCount = 0, - PlayerNames = {}, - PlayerNeeds = false, - OtherNeeds = false, - } - for sPlayerName,v in pairs(ASV.PlayerNames) do - local bPlayerNeedsRecipe = ln4r:DoesPlayerNeedRecipe(sPlayerName, _iBagIdOrLink, _iSlotId) - if bPlayerNeedsRecipe then - tPlayersThatNeed.PlayerCount = tPlayersThatNeed.PlayerCount + 1 - - if sPlayerName == sCurrentPlayerName then - tPlayersThatNeed.PlayerNeeds = true - else - tPlayersThatNeed.OtherNeeds = true - end - tPlayersThatNeed.PlayerNames[sPlayerName] = true - end - end - if tPlayersThatNeed.PlayerCount > 0 then - return tPlayersThatNeed - end -end - - -local function AddKnownTrait(_EventCode, _iCraftingSkillType, _iResearchLineIndex, _iTraitIndex) - if _iCraftingSkillType == CRAFTING_TYPE_INVALID then return end - local sPlayerName = GetUnitName("player") - - if not ASV.KnownTraitTable[sPlayerName][_iCraftingSkillType][_iResearchLineIndex] then - ASV.KnownTraitTable[sPlayerName][_iCraftingSkillType][_iResearchLineIndex] = {} - end - - local iTraitType = GetSmithingResearchLineTraitInfo(_iCraftingSkillType, _iResearchLineIndex, _iTraitIndex) - - if iTraitType ~= ITEM_TRAIT_TYPE_NONE then - ASV.KnownTraitTable[sPlayerName][_iCraftingSkillType][_iResearchLineIndex][_iTraitIndex] = true - end -end - -local function AddKnownRecipe(_EventCode, _iRecipeListIndex, _iRecipeIndex) - local sPlayerName = GetUnitName("player") - local lRecipeResultItemLink = GetRecipeResultItemLink(_iRecipeListIndex, _iRecipeIndex) - local sItemId = select(4,ZO_LinkHandler_ParseLink(lRecipeResultItemLink)) - local iItemId = tonumber(sItemId) - - if type(iItemId) == "number" then - ASV.KnownRecipeTable[sPlayerName][iItemId] = true - end -end - -local function UpdateUnKnownRecipes() - for iRecipeListIndex = 1, GetNumRecipeLists() do - local sRecipeListName, iNumRecipes = GetRecipeListInfo(iRecipeListIndex) - for iRecipeIndex = 1, iNumRecipes do - local bIsKnown, sRecipeName = GetRecipeInfo(iRecipeListIndex, iRecipeIndex) - if bIsKnown then - AddKnownRecipe(nil, iRecipeListIndex, iRecipeIndex) - end - end - end -end - -local function UpdateCraftingSkillTraits(_iCraftingSkillType) - for iResearchLineIndex = 1, GetNumSmithingResearchLines(_iCraftingSkillType) do - local _,_, iNumTraits = GetSmithingResearchLineInfo(_iCraftingSkillType, iResearchLineIndex) - for iTraitIndex = 1, iNumTraits do - local iTraitType, _, bIsKnown = GetSmithingResearchLineTraitInfo(_iCraftingSkillType, iResearchLineIndex, iTraitIndex) - -- if its not known, check to see if we are researching it -- - if bIsKnown or GetSmithingResearchLineTraitTimes(_iCraftingSkillType, iResearchLineIndex, iTraitIndex) ~= nil then - AddKnownTrait(nil, _iCraftingSkillType, iResearchLineIndex, iTraitIndex) - end - end - end -end -local function UpdateUnKnownTraits() - UpdateCraftingSkillTraits(CRAFTING_TYPE_BLACKSMITHING) - UpdateCraftingSkillTraits(CRAFTING_TYPE_CLOTHIER) - UpdateCraftingSkillTraits(CRAFTING_TYPE_WOODWORKING) -end - ---------------------------------------------------------------------------------- ----- Update Tables ---- --- Called during initialization() -- ---------------------------------------------------------------------------------- -local function UpdateTables() - local sPlayerName = GetUnitName("player") - - if not ASV.KnownTraitTable[sPlayerName] then - ASV.KnownTraitTable[sPlayerName] = { - [CRAFTING_TYPE_BLACKSMITHING] = {}, - [CRAFTING_TYPE_CLOTHIER] = {}, - [CRAFTING_TYPE_WOODWORKING] = {}, - } - end - if not ASV.KnownRecipeTable[sPlayerName] then - ASV.KnownRecipeTable[sPlayerName] = {} - end - if not ASV.PlayerNames[sPlayerName] then - ASV.PlayerNames[sPlayerName] = true - end - - UpdateUnKnownTraits() - UpdateUnKnownRecipes() -end - -local function OnAddOnLoaded(_event, _sAddonName) - if _sAddonName == "ZO_Ingame" then - ln4r:Initialize() - end -end -function ln4r:Initialize() - ln4r.AccountSavedVariables = ZO_SavedVars:NewAccountWide("ZO_Ingame_SavedVariables", LIBNEED4RESEARCHVARVERSION, "LibNeed4ResearchVars", varDefaults) - - ASV = ln4r.AccountSavedVariables - --Need4Research = ln4r.AccountSavedVariables - UpdateTables() - - -- register for events - EVENT_MANAGER:RegisterForEvent("LibNeed4Research", EVENT_SMITHING_TRAIT_RESEARCH_STARTED, AddKnownTrait) - EVENT_MANAGER:RegisterForEvent("LibNeed4Research", EVENT_RECIPE_LEARNED, AddKnownRecipe) - - -- Unregister events - EVENT_MANAGER:UnregisterForEvent("LibNeed4Research", EVENT_ADD_ON_LOADED) -end - -EVENT_MANAGER:RegisterForEvent("LibNeed4Research", EVENT_ADD_ON_LOADED, OnAddOnLoaded) - - - - - - diff --git a/libs/LibNeed4Research/LibNeed4Research.txt b/libs/LibNeed4Research/LibNeed4Research.txt deleted file mode 100644 index ee810e0..0000000 --- a/libs/LibNeed4Research/LibNeed4Research.txt +++ /dev/null @@ -1,9 +0,0 @@ -## APIVersion: 100010 -## Title: LibNeed4Research -## Version: xxx -## Author: Circonian -## Description: A library used to track needed traits & recipes for all characters. - - -LibStub\LibStub.lua -LibNeed4Research.lua