Quantcast

Slash commands

Scott King [07-04-15 - 06:22]
Slash commands

- added toggles for health display and sound
- added instructions for use
- added SavedVariables for use across game sessions
Filename
PortraitHealth.lua
diff --git a/PortraitHealth.lua b/PortraitHealth.lua
index 47efa33..ad4e6cf 100755
--- a/PortraitHealth.lua
+++ b/PortraitHealth.lua
@@ -48,86 +48,59 @@ function PH_SlashCommandHandler( msg, class )
 	local className = PlayerClassName;
 	local x = RAID_CLASS_COLORS[PlayerClassNameIndex];

--- New simplified commands (toggles)
+-- show commands
+if msg == '' then
+  DEFAULT_CHAT_FRAME:AddMessage( "|cffffff00Portrait Health "..PH_v.."|r commands:");
+  DEFAULT_CHAT_FRAME:AddMessage( "Usage: |cff00aaff/ph <command>|r.");
+  DEFAULT_CHAT_FRAME:AddMessage(" - |cff00aaffshow|r to toggle health display.");
+  DEFAULT_CHAT_FRAME:AddMessage(" - |cff00aaffsound|r to toggle sound at execute phase.");
+  DEFAULT_CHAT_FRAME:AddMessage(" - |cff00aaffinfo|r to show current settings.");
+end

--- should we display health
+-- health display toggle
 if msg == 'show' then
   if PH_on == 1 then
     PortraitHealth:Hide();
     PH_on = 0;
-    DEFAULT_CHAT_FRAME:AddMessage("Portrait Health display diabled.")
+    DEFAULT_CHAT_FRAME:AddMessage("Portrait Health |cff00aaffdisplay disabled|r.")
   elseif PH_on == 0 then
     PortraitHealth:Show();
     PH_on = 1;
-    DEFAULT_CHAT_FRAME:AddMessage("Portrait Health display enabled.");
+    DEFAULT_CHAT_FRAME:AddMessage("Portrait Health |cff00aaffdisplay enabled|r.");
   end
 end

--- should we play sound
+-- sound toggle
 if msg == 'sound' then
   if PH_sound == 1 then
     PH_sound = 0;
-    DEFAULT_CHAT_FRAME:AddMessage("Portrait Health sound disabled.");
+    DEFAULT_CHAT_FRAME:AddMessage("Portrait Health |cff00aaffsound disabled|r.");
   elseif PH_sound == 0 then
     PH_sound = 1;
-    DEFAULT_CHAT_FRAME:AddMessage("Portrait Health sound enabled.");
+    DEFAULT_CHAT_FRAME:AddMessage("Portrait Health |cff00aaffsound enabled|r.");
   end
 end

--- show commands
-if msg == '' then
-  DEFAULT_CHAT_FRAME:AddMessage("/ph show to toggle health display.");
-  DEFAULT_CHAT_FRAME:AddMessage("/ph sound to toggle sound at execute phase.");
-  DEFAULT_CHAT_FRAME:AddMessage("/ph info to show current settings.");
-end
-
--- show current settings (note to self: add in display and sound settings)
-if msg = 'info' then
+-- show current settings
+if 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\)");
-end

--- Old commands
-
---		-- turn off the health display
---	if msg == 'off' then
---    PortraitHealth:Hide();
---		PH_on = 0;
---		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();
---			PH_on = 1;
---			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\)");
---
---    -- sound on
---    elseif msg == 'sound on' then
---      DEFAULT_CHAT_FRAME:AddMessage("Sound enabled.");
---      PH_sound = 1;
---
---    -- sound off
---    elseif msg == 'sound off' then
---      DEFAULT_CHAT_FRAME:AddMessage("Sound disabled.");
---      PH_sound = 0;
---
---		-- display list of available commands
---		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( " - |cff00aaffsound off|r to disable execute sound notifier.");
---      DEFAULT_CHAT_FRAME:AddMessage( " - |cff00aaffsound on|r to enable execute sound notifier.");
---			DEFAULT_CHAT_FRAME:AddMessage( " - |cff00aaffinfo|r for information about your current settings.");
---	end
+  if PH_on == 1 then
+    DEFAULT_CHAT_FRAME:AddMessage("Health display is |cff00aaffon|r.");
+  else
+    DEFAULT_CHAT_FRAME:AddMessage("Health display is |cff00aaffoff|r.");
+  end
+
+  if PH_sound == 1 then
+    DEFAULT_CHAT_FRAME:AddMessage("Sound is |cff00aaffon|r.");
+  else
+    DEFAULT_CHAT_FRAME:AddMessage("Sound is |cff00aaffoff|r.");
+  end
+end
 end

+-- health display set by user prefs
 function PH_display()
   if PH_on == 0 then
     PortraitHealth:Hide();