Download
(3 Kb)
Download
Updated: 02/23/20 07:09 PM
Compatibility:
Harrowstorm (5.3.5)
Dragonhold (5.2.5)
Scalebreaker (5.1.5)
Elsweyr (5.0.5)
Updated:02/23/20 07:09 PM
Created:05/24/14 11:45 AM
Monthly downloads:6,617
Total downloads:493,029
Favorites:362
MD5:
LibResearch  Popular! (More than 5000 hits)
Version: 4.0r2
by: Baertram, ingeniousclown, katkat42, Randactyl
This library basically provides a bunch of simple functions to get research information.
The library is accessable via the global variable:
Code:
LibResearch
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:
  1. -- returns true if the character knows or is in the process of researching the supplied trait; else returns false
  2. -- there are a few items, given to the character at the very beginning of the game, that are traited but unresearchable;
  3. -- these will present bugs when used with this function, but these items are very rare
  4. -- this function REPLACES the old function IsCraftingTraitKnownOrResearching()
  5. function libResearch:WillCharacterKnowTrait(craftingSkillType, researchLineIndex, traitIndex)
  6.  
  7. -- returns three values: int traitKey, bool isResearchable, string reason
  8. -- traitKey will be 0 if item is ornate, intricate, or traitless; else it will be the result of GetTraitKey()
  9. -- if isResearchable, then reason will be nil
  10. -- otherwise, reason will be: "WrongItemType", "Ornate", "Intricate", "Traitless", "AlreadyKnown"
  11. -- this function REPLACES DetailedIsItemResearchable() and IsItemResearchable()
  12. function libResearch:GetItemTraitResearchabilityInfo(itemLink)
  13.  
  14. -- Returns an integer representation of the parameters
  15. -- craftingSkillType * 10000 + researchLineIndex * 100 + traitIndex
  16. function libResearch:GetTraitKey( craftingSkillType, researchLineIndex, traitIndex )
  17.  
  18. -- returns the global enums CRAFTING_TYPE_BLACKSMITHING, CRAFTING_TYPE_CLOTHIER, CRAFTING_TYPE_WOODWORKING or CRAFTING_TYPE_JEWELRYCRAFTING
  19. -- if applicable; else returns -1
  20. function libResearch:GetItemCraftingSkill( itemLink )
  21.  
  22. -- returns a trait index suitable for feeding to the global functions GetSmithingLineTraitInfo() et. al.,
  23. -- or returns the string "Ornate" if the item is ornate,
  24. -- or returns the string "Intricate" if the item is intricate,
  25. -- or returns -1 if no trait exists
  26. function libResearch:GetResearchTraitIndex( itemLink )
  27.  
  28. -- returns an index that corresponds to the weapon or armor type within the given crafting skill
  29. -- or returns -1 if not applicable
  30. function libResearch:GetResearchLineIndex( itemLink )
  31.  
  32. -- returns three values: craftingSkill, researchLineIndex, traitIndex for the given item link
  33. function libResearch:GetItemResearchInfo( itemLink )
  34.  
  35. -- returns true if the craftingSkillType is one of the researchable crafts, false otherwise
  36. --> As we got 4 crafting skills now the name is wrong, but all are supported!
  37. function libResearch:IsBigThreeCrafting( craftingSkillType )
  38.  
  39. -- Returns true if the integer you pass in represents Blacksmithing, Clothier, or Woodworking; false otherwise
  40. function libResearch:IsBigThreeCrafting( craftingSkillType )
  41.  
  42. -- returns the below table "researchMap"
  43. 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:
  1. -- returns the below table "traitType2TraitIndex"
  2. 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
v4.0r2
Baertram:
-Removed LibStub! Please call the libray by it's global variable "LibResearch"
-Updated API
-Added constants
-Added function libResearch:GetTraitTypeToTraitIndex

