This Library have Functions to:
- display messages in the chat using LibChatMessage.
- animate Controls
- validate creations of Addons
Dependencies:
-
LibChatMessage - Print system messages
HOW TO USE:
Code:
## DependsOn: LibFsCommons>=3
Code:
--@Return instance with available functions
local Utils = LibFsCommons(LongAddonName, ShortAddonName)
--@Return String with format(|c color message |r)
Utils.Colorize(message, color)
--Prints the message in the chat
Utils.PrintMsg(message, tagColor)
--Prints the message in the chat in the color informed
Utils.PrintMsgColorize(message, textColor, tagColor)
--Prints the messages in the chat in the colors informed
--Ex.: Utils.PrintMsgColorizeAr({'first part', 'second part'},
--{'color of the first part','color of the second part'}, color)
Utils.PrintMsgColorizeAr(message, textColor, tagColor)
--Make an Animation
Utils.AnimateTextDefault(_control, duration)
-- compare the same property in two objects
Utils.PropObjEqual(_obj1, _obj2, prop)
--Test if there is another addon, or another version using the same global variable
--If there are problems return [your variable].fsAddonCreated = false
--The test utilize [your variable].version and [your variable].name to check if there are problems
Utils.CanCreateAddon(_IDENTIFIER, _NewConf)
--add a caracter(PadValue) in the left of the string(PadString) till the result reaches value specified(HowMany)
--Ex.: Utils.LeftPad('Test', 3, 'z') return zzzTest
Utils.LeftPad(PadString, HowMany, PadValue)
--convert the seconds to the format HH:MM:SS
--Ex.: Utils.SecondsToStr(4321) return 01:12:01
Utils.SecondsToStr(_Secs)
-- print messages using LibChatMessage(default) or normal chat
Utils.UseLibChatMessage(useLib)
-- print using short/long tag in the chat
-- Obs.: If using LibChatMessage this change will apply to all addons that uses LibChatMessage
Utils.UseShortTag(useShort)
-- return the value of the selected tag
Utils.GetTag()
-- Default Slash command function
Utils.SlashCommandFuncDef(slashCommands, slashCommandName, notFoundMsg, option)
-- print to the chat the slash commands in the list
Utils.DisplaySlashCommands(slashCommands, slashCommandName)
-- execute the function of an slash command
Utils.ExecuteSlashCommands(slashCommands, options, notFoundMsg)
-- print to the chat the slash command
Utils.GetSlashCommandsObj(obj, slashCommandName)
--Exemple of slashCommands object
YourAddon.slashCommands = {
[1] = {
str = "SI_YOURADDON_SLASH_COMMANDS_TITLE",
defColor = true
},
[2] = {
cmd = "show",
str = "SI_YOURADDON_SLASH_COMMANDS_SHOW",
compl = " this and that",
func = function (options)
YourAddon.ShowThisAndThat(options)
end
},}