This library basically provides a bunch of simple functions to get research information.
The library is accessable via the global variable:
LibStub support was removed with version 4.r2
Please add the dependency to your addon's manifest txt file using the addonversion 042 to make sure the users install at least this version to be access via the global variable:
Code:
## DependsOn: LibResearch>=042
-> This will make your addon stop loading if the library is missing or installed with a version < then 4.r2.
Code:
## OptionalDependsOn: LibResearch>=042
-> This will make your addon load if the library is missing or installed with a version < then 4.r2, but it WILL throw error messages if you try to load it via LibStub and might throw other error messages.
[Here is the new API]
Constants:
Code:
LIBRESEARCH_REASON_ALREADY_KNOWN = "AlreadyKnown"
LIBRESEARCH_REASON_WRONG_ITEMTYPE = "WrongItemType"
LIBRESEARCH_REASON_ORNATE = "Ornate"
LIBRESEARCH_REASON_INTRICATE = "Intricate"
LIBRESEARCH_REASON_TRAITLESS = "Traitless"
Functions:
lua Code:
-- returns true if the character knows or is in the process of researching the supplied trait; else returns false
-- there are a few items, given to the character at the very beginning of the game, that are traited but unresearchable;
-- these will present bugs when used with this function, but these items are very rare
-- this function REPLACES the old function IsCraftingTraitKnownOrResearching()
function libResearch:WillCharacterKnowTrait(craftingSkillType, researchLineIndex, traitIndex)
-- returns three values: int traitKey, bool isResearchable, string reason
-- traitKey will be 0 if item is ornate, intricate, or traitless; else it will be the result of GetTraitKey()
-- if isResearchable, then reason will be nil
-- otherwise, reason will be: "WrongItemType", "Ornate", "Intricate", "Traitless", "AlreadyKnown"
-- this function REPLACES DetailedIsItemResearchable() and IsItemResearchable()
function libResearch:GetItemTraitResearchabilityInfo(itemLink)
-- Returns an integer representation of the parameters
-- craftingSkillType * 10000 + researchLineIndex * 100 + traitIndex
function libResearch:GetTraitKey( craftingSkillType, researchLineIndex, traitIndex )
-- returns the global enums CRAFTING_TYPE_BLACKSMITHING, CRAFTING_TYPE_CLOTHIER, CRAFTING_TYPE_WOODWORKING or CRAFTING_TYPE_JEWELRYCRAFTING
-- if applicable; else returns -1
function libResearch:GetItemCraftingSkill( itemLink )
-- returns a trait index suitable for feeding to the global functions GetSmithingLineTraitInfo() et. al.,
-- or returns the string "Ornate" if the item is ornate,
-- or returns the string "Intricate" if the item is intricate,
-- or returns -1 if no trait exists
function libResearch:GetResearchTraitIndex( itemLink )
-- returns an index that corresponds to the weapon or armor type within the given crafting skill
-- or returns -1 if not applicable
function libResearch:GetResearchLineIndex( itemLink )
-- returns three values: craftingSkill, researchLineIndex, traitIndex for the given item link
function libResearch:GetItemResearchInfo( itemLink )
-- returns true if the craftingSkillType is one of the researchable crafts, false otherwise
--> As we got 4 crafting skills now the name is wrong, but all are supported!
function libResearch:IsBigThreeCrafting( craftingSkillType )
-- Returns true if the integer you pass in represents Blacksmithing, Clothier, or Woodworking; false otherwise
function libResearch:IsBigThreeCrafting( craftingSkillType )
-- returns the below table "researchMap"
function libResearch:GetResearchMap()
Here is the researchMap construct, in case you need it. Note that this can change between patches based on the whims of the game developers...
Code:
local researchMap = {
[BLACKSMITH] = {
WEAPON = {
[WEAPONTYPE_AXE] = 1,
[WEAPONTYPE_HAMMER] = 2,
[WEAPONTYPE_SWORD] = 3,
[WEAPONTYPE_TWO_HANDED_AXE] = 4,
[WEAPONTYPE_TWO_HANDED_HAMMER] = 5,
[WEAPONTYPE_TWO_HANDED_SWORD] = 6,
[WEAPONTYPE_DAGGER] = 7,
},
ARMOR = {
[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,
},
},
--normal for light, +7 for medium
[CLOTHIER] = {
ARMOR = {
[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,
},
},
[WOODWORK] = {
WEAPON = {
[WEAPONTYPE_BOW] = 1,
[WEAPONTYPE_FIRE_STAFF] = 2,
[WEAPONTYPE_FROST_STAFF] = 3,
[WEAPONTYPE_LIGHTNING_STAFF] = 4,
[WEAPONTYPE_HEALING_STAFF] = 5,
},
ARMOR = {
[EQUIP_TYPE_OFF_HAND] = 6,
},
},
[JEWELRY_CRAFTING] = {
ARMOR = {
[EQUIP_TYPE_NECK] = 1,
[EQUIP_TYPE_RING] = 2,
},
}
}
Lua Code:
-- returns the below table "traitType2TraitIndex"
function libResearch:GetTraitTypeToTraitIndex()
Code:
local ItemTraitType2TraitIndex = {
--Weapons
[ITEM_TRAIT_TYPE_WEAPON_POWERED] = 1, -- 1
[ITEM_TRAIT_TYPE_WEAPON_CHARGED] = 2, -- 2
[ITEM_TRAIT_TYPE_WEAPON_PRECISE] = 3, -- 3
[ITEM_TRAIT_TYPE_WEAPON_INFUSED] = 4, -- 4
[ITEM_TRAIT_TYPE_WEAPON_DEFENDING] = 5, -- 5
[ITEM_TRAIT_TYPE_WEAPON_TRAINING] = 6, -- 6
[ITEM_TRAIT_TYPE_WEAPON_SHARPENED] = 7, -- 7
[ITEM_TRAIT_TYPE_WEAPON_WEIGHTED] = 8, -- 8 --> Old, removed from game and exchanged by ITEM_TRAIT_TYPE_WEAPON_DECISIVE
[ITEM_TRAIT_TYPE_WEAPON_DECISIVE] = 8, -- 8
[ITEM_TRAIT_TYPE_WEAPON_NIRNHONED] = 9, -- 26
[ITEM_TRAIT_TYPE_WEAPON_INTRICATE] = LIBRESEARCH_REASON_INTRICATE, -- 9
[ITEM_TRAIT_TYPE_WEAPON_ORNATE] = LIBRESEARCH_REASON_ORNATE, -- 10
--Armor
[ITEM_TRAIT_TYPE_ARMOR_STURDY] = 1, -- 11
[ITEM_TRAIT_TYPE_ARMOR_IMPENETRABLE] = 2, -- 12
[ITEM_TRAIT_TYPE_ARMOR_REINFORCED] = 3, -- 13
[ITEM_TRAIT_TYPE_ARMOR_WELL_FITTED] = 4, -- 14
[ITEM_TRAIT_TYPE_ARMOR_TRAINING] = 5, -- 15
[ITEM_TRAIT_TYPE_ARMOR_INFUSED] = 6, -- 16
[ITEM_TRAIT_TYPE_ARMOR_EXPLORATION] = 7, -- 17 --> Old, removed from game and exchanged by ITEM_TRAIT_TYPE_ARMOR_PROSPEROUS
[ITEM_TRAIT_TYPE_ARMOR_PROSPEROUS] = 7, -- 17
[ITEM_TRAIT_TYPE_ARMOR_DIVINES] = 8, -- 18
[ITEM_TRAIT_TYPE_ARMOR_NIRNHONED] = 9, -- 25
[ITEM_TRAIT_TYPE_ARMOR_INTRICATE] = LIBRESEARCH_REASON_INTRICATE, -- 20
[ITEM_TRAIT_TYPE_ARMOR_ORNATE] = LIBRESEARCH_REASON_ORNATE, -- 19
--Jewelry
[ITEM_TRAIT_TYPE_JEWELRY_ARCANE] = 1, -- 22
[ITEM_TRAIT_TYPE_JEWELRY_HEALTHY] = 2, -- 21
[ITEM_TRAIT_TYPE_JEWELRY_ROBUST] = 3, -- 23
[ITEM_TRAIT_TYPE_JEWELRY_TRIUNE] = 4, -- 30
[ITEM_TRAIT_TYPE_JEWELRY_INFUSED] = 5, -- 33
[ITEM_TRAIT_TYPE_JEWELRY_PROTECTIVE] = 6, -- 32
[ITEM_TRAIT_TYPE_JEWELRY_SWIFT] = 7, -- 28
[ITEM_TRAIT_TYPE_JEWELRY_HARMONY] = 8, -- 29
[ITEM_TRAIT_TYPE_JEWELRY_BLOODTHIRSTY] = 9, -- 31
[ITEM_TRAIT_TYPE_JEWELRY_INTRICATE] = LIBRESEARCH_REASON_INTRICATE, -- 27
[ITEM_TRAIT_TYPE_JEWELRY_ORNATE] = LIBRESEARCH_REASON_ORNATE, -- 24
}
LibResearch at GitHub: https://github.com/Baertram/LibResearch