v4.0r1
Baertram:
-Updated API
-Added AddOnVersion and IsLibrary tags
-Updated library on ESOUI
-Made the library standalone usable via global variable LibResearch
-Library still can be used via LibStub but the name changed to LibResearch, and this will only be kept active for a short time until LibStub wil be obsolete.

v3.0r1
Baertram:
-Added jewelry crafting
-Updated API


v2.0r2
-Fix an insidious bug

v2.0
-Major overhaul:
-new function names
-use itemLinks instead of bagId and slotIndex
-new return values for some functions
-Updated for API patch 100009.

v1.0r4
-Fixed an error introduced because of a misunderstanding about a new API function.

v1.0r3
-Updated for API patch 100008.

v1.0r2
-Added a new function: "IsBigThreeCrafting()". See documentation.


v1.0r1
-Initial release
Optional Files (0)


Archived Files (8)
File Name
Version
Size
Uploader
Date
4.0r1
3kB
Baertram
06/18/19 03:52 PM
2.0r2
4kB
katkat42
09/16/14 01:49 PM
2.0
4kB
katkat42
09/13/14 10:27 PM
1.0r4
3kB
katkat42
08/03/14 03:35 PM
1.0r3
3kB
katkat42
08/02/14 12:41 PM
1.0r3
3kB
katkat42
08/02/14 11:15 AM
1.0r2
3kB
ingeniousclown
05/25/14 08:12 PM
1.0r1
3kB
05/24/14 11:45 AM


Post A Reply Comment Options
Unread 02/09/20, 01:56 PM  
Baertram
Super Moderator
 
Baertram's Avatar
ESOUI Super Moderator
AddOn Author - Click to view AddOns

Forum posts: 4963
File comments: 6032
Uploads: 78
LibResearch will strip LibStub soon!
Be sure to use the globale variable LibResearch now and not LibStub("LibResearch") anymore!


Current version 42 can be found here:
https://github.com/Baertram/LibResearch
Last edited by Baertram : 02/09/20 at 01:59 PM.
Report comment to moderator  
Reply With Quote
Unread 08/04/14, 11:16 AM  
Morwo
 
Morwo's Avatar

Forum posts: 44
File comments: 100
Uploads: 0
hi there,
i get lua errors, with LibResearch mentioned in it. they dont stop, even if i turn tis lib off as an addon, anoying because i get tons of po ups. never ending.

Report comment to moderator  
Reply With Quote
Unread 08/03/14, 03:46 PM  
katkat42
AddOn Author - Click to view AddOns

Forum posts: 155
File comments: 142
Uploads: 7
Originally Posted by Sephiroth018
I think you forgot to raise the minor number for registering libResearch in libStub:

In libResearch.lua
Currently:
Lua Code:
  1. local MAJOR, MINOR = "libResearch", 3

Should be:
Lua Code:
  1. local MAJOR, MINOR = "libResearch", 4

That causes your fix (r4) to not be used when r3 has already been registered in libStub
I did. I have fixed and re-uploaded the file.
Report comment to moderator  
Reply With Quote
Unread 08/03/14, 03:35 PM  
Sephiroth018
 
Sephiroth018's Avatar
AddOn Author - Click to view AddOns

Forum posts: 20
File comments: 67
Uploads: 3
I think you forgot to raise the minor number for registering libResearch in libStub:

In libResearch.lua
Currently:
Lua Code:
  1. local MAJOR, MINOR = "libResearch", 3

Should be:
Lua Code:
  1. local MAJOR, MINOR = "libResearch", 4

That causes your fix (r4) to not be used when r3 has already been registered in libStub
Last edited by Sephiroth018 : 08/03/14 at 03:36 PM.
Report comment to moderator  
Reply With Quote
Unread 05/25/14, 02:33 AM  
b|m
AddOn Author - Click to view AddOns

Forum posts: 2
File comments: 15
Uploads: 1
Thanks for making your work available in a library.
Last edited by b|m : 05/25/14 at 02:33 AM.
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: