Quantcast
Download
(5 Kb)
Download
Updated: 09/17/18 10:57 AM
Compatibility:
Wolfhunter (4.1)
Summerset (4.0)
Updated:09/17/18 10:57 AM
Created:07/22/18 02:41 PM
Monthly downloads:492
Total downloads:750
Favorites:2
MD5:
4.1
LibPotionBuff
Version: 1.01
by: Baertram [More]
For Players
This Library is only for use by Add-on Developers

For Developers
This Library includes a list of all current potion buffs along with their type (non-crafted, crafted, from crown store).
It includes functions to get information about group member's and/or player potion statuses.
The Library can be used by itself or packaged in an Add-on without the standalone.lua file.

Code:
Structure
LibPotionBuff
|_LibPotionBuff.txt
|_LibPotionBuff.lua
|_LibStub
| |_LibStub.lua
If you want to package LibPotionBuff with your addon, you only need to use the file LibPotionBuff.lua inside your addon, without the .txt file!
Depends on: Your addon needs to use LibStub!

Functions
You need to create an instance of this library via LibStub like this:
Lua Code:
  1. --libPotionBuff
  2. local lib = LibStub:GetLibrary("LibPotionBuff")
Use the variable lib to call the following functions then:


Lua Code:
  1. function lib:GetTimeLeftInSeconds(timeInMilliseconds)
  2. Parameter: number timeInMilliseconds - any number in milliseconds
  3. Returns: time in seconds rounded up

Lua Code:
  1. function lib:GetPotionBuffInfos(unitTag)
  2. --Parameter: string unitTag - any unitTag (http://wiki.esoui.com/UnitTag)
  3. -- Returns: boolean isBuffActive, bool isCrafted, bool isFromCrownStore, number abilityId, string buffName, number timeStarted, number timeEnds, textureString iconTexture

Lua Code:
  1. function lib:IsPotionBuffActive(unitTag)
  2. --Parameter: string unitTag - any unitTag (http://wiki.esoui.com/UnitTag)
  3. -- Returns: bool isBuffActive

Lua Code:
  1. function lib:IsPotionBuffActiveAndGetTimeLeft(unitTag)
  2. --Parameter: string unitTag - any unitTag (http://wiki.esoui.com/UnitTag)
  3. -- Returns: bool isBuffActive, number timeLeftInSeconds , number abilityId

Lua Code:
  1. function lib:GetPotionSlotCooldown(chatOutput)
  2.     -- Parameter:   boolean chatOutput - true = output the info to the chat; false = do not show anyhting into the chat
  3.     -- Returns:     number timeLeftInMilliseconds, number buffTotalCooldownInMilliseconds

Lua Code:
  1. function lib:IsAbilityACraftedPotionBuff(abilityId)
  2. --Parameter: integer abilityId - any abilityId (http://esoitem.uesp.net/viewlog.php?record=minedSkills)
  3. -- Returns: nilable:bool IsAbilityACraftedPotionBuff(true) or false if not, or nil if not any potion buff

Lua Code:
  1. function lib:IsAbilityACrownStorePotionBuff(abilityId)
  2. --Parameter: integer abilityId - any abilityId (http://esoitem.uesp.net/viewlog.php?record=minedSkills)
  3. -- Returns: nilable:bool isAbilityACrownStorePotionBuff(true) or false if not, or nil if not any potion buff

Lua Code:
  1. function lib:IsAbilityAPotionBuff(abilityId)
  2. --Parameter: integer abilityId - any abilityId (http://esoitem.uesp.net/viewlog.php?record=minedSkills)
  3. -- Returns: bool isAbilityAnActivePotionBuff(true) or false if not


To register a callback function to the EVENT_EFFECT_CHANGED event for all the potion abilityIds you can use this function:
Lua Code:
  1. function lib:RegisterAbilityIdsFilterOnEventEffectChanged(addonEventNameSpace, callbackFunc, filterType, filterParameter)
  2. --Parameters:   addonEventNameSpace - prefered to insert your addon name. if you want to call this function twice, make sure the second/third/... addonEventNameSpace has another name. Example `addonName.."_01"`, `addonName.."_02"`
  3. --callbackFunc - any global function you want to run when the event is firing
  4. --filterType - choose any filter type from here: http://wiki.esoui.com/AddFilterForEvent
  5. --filterParameter - choose any filter parameter from here: http://wiki.esoui.com/AddFilterForEvent
To unregister your callback function to the EVENT_EFFECT_CHANGED event for all the potion abilityIds you can use this function:
Lua Code:
  1. function lib:UnRegisterAbilityIdsFilterOnEventEffectChanged()
1.01
Fixed the wrong library txt file
Added LiBStub dependency

Thanks to "Lakashi" for the fix info about the wrong txt file!
Optional Files (0)


Archived Files (1)
File Name
Version
Size
Author
Date
1.0
5kB
Baertram
07/22/18 02:41 PM


Post A Reply Comment Options
Unread 09/17/18, 11:17 AM  
Baertram
 
Baertram's Avatar
AddOn Author - Click to view AddOns

Forum posts: 1767
File comments: 1862
Uploads: 47
Thanks Lakashi, quick and good find! Fixed now + added dependency to LibStub properly.
Report comment to moderator  
Reply With Quote
Unread 09/17/18, 10:16 AM  
Lakashi

Forum posts: 2
File comments: 50
Uploads: 0
In the LibPotionBuff.txt, you have "libs\LibPotionBuff\LibPotionBuff.lua" as the directory and the lua is actually sitting in the root. Same with the LibStub as well, there is no libs directory.

Temporary fix:
Make the LibPotionBuff.txt line 7 and 8 read as:
Code:
LibStub\LibStub.lua
LibPotionBuff.lua
Last edited by Lakashi : 09/17/18 at 10:21 AM.
Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: