Module FocusCore

API documentation can be generated using LDoc or viewed here: https://wardz.github.io/FocusFrame/

Info:

  • License: MIT
  • Author: Wardz

Tables

Events List of available events.

Misc

Focus:ShowError ([msg="You have no focus"]) Display an error in UIErrorsFrame.
Focus:ToggleNameplateScan (state) Toggle nameplate scanning.

Unit

Focus:UnitIsFocus (unit[, checkName=false]) Check if unit ID or unit name matches focus target.
Focus:GetFocusUnit () Get unit ID for focus if available.
Focus:FocusExists ([showError=false]) Check if focus is sat.
Focus:Call (func, arg1, arg2, arg3, arg4) Call functions on focus.
Focus:CastSpellByName (name) Trigger CastSpellByName on focus target.
Focus:TargetFocus ([name=nil[, setFocusName=nil]]) Target the focus.
Focus:TargetFocusTarget () Target the focus' target.
Focus:TargetPrevious () Target last target after having targeted focus.
Focus:SetFocus ([name=nil]) Set current target as focus, or name if given.
Focus:IsDead () Check if focus is dead.
Focus:TargetIsDead () Check if focus' target is dead.
Focus:ClearFocus () Remove focus & all data.

Getters

Focus:GetName () Get focus unit name.
Focus:GetHealth () Get focus health.
Focus:GetPower () Get focus power.
Focus:GetTargetName () Get focus' target name.
Focus:GetTargetHealth () Get focus' target health.
Focus:GetTargetPower () Get focus' target power.
Focus:GetPowerColor () Get statusbar color for power.
Focus:GetBuffs () Get table containing all buff+debuff data for focus.
Focus:GetCast ([name=focusTargetName]) Get cast data for focus.
Focus:GetReactionColors () Get UnitReactionColor for focus

Data

Focus:GetData ([key1=nil[, key2=nil[, key3=nil[, key4=nil]]]]) Get focus data by key.
Focus:SetData (key, value) Insert/replace any focus data
Focus:ClearData ([key=nil]) Delete data by key or all focus data if no key is given.

Events

Focus:OnEvent (eventName, callback) Register event handler for a focus event.
Focus:RemoveEvent (eventName, eventID) Remove existing event handler.


Tables

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) -- unit arg may be nil!

Misc

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:

  • state bool

Returns:

    bool true if enabled

Unit

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:Call(CastSpellByName, "Fireball") -- Casts Fireball on focus target
  • Focus:Call(DropItemOnUnit); -- defaults to focus unit if no second arg given
Focus:CastSpellByName (name)
Trigger CastSpellByName on focus target.

Parameters:

  • name string name of spell to cast

Usage:

    Focus:CastSpellByName("Fireball") -- Casts Fireball on focus target
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.

Getters

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:

  1. number min
  2. number max
Focus:GetPower ()
Get focus power. (Mana etc)

Returns:

  1. number min
  2. number max
Focus:GetTargetName ()
Get focus' target name.

Returns:

    string or nil
Focus:GetTargetHealth ()
Get focus' target health.

Returns:

  1. number min
  2. number max
Focus:GetTargetPower ()
Get focus' target power.

Returns:

  1. number min
  2. 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:

  1. table FSPELLCASTINGCORE cast data
  2. number Current cast time
  3. number Max cast time
  4. number Spark position
  5. number Time left formatted

Or

    nil
Focus:GetReactionColors ()
Get UnitReactionColor for focus

Returns:

  1. number r
  2. number g
  3. number b

Data

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:

Events

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
generated by LDoc 1.4.6 Last updated 2018-04-06 16:18:16