File ./LibScriptablePlugins-1.0/LibScriptablePluginUtils-1.0/LibScriptablePluginUtils-1.0.lua

Functions

PluginUtils.BetterUnitClassification (unit) Return the unit classification of the given unit.
PluginUtils.ConvertMethodToFunction (namespace, func_name) Leave a function as-is or if a string is passed in, convert it to a namespace-method function call.
PluginUtils.GetBestUnitID (unit) Return the best UnitID for the UnitID provided
PluginUtils.GetCoords (n, pitch) Retrieve the column and row coordinates for the provided index and pitch
PluginUtils.GetLocalizedClassification (classification) Return a localized form of the unit classification.
PluginUtils.GetMobIDFromGuid (guid) Return the Mob ID of the given GUID.
PluginUtils.Intersect (frame1, frame2, frame1xPad1, frame1yPad1, frame1xPad2, frame1yPad2, frame2xPad1, frame2yPad1, frame2xPad2, frame2yPad2) Intersect - Find out if two frames intersect, adjusted by paddings.
PluginUtils.IsPowerOf2 (n) Determine if the number provided is a power of 2
PluginUtils.IsSingletonUnitID (unit) Return whether the UnitID provided is a singleton
PluginUtils.IsValidClassification (unit, classification) Return whether the classification is valid
PluginUtils.IsWackyUnitGroup (classification) Return whether the classification provided is considered "wacky"
PluginUtils.Split (str, delim) Split a string using the delimiter provided
PluginUtils:New (environment) Populate an environment with this plugin's fields


Functions

PluginUtils.BetterUnitClassification (unit)
Return the unit classification of the given unit. This acts like UnitClassification(unit), but returns "worldboss" for bosses that match LibBossIDs-1.0

Parameters

  • unit: The unit to check the classification of.

Return value:

one of "worldboss", "elite", "rareelite", "rare", or "normal"
PluginUtils.ConvertMethodToFunction (namespace, func_name)
Leave a function as-is or if a string is passed in, convert it to a namespace-method function call.

Parameters

  • namespace: a table with the method func_name on it
  • func_name: a function (which would then just return) or a string, which is the name of the method.

Usage

  • PluginUtils.ConvertMethodToFunction({}, function(value) return value end)("blah") == "blah"
  • PluginUtils.ConvertMethodToFunction({ method = function(self, value) return value end }, "method")("blah") == "blah"

Return value:

a function
PluginUtils.GetBestUnitID (unit)
Return the best UnitID for the UnitID provided

Parameters

  • unit: the known UnitID

Usage:

PluginUtils.GetBestUnitID("playerpet") == "pet"

Return value:

the best UnitID. If the ID is invalid, it will return false
PluginUtils.GetCoords (n, pitch)
Retrieve the column and row coordinates for the provided index and pitch

Parameters

  • n: An index within a buffer
  • pitch: Your surface's column width

Usage:

GetCoords(n, pitch)

Return value:

The column and row representing the provided data
PluginUtils.GetLocalizedClassification (classification)
Return a localized form of the unit classification.

Parameters

  • classification: a unit classification, e.g. "player", "party", "partypet"

Usage

  • PluginUtils.GetLocalizedClassification("player") == "Player"
  • PluginUtils.GetLocalizedClassification("target") == "Player's target"
  • PluginUtils.GetLocalizedClassification("partypettarget") == "Party pet targets"

Return value:

a localized string of the unit classification
PluginUtils.GetMobIDFromGuid (guid)
Return the Mob ID of the given GUID. It doesn't matter if the guid starts with "0x" or not. This will only work for NPCs, not other types of guids, such as players.

Parameters

  • guid:

Usage

  • PluginUtils.GetMobIDFromGuid("0xF13000046514911F") == 1125
  • PluginUtils.GetMobIDFromGuid("F13000046514911F") == 1125
PluginUtils.Intersect (frame1, frame2, frame1xPad1, frame1yPad1, frame1xPad2, frame1yPad2, frame2xPad1, frame2yPad1, frame2xPad2, frame2yPad2)
Intersect - Find out if two frames intersect, adjusted by paddings. usage Intersect(frame1, frame2, frame1xPad1, frame1yPad1, frame1xPad2, frame1yPad2, frame2xPad1, frame2yPad1, frame2xPad2, frame2yPad2)

Parameters

  • frame1: The first frame to compare.
  • frame2: The second frame to compare.
  • frame1xPad1: Padding for left side of frame1
  • frame1yPad1: Padding for top side of frame1
  • frame1xPad2: Padding for right side of frame1
  • frame1yPad2: Padding for bottom of frame1
  • frame2xPad1: Padding for left side of frame2
  • frame2yPad1: Padding for top side of frame2
  • frame2xPad2: Padding for right side of frame2
  • frame2yPad2: Padding for bottom of frame2

Return value:

True if the two frames intersect, false otherwise
PluginUtils.IsPowerOf2 (n)
Determine if the number provided is a power of 2

Parameters

  • n: A number value

Usage:

IsPowerOf2(n)

Return value:

A boolean indicating whether the value is a power of 2 or not
PluginUtils.IsSingletonUnitID (unit)
Return whether the UnitID provided is a singleton

Parameters

  • unit: the UnitID to check

Usage

  • PluginUtils.IsSingletonUnitID("player") == true
  • PluginUtils.IsSingletonUnitID("party1") == false

Return value:

whether it is a singleton
PluginUtils.IsValidClassification (unit, classification)
Return whether the classification is valid

Parameters

  • unit:
  • classification: the classification to check

Usage

  • PluginUtils.IsValidClassification("player") == true
  • PluginUtils.IsValidClassification("party") == true
  • PluginUtils.IsValidClassification("partytarget") == true
  • PluginUtils.IsValidClassification("partypettarget") == true
  • PluginUtils.IsValidClassification("party1") == false

Return value:

whether it is a a valid classification
PluginUtils.IsWackyUnitGroup (classification)
Return whether the classification provided is considered "wacky"

Parameters

  • classification: the classification in question

Usage

  • assert(not PluginUtils.IsWackyUnitGroup("player"))
  • assert(PluginUtils.IsWackyUnitGroup("targettarget"))
  • assert(PluginUtils.IsWackyUnitGroup("partytarget"))

Return value:

whether it is wacky
PluginUtils.Split (str, delim)
Split a string using the delimiter provided

Parameters

  • str: The string to split
  • delim: The delimiter should be a single character

Usage:

Split(str, delim)

Return value:

A new table populated with the split substrings
PluginUtils:New (environment)
Populate an environment with this plugin's fields

Parameters

  • environment:

Usage:

:New(environment)

Return value:

A new plugin object, aka the environment

Valid XHTML 1.0!