Module Musician.Utils
Utility functions
Functions
| Musician.Utils.Base64Decode (data) | Decode base 64 string
Lua 5.1+ base64 v3.0 (c) 2009 by Alex Kloss |
| Musician.Utils.Debug (module, ...) | Print debug stuff in the console |
| Musician.Utils.DeepCopy (orig) | Deep copy a table http://lua-users.org/wiki/CopyTable |
| Musician.Utils.DeepMerge (merged, orig) | Deep merge two tables |
| Musician.Utils.DisplayEmote (player, playerGUID, message) | Display a faked emote |
| Musician.Utils.EasyMenu (menuList, menuFrame, anchor, x, y, displayMode, autoHideDelay) | Blizzard's EasyMenu using MSA_DropDownMenu |
| Musician.Utils.EasyMenu_Initialize (frame, level, menuList) | Blizzard's EasyMenu_Initialize using MSA_DropDownMenu |
| Musician.Utils.Error (msg) | Display an error message in a popup |
| Musician.Utils.FlipTable (orig) | Flip a table |
| Musician.Utils.ForEach (list, func) | Call function for each item of the provided table |
| Musician.Utils.FormatPlayerName (player) | Get player name for display |
| Musician.Utils.FormatText (text) | Format text, adding highlights etc. |
| Musician.Utils.FormatTime (time, simple) | Format time to mm:ss.ss format |
| Musician.Utils.FromHex (hex) | Convert hex string to string |
| Musician.Utils.GetByteReader (data, err) | Return a byte reader function for provided data string |
| Musician.Utils.GetChatIcon (path[, r=0[, g=0[, b=0]]]) | Return the code to insert an icon in a chat message or a text string |
| Musician.Utils.GetColorCode (r, g, b) | Get color code from RGB values |
| Musician.Utils.GetLink (command, text, ...) | Get hyperlink |
| Musician.Utils.GetNormalizedRealmName () | Return the normalized realm name the player belongs to Safer than the standard GetNormalizedRealmName() that may return nil sometimes |
| Musician.Utils.GetOs () | Return operating system name |
| Musician.Utils.GetPlayerLink (player) | Get player hyperlink |
| Musician.Utils.GetPromoEmote () | Return the "Player is playing music" emote with promo message |
| Musician.Utils.GetRealmLocale () | Return the short locale code of the realm the player belongs to |
| Musician.Utils.GetVersionText () | Return the current version as text for the end user |
| Musician.Utils.HasPromoEmote (message) | Return true if the message contains the promo emote, in any language |
| Musician.Utils.Highlight (text, color) | Highlight text |
| Musician.Utils.MuteGameMusic (force) | Start or stop the actual game music if a song can actually be heard |
| Musician.Utils.NormalizePlayerName (playerName) | Return the normalized player name, including realm slug |
| Musician.Utils.OverrideNextFullPromoEmote () | Override the next full promo emote |
| Musician.Utils.PackNumber (num, bytes) | Pack an integer number into a string |
| Musician.Utils.PackPlayerGuid () | Pack player GUID into a 6-byte string |
| Musician.Utils.PackPlayerPosition () | Pack player position into a 18-byte chunk string |
| Musician.Utils.PackTime (seconds, bytes, fps) | Pack a time or duration in seconds into a string |
| Musician.Utils.PaddingZeros (number, zeros) | Add padding zeros |
| Musician.Utils.ParseTime (timestamp) | Parse time in seconds from mm:ss.ss format |
| Musician.Utils.PlayerGuidIsVisible (guid) | Return true if the player whose GUID is provided is visible (loaded) by the game client |
| Musician.Utils.PlayerIsInGroup (playerName) | Return true if the player is in my party or raid |
| Musician.Utils.PlayerIsMyself (playerName) | Return true if the provided player name is myself |
| Musician.Utils.PlayerIsOnSameRealm (playerName) | Return true if the provided player name is on the same realm or connected realm as me |
| Musician.Utils.PlayerRealm (playerName) | Return the player realm slug |
| Musician.Utils.Popup (msg, callback, force) | Display a message in a popup |
| Musician.Utils.Print (msg) | Display a message in the console |
| Musician.Utils.PrintError (msg) | Display an error message in the console |
| Musician.Utils.ReadBytes (str, bytes) | Read some bytes from a string and remove them |
| Musician.Utils.RemoveChatMessage (lineID) | Remove a chat message by its line ID |
| Musician.Utils.ResetFullPromoEmoteCooldown () | Mark the full promo emote as recently seen |
| Musician.Utils.SendPromoEmote () | Send the "Player is playing music" emote with promo message |
| Musician.Utils.SetFontStringTextFixedSize (fontString, text) | Set text to a FontString element ensuring the visual text size is respected |
| Musician.Utils.ShallowCopy (orig) | Shallow copy a table http://lua-users.org/wiki/CopyTable |
| Musician.Utils.SimplePlayerName (playerName) | Return the simple player name, including the realm slug if needed |
| Musician.Utils.SongIsPlaying () | Return true if a song is actually playing and is audible |
| Musician.Utils.ToHex (str) | Convert string to hex string |
| Musician.Utils.UnpackNumber (data) | Unpack a string into an integer number |
| Musician.Utils.UnpackPlayerGuid (str) | Unpack player GUID from string |
| Musician.Utils.UnpackPlayerPosition (str) | Unpack player position from chunk string |
| Musician.Utils.UnpackTime (data, fps) | Unpack a string into a time or duration in seconds |
| Musician.Utils.VersionCompare (versionA, versionB) | Compare two version numbers |
Functions
- Musician.Utils.Base64Decode (data)
-
Decode base 64 string
Lua 5.1+ base64 v3.0 (c) 2009 by Alex Kloss
licensed under the terms of the LGPL2 http://lua-users.org/wiki/BaseSixtyFour Parameters:
- data (string)
Returns:
-
str (string)
- Musician.Utils.Debug (module, ...)
-
Print debug stuff in the console
Parameters:
- module (string)
- ... (string)
- Musician.Utils.DeepCopy (orig)
-
Deep copy a table
http://lua-users.org/wiki/CopyTable
Parameters:
- orig (table)
Returns:
-
copy (table)
- Musician.Utils.DeepMerge (merged, orig)
-
Deep merge two tables
Parameters:
- merged (table)
- orig (table)
Returns:
-
merged (table)
- Musician.Utils.DisplayEmote (player, playerGUID, message)
-
Display a faked emote
Parameters:
- player (string)
- playerGUID (string)
- message (string)
- Musician.Utils.EasyMenu (menuList, menuFrame, anchor, x, y, displayMode, autoHideDelay)
-
Blizzard's EasyMenu using MSA_DropDownMenu
Parameters:
- menuList
- menuFrame
- anchor
- x
- y
- displayMode
- autoHideDelay
- Musician.Utils.EasyMenu_Initialize (frame, level, menuList)
-
Blizzard's EasyMenu_Initialize using MSA_DropDownMenu
Parameters:
- frame
- level
- menuList
- Musician.Utils.Error (msg)
-
Display an error message in a popup
Parameters:
- msg (string)
- Musician.Utils.FlipTable (orig)
-
Flip a table
Parameters:
- orig (table)
Returns:
-
flipped (table)
- Musician.Utils.ForEach (list, func)
-
Call function for each item of the provided table
Parameters:
- list (table)
- func (function) Takes 3 arguments: value, key and the provided table.
- Musician.Utils.FormatPlayerName (player)
-
Get player name for display
Parameters:
- player (string)
Returns:
-
formattedPlayerName (string)
- Musician.Utils.FormatText (text)
-
Format text, adding highlights etc.
Parameters:
- text (string)
Returns:
-
formattedText (string)
- Musician.Utils.FormatTime (time, simple)
-
Format time to mm:ss.ss format
Parameters:
- time (number)
- simple (boolean)
Returns:
-
formattedTime (string)
- Musician.Utils.FromHex (hex)
-
Convert hex string to string
Parameters:
- hex (string)
Returns:
-
str (string)
- Musician.Utils.GetByteReader (data, err)
-
Return a byte reader function for provided data string
Parameters:
- data (string)
- err (string) Error to be returned in case of reading error
Returns:
-
readBytes (function)
- Musician.Utils.GetChatIcon (path[, r=0[, g=0[, b=0]]])
-
Return the code to insert an icon in a chat message or a text string
Parameters:
- path (string)
- r (number) 0-1 (default 0)
- g (number) 0-1 (default 0)
- b (number) 0-1 (default 0)
Returns:
-
chatIcon (string)
- Musician.Utils.GetColorCode (r, g, b)
-
Get color code from RGB values
Parameters:
- r (number) 0-1
- g (number) 0-1
- b (number) 0-1
Returns:
-
colorCode (string)
- Musician.Utils.GetLink (command, text, ...)
-
Get hyperlink
Parameters:
- command (string)
- text (string)
- ... (string)
Returns:
-
link (string)
- Musician.Utils.GetNormalizedRealmName ()
-
Return the normalized realm name the player belongs to
Safer than the standard GetNormalizedRealmName() that may return nil sometimes
Returns:
-
realmName (string)
- Musician.Utils.GetOs ()
-
Return operating system name
Returns:
-
os (string)
- Musician.Utils.GetPlayerLink (player)
-
Get player hyperlink
Parameters:
- player (string)
Returns:
-
playerLink (string)
- Musician.Utils.GetPromoEmote ()
-
Return the "Player is playing music" emote with promo message
Returns:
-
promoEmote (string)
- Musician.Utils.GetRealmLocale ()
-
Return the short locale code of the realm the player belongs to
Returns:
-
locale (string) 'en', 'fr' etc.
- Musician.Utils.GetVersionText ()
-
Return the current version as text for the end user
Returns:
-
version (string)
- Musician.Utils.HasPromoEmote (message)
-
Return true if the message contains the promo emote, in any language
Parameters:
- message (string)
Returns:
- hasPromoEmote (boolean)
- isFullPromoEmote (boolean) true if the emote contains the part invinting other players to install Musician
- Musician.Utils.Highlight (text, color)
-
Highlight text
Parameters:
- text (string)
- color (string|Color)
Returns:
-
highlightedText (string)
- Musician.Utils.MuteGameMusic (force)
-
Start or stop the actual game music if a song can actually be heard
Parameters:
- force (boolean)
- Musician.Utils.NormalizePlayerName (playerName)
-
Return the normalized player name, including realm slug
Parameters:
- playerName (string)
Returns:
-
normalizedPlayerName (string)
- Musician.Utils.OverrideNextFullPromoEmote ()
- Override the next full promo emote
- Musician.Utils.PackNumber (num, bytes)
-
Pack an integer number into a string
Parameters:
- num (int) integer to pack
- bytes (int) number of bytes
Returns:
-
data (string)
- Musician.Utils.PackPlayerGuid ()
-
Pack player GUID into a 6-byte string
Returns:
-
data (string)
- Musician.Utils.PackPlayerPosition ()
-
Pack player position into a 18-byte chunk string
Returns:
-
data (string)
- Musician.Utils.PackTime (seconds, bytes, fps)
-
Pack a time or duration in seconds into a string
Parameters:
- seconds (float)
- bytes (int) Number of bytes
- fps (float) Precision in frames par second
Returns:
-
data (string)
- Musician.Utils.PaddingZeros (number, zeros)
-
Add padding zeros
Parameters:
- number (int)
- zeros (int)
Returns:
-
formattedNumber (string)
- Musician.Utils.ParseTime (timestamp)
-
Parse time in seconds from mm:ss.ss format
Parameters:
- timestamp (string)
Returns:
-
seconds (number)
- Musician.Utils.PlayerGuidIsVisible (guid)
-
Return true if the player whose GUID is provided is visible (loaded) by the game client
Parameters:
- guid (string)
Returns:
-
isVisible (boolean)
- Musician.Utils.PlayerIsInGroup (playerName)
-
Return true if the player is in my party or raid
Parameters:
- playerName (string)
Returns:
-
isInMyGroup (boolean)
- Musician.Utils.PlayerIsMyself (playerName)
-
Return true if the provided player name is myself
Parameters:
- playerName (string)
Returns:
-
isMyself (boolean)
- Musician.Utils.PlayerIsOnSameRealm (playerName)
-
Return true if the provided player name is on the same realm or connected realm as me
Parameters:
- playerName (string)
Returns:
-
isOnSameRealm (boolean)
- Musician.Utils.PlayerRealm (playerName)
-
Return the player realm slug
Parameters:
- playerName (string)
Returns:
-
realmSlug (string)
- Musician.Utils.Popup (msg, callback, force)
-
Display a message in a popup
Parameters:
- msg (string)
- callback (function)
- force (boolean)
- Musician.Utils.Print (msg)
-
Display a message in the console
Parameters:
- msg (string)
- Musician.Utils.PrintError (msg)
-
Display an error message in the console
Parameters:
- msg (string)
- Musician.Utils.ReadBytes (str, bytes)
-
Read some bytes from a string and remove them
Parameters:
- str (string)
- bytes (int)
Returns:
- data (string) read bytes
- str (string) new string
- Musician.Utils.RemoveChatMessage (lineID)
-
Remove a chat message by its line ID
Parameters:
- lineID (int)
- Musician.Utils.ResetFullPromoEmoteCooldown ()
- Mark the full promo emote as recently seen
- Musician.Utils.SendPromoEmote ()
- Send the "Player is playing music" emote with promo message
- Musician.Utils.SetFontStringTextFixedSize (fontString, text)
-
Set text to a FontString element ensuring the visual text size is respected
Parameters:
- fontString (FontString)
- text (string)
- Musician.Utils.ShallowCopy (orig)
-
Shallow copy a table
http://lua-users.org/wiki/CopyTable
Parameters:
- orig (table)
Returns:
-
copy (table)
- Musician.Utils.SimplePlayerName (playerName)
-
Return the simple player name, including the realm slug if needed
Parameters:
- playerName (string)
Returns:
-
simpleName (string)
- Musician.Utils.SongIsPlaying ()
-
Return true if a song is actually playing and is audible
Returns:
-
isPlaying (boolean)
- Musician.Utils.ToHex (str)
-
Convert string to hex string
Parameters:
- str (string)
Returns:
-
hex (string)
- Musician.Utils.UnpackNumber (data)
-
Unpack a string into an integer number
Parameters:
- data (string)
Returns:
-
num (int)
- Musician.Utils.UnpackPlayerGuid (str)
-
Unpack player GUID from string
Parameters:
- str (string)
Returns:
-
guid (string)
- Musician.Utils.UnpackPlayerPosition (str)
-
Unpack player position from chunk string
Parameters:
- str (string)
Returns:
- posY (number)
- posX (number)
- posZ (number)
- instanceID (int)
- guid (string)
- Musician.Utils.UnpackTime (data, fps)
-
Unpack a string into a time or duration in seconds
Parameters:
- data (string)
- fps (float) Precision in frames par second
Returns:
-
seconds (float)
- Musician.Utils.VersionCompare (versionA, versionB)
-
Compare two version numbers
Parameters:
- versionA (string)
- versionB (string)
Returns:
-
difference (number) 0 if A = B, 1 if A > B, -1 if A < B