Slash commands
Scott King [06-30-15 - 06:40]
Slash commands
Added basic /cmd to the addon for hiding and showing the health output
and returning information about the addon to the chat window
diff --git a/PortraitHealth.lua b/PortraitHealth.lua
index 21f8f70..f141ff2 100755
--- a/PortraitHealth.lua
+++ b/PortraitHealth.lua
@@ -4,6 +4,7 @@ classDisplayName, class, classID = UnitClass("player");
PlayerClass = classID;
PlayerClassName = classDisplayName;
PlayerClassNameIndex = class;
+PH_v = '3.0'; -- version number
PH_p = {} -- Class: ID:
PH_p[1] = "20" -- Warrior 1
@@ -18,13 +19,33 @@ PH_p[9] = "25" -- Warlock 9
PH_p[10] = "10" -- Monk 10
PH_p[11] = "25" -- Druid 11
--- Slash Command: Disables the output
-function PH_SlashCommandHandler( msg )
- DEFAULT_CHAT_FRAME:AddMessage( "Command: " .. msg );
- if msg == 'hi' then
+-- Slash Commands
+function PH_SlashCommandHandler( msg, class )
+ local class = PlayerClass;
+ local className = PlayerClassName;
+ local x = RAID_CLASS_COLORS[PlayerClassNameIndex];
+
+ -- turn off the health display
+ if msg == 'off' then
PortraitHealth:Hide();
- else
- PortraitHealth:Show();
+ DEFAULT_CHAT_FRAME:AddMessage("Portrait Health disabled. Type |cFF00aaff/ph on|r to re-enable.");
+
+ -- turn on the health display
+ elseif msg == 'on' then
+ PortraitHealth:Show();
+ DEFAULT_CHAT_FRAME:AddMessage("Portrait Health enabled.");
+
+ -- show the current setup
+ elseif msg == 'info' then
+ DEFAULT_CHAT_FRAME:AddMessage("Addon version |cFFFFFF00" ..PH_v.. "|r");
+ DEFAULT_CHAT_FRAME:AddMessage("Execute at |cFFFF0000"..PH_p[class].."%|r \(|c"..x.colorStr..""..PlayerClassName.."|r\)");
+
+ elseif msg == '' then
+ DEFAULT_CHAT_FRAME:AddMessage( "|cffffff00Portrait Health "..PH_v.."|r commands:");
+ DEFAULT_CHAT_FRAME:AddMessage( "Type |cff00aaff/ph|r before the command. Ex: |cff00aaff/ph off|r disables the health display.");
+ DEFAULT_CHAT_FRAME:AddMessage( " - |cff00aaffoff|r to disable target health display.");
+ DEFAULT_CHAT_FRAME:AddMessage( " - |cff00aaffon|r to re-enable.");
+ DEFAULT_CHAT_FRAME:AddMessage( " - |cff00aaffinfo|r for information about your current settings.");
end
end
@@ -39,7 +60,7 @@ function DisplayClass(class)
local class = PlayerClass;
local className = PlayerClassName;
local x = RAID_CLASS_COLORS[PlayerClassNameIndex];
- DEFAULT_CHAT_FRAME:AddMessage("|cffffff9aPortrait Health|r loaded. Your class: |c"..x.colorStr..""..PlayerClassName.."|r.\nExecute phase set to |cFFFF0000"..PH_p[class].."%|r");
+ DEFAULT_CHAT_FRAME:AddMessage("|cffffff00Portrait Health "..PH_v.."|r loaded. Type |cff00aaff/ph|r for a list of commands.");
end
-- Set the text color and update health output