WoW:Satellite (AddOn)
WoW AddOn Library Page
Satellite is a tool for slash command enhancement, and more. It makes Slash Command registration and management easy with simple table registration and advanced features like ChatType emulation, color and visibility management and sticky status.
Available from WoWInterface.
Features
- Register Slash Commands with a simple table format
- Optional ChatType support for enhanced features
- Add your slash command to the /chathelp printout
- Make your slash commands sticky
- Have the header change in the editbox after typing the /command
- Emulate incoming chat messages using your custom ChatType in the frames and color customizable by the player
- Save color and frame visibility across sessions on a per character basis
- Optional function handlers for onSpace, onTab, onColorChange and onVisibleChange
Built-in Slash Commands
- /print var - Print executed code. Short for /script Satellite.GenerateChatEvent('PRINT', table.concat( { msg } ) );
- /printComma var, var - Print multiple executed variables separated by ", ". Short for /script Sea.io.printComma(msg);
- /z - Execute code. Short for /script or /run
- (If you're using this addon as an embedded library feel free to comment out the registration of these commands)
Quick Start Example
Minimal Required Example
Satellite.registerSlashCommand( { id="TELL_TRACK"; commands = { "/telltrack","/ttrack" }; onExecute = function(msg) ... end; } );
Maximum Usage
Satellite.registerSlashCommand( { id = "PRINT"; commands = {"/print"}; onExecute = function(msg, cmd) RunScript('Satellite.GenerateChatEvent("PRINT", table.concat( {'..msg..'} ) )') end; header = "Print: "; printHeader = "[Print]: "; hideMenuOption = false; menuText = "Print"; helpText = "Print executed code. Short for /script Satellite.GenerateChatEvent('PRINT', table.concat( { msg } ) ); "; sticky = true; defaultColor = { r = 1.0, g = 1.0, b = 0.3 }; defaultFrames = { DEFAULT_CHAT_FRAME:GetID() }; onSpace = function(msg, cmd) ... end; onTab = function(msg, cmd) ... end; onColorChange = function(r, g, b) ... end; onVisibleChange = function(frameID, isVisible) ... end; } );
Slash Command Table Object
Syntax
{ -- Required members id = "IDENTIFIER"; commands = { "/command1", "/command2" }; onExecute = SomeFunction; -- Optional members onSpace = SomeFunction; onTab = SomeFunction; helpText = "This does something cool."; -- ChatType members -- Using any of the following options will make the slash command a full fledged Chat Type. -- Chat Types are shown in the Chat Tab menus and can have their color and visibility controlled by the player. -- You can send emulated messages as a ChatType (registered Satellite ID) using GenerateChatEvent. sticky = false; hideMenuOption = false; menuText = "Command"; header = "Command: "; printHeader = "[Command]: "; -- or { "header1 ", "header2 " }; defaultFrames = { 1, 2, 3 }; defaultColor = { r = 1.0, g = 1.0, b = 1.0 }; onColorChange = SomeFunction; onVisibleChange = SomeFunction; }
- -Satellite.registerSlashCommand allows you to pass multiple slash command table objects:
- Satellite.registerSlashCommand( { ... }, { ... } )
Required Members
- id - some unique ID (used in various variable generation and as the ChatType, all upper case)
- commands - a table of /commands to check for (all lower case)
- onExecute - a function which is called when the user runs the command
- args:
- msg - the chat message as typed into the editbox (excluding the "/command ")
- lastCommandUsed - the slash command as typed into the editbox (or last one used in the case of a sticky command)
- args:
Optional Members
- onSpace - a function called when a space bar is pressed
- args:
- msg - the chat message as currently seen in the editbox (excluding the "/command ")
- lastCommandUsed - the slash command as typed into the editbox (or last one used in the case of a sticky command)
- args:
- onTab - a function call when a tab key is pressed
- args:
- msg - the chat message as currently seen in the editbox (excluding the "/command ")
- lastCommandUsed - the slash command as typed into the editbox (or last one used in the case of a sticky command)
- args:
- helpText - a string explaining what the command does
- onSpace - a function called when a space bar is pressed
ChatType Members
- sticky - boolean value determining if the command should be sticky
- menuText - text seen in the "Other Messages" menu of the Chat Tab Menu (used to generate printHeader is absent)
- header - text or table of text seen in the left of the edit box after entering the slash command (defaults to commands[1])
- If in table form it should have the same amount of entries as the 'commands' table, implying direct relation.
- ex: If command 1 is used header 1 will be seen, etc.
- printHeader - text seen in the left of the chat frame message when using GenerateChatEvent
- defaultFrames - a table of the #'s of chat frames this ChatType will by visible in by default
- defaultColor - the default color table of this ChatType in the editbox and chat frame messages
- onColorChange - function called when the color is changed
- args:
- r - red value (0-1)
- g - green value (0-1)
- b - blue value (0-1)
- args:
- onVisibleChange
- args:
- frameID - (1-7) chat frame that visibility has been modified on
- isVisible - boolean value for if the chatType is visible or not
- args:
Emulate Chat Messages
Syntax
Satellite.GenerateChatEvent( chatType, msg );
Result
- An event "CHAT_MSG_"..chatType will be sent to the ChatFrame_OnEvent of each chat frame that chatType is visible in. arg1 will be the msg and all other args will be the empty string. This will print the msg prefixed with the printHeader (or "" if unspecified).
Embedding
To embed Satellite in your addon:
- 1) Drop the Satellite folder in your addon folder
- 2) Either add the following to your xml file:
<Include file="Satellite\Satellite.xml"/>
- Or add this line to your toc file:
Satellite\Satellite.xml
- 3) Add the following line to your toc:
SavedVariablesPerCharacter: Satellite_Config
Screen Shots
ChatType Headers
Extra ChatTypes in the "Other Messages" Menu
Change log
v1.8b
- Updated embedded libs
v1.8
- Prepared for Lua 5.1
- Commented out /print and /printc slash command examples (simpler versions are in SeaPrint now)
v1.71
- Unhooking, if it wasn't hooked in the first place, is dissabled
v1.7
- registerSlashCommand, unregisterSlashCommand and updateSlashCommand are now more robust in their handling of replacing and restoring slash commands with multiple aliases. It should store more or less aliases than the registered amount, restore them all when unregistering and make sure there aren't extras after updating.
- Hooks now unhook before hooking so that when embedding multiple hooks do not exist simultainiously.
- The ChatFrame_OnEvent hook now emulates the global 'event' variable for other addon hooks that happen to use it instead of the passed argument.
1.4 to 1.61
- 1.61
- Fixed a validation bug
- 1.6
- Slash command 'header' can now be a table of headers corresponding to individual commands
- 'sticky' now correctly evaluates to '0' if false
- Added 'hideMenuOption' boolean to allow chat type emulation without adding an option to the "Other Messages" menu of the Chat Tab Menu
- The 'script' chat type now used hideMenuOption
- Fixed a few typos that were causing nil errors
- Rewrote the updateSlashCommand function to properly evaluate (overwriting current user defined values) 'defaultColor' and 'defaultFrames'. It also now only updates values passed to the function.
- Fixed validateSlashMember to fully evaluate now.
- onExecute, onTab and onSpace callbacks now pass a second argument: the specific command used
- 1.5
- Added onVisibleChange for chatTypes to call a callback when AddChatWindowMessages or RemoveChatWindowMessages is called on it.
- Fixed visibility bug that was causing chatTypes to be visible in all chat frames after relog
- 1.42
- Fixed a bug that caused chat types not to be vissible after relogging.
- 1.41
- Added VARIABLES_LOADED to ADDON_LOADED for embedding
- 1.4
- Reregistering with replace=true correctly updates the chatType
- Default frame visibility are now correctly implemented
- Removed the GetChatWindowMessages hook in favor of using ChatFrame_AddMessageGroup on event
- Fixed a nil error in the ChangeChatColor hook
- Added Satellite.IsChatTypeVisible(chatTypeGroup, chatFrame)
- Satellite.GenerateChatEvent(chatType, text) now accepts any CHAT_MSG event chat type and not just Satellite commands. ex: SYSTEM
- Fixed a debug error when 'this' is nil
- unregisterSlashCommand now removed the chat visibility. it is restored when you reregister
1.3 and lower
- 1.3
- Removed localization strings from the main lua file, oops.
- 1.2
- Fixed bug with /script not workign on non-english clients
- 1.11
- Contains Embeddable SeaHooks and SeaPrint
- Fixed file name typo from Satelite to Satellite
- Fixed /z to be the first command, seen in /chathelp
- 1.1
- Embeddable
- 1.0
- Public Release