WoW:Satellite (AddOn)

From AddOn Studio
Jump to navigation Jump to search
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[edit]

  • 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[edit]

  • /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[edit]

Minimal Required Example[edit]

Satellite.registerSlashCommand(
	{
		id="TELL_TRACK";
		commands = { "/telltrack","/ttrack" };
		onExecute = function(msg) ... end;
	}
);

Maximum Usage[edit]

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[edit]

Syntax[edit]

{
	-- 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[edit]

  • 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)

Optional Members[edit]

  • 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)
  • 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)
  • helpText - a string explaining what the command does

ChatType Members[edit]

  • 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)
  • onVisibleChange
    args:
    frameID - (1-7) chat frame that visibility has been modified on
    isVisible - boolean value for if the chatType is visible or not

Emulate Chat Messages[edit]

Syntax[edit]

Satellite.GenerateChatEvent( chatType, msg );

Result[edit]

  • 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[edit]

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[edit]

ChatType Headers[edit]

File:PrintHeaders.jpg

Extra ChatTypes in the "Other Messages" Menu[edit]

File:ExtraChatTypes.jpg

Change log[edit]

v1.8b[edit]

  1. Updated embedded libs

v1.8[edit]

  1. Prepared for Lua 5.1
  2. Commented out /print and /printc slash command examples (simpler versions are in SeaPrint now)

v1.71[edit]

  1. Unhooking, if it wasn't hooked in the first place, is dissabled

v1.7[edit]

  1. 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.
  2. Hooks now unhook before hooking so that when embedding multiple hooks do not exist simultainiously.
  3. 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[edit]

1.61
  1. Fixed a validation bug
1.6
  1. Slash command 'header' can now be a table of headers corresponding to individual commands
  2. 'sticky' now correctly evaluates to '0' if false
  3. Added 'hideMenuOption' boolean to allow chat type emulation without adding an option to the "Other Messages" menu of the Chat Tab Menu
  4. The 'script' chat type now used hideMenuOption
  5. Fixed a few typos that were causing nil errors
  6. 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.
  7. Fixed validateSlashMember to fully evaluate now.
  8. onExecute, onTab and onSpace callbacks now pass a second argument: the specific command used
1.5
  1. Added onVisibleChange for chatTypes to call a callback when AddChatWindowMessages or RemoveChatWindowMessages is called on it.
  2. Fixed visibility bug that was causing chatTypes to be visible in all chat frames after relog
1.42
  1. Fixed a bug that caused chat types not to be vissible after relogging.
1.41
  1. Added VARIABLES_LOADED to ADDON_LOADED for embedding
1.4
  1. Reregistering with replace=true correctly updates the chatType
  2. Default frame visibility are now correctly implemented
  3. Removed the GetChatWindowMessages hook in favor of using ChatFrame_AddMessageGroup on event
  4. Fixed a nil error in the ChangeChatColor hook
  5. Added Satellite.IsChatTypeVisible(chatTypeGroup, chatFrame)
  6. Satellite.GenerateChatEvent(chatType, text) now accepts any CHAT_MSG event chat type and not just Satellite commands. ex: SYSTEM
  7. Fixed a debug error when 'this' is nil
  8. unregisterSlashCommand now removed the chat visibility. it is restored when you reregister

1.3 and lower[edit]

1.3
  1. Removed localization strings from the main lua file, oops.
1.2
  1. Fixed bug with /script not workign on non-english clients
1.11
  1. Contains Embeddable SeaHooks and SeaPrint
  2. Fixed file name typo from Satelite to Satellite
  3. Fixed /z to be the first command, seen in /chathelp
1.1
  1. Embeddable
1.0
  1. Public Release