Module FocusCore
API documentation can be generated using LDoc or viewed here:
https://wardz.github.io/FocusFrame/
Info:
- License: MIT
- Author: Wardz
| Events |
List of available events. |
-
Events
-
List of available events.
All events can be registered multiple times.
Fields:
- UNIT_HEALTH_OR_POWER
- UNIT_LEVEL
- UNIT_AURA
- UNIT_CLASSIFICATION_CHANGED
- UNIT_FACTION
- PLAYER_FLAGS_CHANGED
- RAID_TARGET_UPDATE
- FOCUS_UNITID_EXISTS
- FOCUS_SET
- FOCUS_CHANGED
- FOCUS_CLEAR
- FOCUS_TARGET_UPDATED
Usage:
Focus:OnEvent("EVENT_NAME", function(event, unit) end)
-
Focus:ShowError ([msg="You have no focus"])
-
Display an error in UIErrorsFrame.
Parameters:
- msg
string
(default "You have no focus")
-
Focus:ToggleNameplateScan (state)
-
Toggle nameplate scanning.
Parameters:
Returns:
bool
true if enabled
-
Focus:UnitIsFocus (unit[, checkName=false])
-
Check if unit ID or unit name matches focus target.
If 'checkName' is true, 'unit' needs to be a name and not an unit ID.
Parameters:
- unit
string
- checkName
bool
(default false)
Returns:
bool
true if match
-
Focus:GetFocusUnit ()
-
Get unit ID for focus if available.
If you need to get unitID reliably, checkout FOCUS_UNITID_EXISTS event.
Returns:
string
unitID
Or
nil
-
Focus:FocusExists ([showError=false])
-
Check if focus is sat. (not same as UnitExists!)
Use falseness check on CURR_FOCUS_TARGET instead when performance is critical.
Parameters:
- showError
bool
display default UI error msg
(default false)
Returns:
bool
true if exists
-
Focus:Call (func, arg1, arg2, arg3, arg4)
-
Call functions on focus. I.e CastSpellByName.
Parameters:
- func
func
function reference or string to be parsed in loadstring()
- arg1
- arg2
- arg3
- arg4
Returns:
pcall or loadstring results
Usage:
-
Focus:CastSpellByName (name)
-
Trigger CastSpellByName on focus target.
Parameters:
- name
string
name of spell to cast
Usage:
Focus:CastSpellByName("Fireball")
-
Focus:TargetFocus ([name=nil[, setFocusName=nil]])
-
Target the focus.
Parameters:
- name
string
Target unit with this name instead when not nil.
(default nil)
- setFocusName
bool
true to update string vars storing focus unit name
(default nil)
Returns:
bool
true on success
-
Focus:TargetFocusTarget ()
-
Target the focus' target.
-
Focus:TargetPrevious ()
-
Target last target after having targeted focus.
This can only be used after TargetFocus() has been ran!
-
Focus:SetFocus ([name=nil])
-
Set current target as focus, or name if given.
Parameters:
-
Focus:IsDead ()
-
Check if focus is dead.
Returns:
bool
true if dead
-
Focus:TargetIsDead ()
-
Check if focus' target is dead.
Returns:
bool
true if dead
-
Focus:ClearFocus ()
-
Remove focus & all data.
-
Focus:GetName ()
-
Get focus unit name.
Global var CURR_FOCUS_TARGET may also be used when performance is critical.
Returns:
string
unit name
Or
nil
-
Focus:GetHealth ()
-
Get focus health.
Returns:
-
number
min
-
number
max
-
Focus:GetPower ()
-
Get focus power. (Mana etc)
Returns:
-
number
min
-
number
max
-
Focus:GetTargetName ()
-
Get focus' target name.
Returns:
string
or nil
-
Focus:GetTargetHealth ()
-
Get focus' target health.
Returns:
-
number
min
-
number
max
-
Focus:GetTargetPower ()
-
Get focus' target power.
Returns:
-
number
min
-
number
max
-
Focus:GetPowerColor ()
-
Get statusbar color for power.
Returns:
table
{r=number,g=number,b=number}
-
Focus:GetBuffs ()
-
Get table containing all buff+debuff data for focus.
Should be ran in an OnUpdate script or OnEvent("UNIT_AURA")
Returns:
table
data or empty table
-
Focus:GetCast ([name=focusTargetName])
-
Get cast data for focus.
Should be ran in an OnUpdate script.
Parameters:
- name
string
(default focusTargetName)
Returns:
-
table
FSPELLCASTINGCORE cast data
-
number
Current cast time
-
number
Max cast time
-
number
Spark position
-
number
Time left formatted
Or
nil
-
Focus:GetReactionColors ()
-
Get UnitReactionColor for focus
Returns:
-
number
r
-
number
g
-
number
b
-
Focus:GetData ([key1=nil[, key2=nil[, key3=nil[, key4=nil]]]])
-
Get focus data by key.
If no key is specified, returns all the data.
See SetFocusInfo() for list of data available.
Parameters:
Returns:
data or empty table
Or
nil
Usage:
local lvl = Focus:GetData("unitLevel")
local lvl, class, name = Focus:GetData("unitLevel", "unitClass", "unitName")
local data = Focus:GetData()
-
Focus:SetData (key, value)
-
Insert/replace any focus data
Parameters:
-
Focus:ClearData ([key=nil])
-
Delete data by key or all focus data if no key is given.
When deleting all focus data, you probably want to run Focus:ClearFocus() instead.
Parameters:
-
Focus:OnEvent (eventName, callback)
-
Register event handler for a focus event.
This does not overwrite existing event handlers.
Parameters:
- eventName
string
- callback
func
Returns:
number
event ID
-
Focus:RemoveEvent (eventName, eventID)
-
Remove existing event handler.
Parameters:
- eventName
string
- eventID
number