Get an Epic Experience with Premium

LibPlayerSpellInfo-1.0

Libraries Login to Add Favorites
  • 0 Likes
  • World of Warcraft
  • 14 Monthly Downloads
  • Supports: 4.0.1
  • 1,372 Total Downloads
  • Updated 11/12/2010
  • Created 10/08/2010
  • 0 Favorites
  • Project Site
  • Release Type: Inactive
  • License: LPS Style BSD
  • Newest File: Release-r7
or

About LibPlayerSpellInfo-1.0

A library to provide extended information regarding player spell action/macro cast requirements (such as reagent, equipment and form requirements).

Includes:
  • Spell requirement API's that determine if a spell meets equipment, form, and/or reagent requirements.
    • There are also API's for parsing entire macrotext objects and determining if a spell name/link/id is a valid player spell/companion/mount.
  • Cast requirement API's (basically beefier IsUsableSpell/Action/Item functions) that determine nearly all1 casting requirements for any given spell/item/action.

1 Excluded parameters are whether the player has control of their character (which can be determined with LibUnitControl-1.0) and whether the player's target is within LOS, which is currently impossible to discern.

Usage

Here's a relatively simple display hook for use with the default blizzard actionbars that improves color indication of a whether a spell can be cast:

local lps = LibStub("LibPlayerSpellInfo-1.0")

local hook_ActionButton_OnUpdate = ActionButton_OnUpdate
function ActionButton_OnUpdate(button, elapsed)
  if button.rangeTimer and ( button.rangeTimer - elapsed <= 0 ) then
    ActionButton_UpdateUsable(button)
  end
  hook_ActionButton_OnUpdate(button, elapsed)
end

function ActionButton_UpdateUsable(button)

  local name = button:GetName()
  local icon, texture = _G[name.."Icon"], _G[name.."NormalTexture"]
  
  local isKnown, hasReact, _, inRange, hasUnit, _, hasMana
    hasEquip, hasReagent, inForm = lps:ActionUseInfo(button.action)
  
  if ( not inForm ) then -- Green overlay
    icon:SetVertexColor(0, 0.4, 0.2)
    texture:SetVertexColor(0, 0.4, 0.2)
  elseif ( not hasEquip ) or ( not hasReagent ) then -- Orange overlay
    icon:SetVertexColor(0.4, 0.2, 0)
    texture:SetVertexColor(0.4, 0.2, 0)
  elseif ( not hasMana ) then -- Blue overlay
    icon:SetVertexColor(0.2, 0.3, 0.7)
    texture:SetVertexColor(0.2, 0.3, 0.7)
  elseif ( hasUnit and not inRange ) then -- Red overlay
    icon:SetVertexColor(0.7, 0.15, 0.15)
    texture:SetVertexColor(0.7, 0.15, 0.15)
  elseif ( isKnown and not hasReact ) then -- Gray overlay
    icon:SetVertexColor(0.4, 0.4, 0.4);
    texture:SetVertexColor(1.0, 1.0, 1.0)
  else -- No overlay
    icon:SetVertexColor(1.0, 1.0, 1.0)
    texture:SetVertexColor(1.0, 1.0, 1.0)
  end
  
end

------------------------------------------------------------------------
r8 | draake | 2010-11-13 05:54:32 +0000 (Sat, 13 Nov 2010) | 1 line
Changed paths:
   A /tags/Release-r7 (from /trunk/LibPlayerSpellInfo-1.0:7)

Tagging as Release-r7.
------------------------------------------------------------------------
r7 | draake | 2010-11-13 05:51:31 +0000 (Sat, 13 Nov 2010) | 1 line
Changed paths:
   M /trunk/LibPlayerSpellInfo-1.0/LibPlayerSpellInfo-1.0.lua

Work around for GetCompanionInfo improperly returning nil when logging in sometimes.
------------------------------------------------------------------------
r6 | draake | 2010-10-13 19:35:01 +0000 (Wed, 13 Oct 2010) | 1 line
Changed paths:
   M /trunk/LibPlayerSpellInfo-1.0/LibPlayerSpellInfo-1.0.lua

Clean up api info for luadoc... part4.
------------------------------------------------------------------------
r5 | draake | 2010-10-08 17:35:30 +0000 (Fri, 08 Oct 2010) | 1 line
Changed paths:
   M /trunk/LibPlayerSpellInfo-1.0/LibPlayerSpellInfo-1.0.lua

Clean up api info for luadoc... part3.
------------------------------------------------------------------------

Login to Curse

Don't have an account? Create One.

Get an epic experience with Curse Premium
  • Faster addon downloads
  • Premium-Only Beta Giveaways
  • Ad-Free Curse experience
  • Premium Curse Client
  • and many More Features
  • Learn More »

Leaguepedia PAX Skin Giveaway