Download
(5 Kb)
Download
Updated: 04-26-11 12:13 PM
Pictures
File Info
Updated:04-26-11 12:13 PM
Created:04-20-11 12:26 PM
Downloads:969
Favorites:5
MD5:
LibSpellOverlay-1.0
Version: 1.0
by: Vladinator [More]
The objective of this library is to make showing/hiding custom overlays easier, using the built in spell activation overlay addon made by Blizzard and introduced patch 4.0.3.

These are the API this library provides:
Code:
:Show(spellID, duration[, position][, scale][, texture][, r, g, b])
  spellID = number, preferably a real spell ID
  duration = between 1 and max int value
  position = ["CENTER", "TOP", "BOTTOM", "LEFT", "RIGHT", "TOPLEFT", "TOPRIGHT", "BOTTOMLEFT", "BOTTOMRIGHT", "RIGHT (FLIPPED)", "BOTTOM (FLIPPED)", "LEFT + RIGHT (FLIPPED)", "TOP + BOTTOM (FLIPPED)"]
  scale = number, .5 is half size, 2 is double size, e.g.
  texture = string, path to a blp/tga file to use as a texture
  r, g and b = color the texture, set to 255 to make it appear normal

:Hide(spellID)
  spellID = number, hides the overlay by this spell ID

:FreePositions()
  returns a table with positions that are available
Example addon (Mage)
Using the library to show a texture and make it turn more red the more stacks of Arcane Blast the player has.
lua Code:
  1. --[[
  2.   Example addon using LibSpellOverlay-1.0 to create an overlay and
  3.   help track Arcane Blast debuff stacks.
  4. ]]
  5.  
  6. -- Do not load if not a Mage
  7. if select(2, UnitClass("player")) ~= "MAGE" then return end
  8.  
  9. -- Do not load if LibStub is missing
  10. if not LibStub then return end
  11.  
  12. -- Get the library
  13. local LibSpellOverlay = LibStub:GetLibrary("LibSpellOverlay-1.0", 1)
  14.  
  15. -- Do not load if the library couldn't be found
  16. if not LibSpellOverlay then return end
  17.  
  18. -- Load our addon and it's variables
  19. local addon = CreateFrame("Frame")
  20. local spellID = 36032
  21. local spellName = GetSpellInfo(spellID)
  22. local stackColors = {
  23.   {255, 255, 255}, -- fallback (white)
  24.   {255, 192, 192}, -- 1 stack (slighty red)
  25.   {255, 128, 128}, -- 2 stacks (light red)
  26.   {255, 64, 64}, -- 3 stacks (orange)
  27.   {255, 0, 0}, -- 4 stacks (red)
  28. }
  29. addon:RegisterEvent("UNIT_AURA")
  30. addon:SetScript("OnEvent", function(addon, event, unit)
  31.   if unit ~= "player" then return end
  32.  
  33.   local _, _, _, stacks, _, duration = UnitDebuff(unit, spellName)
  34.   if (duration or 0) > 0 then
  35.     local r, g, b = unpack( stackColors[stacks+1] or select(2, next(stackColors)) )
  36.     LibSpellOverlay:Show(spellID, duration, "BOTTOM (FLIPPED)", 1.25, "Textures\\SpellActivationOverlays\\GenericTop_01", r, g, b)
  37.   else
  38.     LibSpellOverlay:Hide(spellID)
  39.   end
  40. end)
26.04.2011:
+ Expanded the example.lua with more example code, now both Hunter and Mage have working custom overlays showing up at specific events.
Optional Files (0)


Post A Reply Comment Options
Old 04-21-11, 09:57 AM  
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view AddOns

Forum posts: 747
File comments: 382
Uploads: 39
Revision 2 is up, made it use LibStub (like libraries should), fixed some errors, put the example in LibStub style of coding, commented it out in the .toc by default.

I'd say it's ready for addon developers to take advantage of the easy way of showing overlays at certain events!
Last edited by Vlad : 04-21-11 at 10:31 AM.
Vlad is offline Report comment to moderator  
Reply With Quote
Old 04-21-11, 08:35 AM  
adz4u28
A Murloc Raider

Forum posts: 5
File comments: 22
Uploads: 0
looks very promising nice job wtb some gui or such tho!
adz4u28 is offline Report comment to moderator  
Reply With Quote
Old 04-20-11, 02:28 PM  
Vlad
A Molten Giant
 
Vlad's Avatar
AddOn Author - Click to view AddOns

Forum posts: 747
File comments: 382
Uploads: 39
I'd like to specify it's supposed to make it easier for addon coders to show buffs or specific events with the overlay system -no GUI or other features for users so far. :P
Vlad is offline Report comment to moderator  
Reply With Quote
Old 04-20-11, 02:23 PM  
tinyu
A Molten Giant
 
tinyu's Avatar
AddOn Author - Click to view AddOns

Forum posts: 816
File comments: 335
Uploads: 16
gonna go test it out now ill leave feed back in a few minutes.
__________________


"There's no such thing as too many addons."
Lothaer
Titan Dev Team Member.
tinyu is offline Report comment to moderator  
Reply With Quote
Post A Reply



Category Jump: