Quantcast

Simplified slash commands. Untested. Some orgres gonna die.

Scott King [07-03-15 - 17:47]
Simplified slash commands. Untested. Some orgres gonna die.
Filename
PortraitHealth.lua
diff --git a/PortraitHealth.lua b/PortraitHealth.lua
index 223164d..6f153e0 100755
--- a/PortraitHealth.lua
+++ b/PortraitHealth.lua
@@ -48,41 +48,82 @@ function PH_SlashCommandHandler( msg, class )
 	local className = PlayerClassName;
 	local x = RAID_CLASS_COLORS[PlayerClassNameIndex];

-		-- turn off the health display
-	if msg == 'off' then
+-- New simplified commands (toggles)
+
+-- should we display health
+if msg == 'show' then
+  if PH_on == 1 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\)");
-
-    elseif msg == 'sound on' then
-      DEFAULT_CHAT_FRAME:AddMessage("Sound enabled.");
-      PH_sound = 1;
-
-    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
+    PH_on = 0;
+    DEFAULT_CHAT_FRAME:AddMessage("Portrait Health display diabled.")
+  elseif PH_on == 0 then
+    PortraitHealth:Show();
+    PH_on = 1;
+    DEFAULT_CHAT_FRAME:AddMessage("Portrait Health display enabled.");
+  end
+end
+
+-- should we play sound
+if msg == 'sound' then
+  if PH_sound == 1 then
+    PH_sound = 0;
+    DEFAULT_CHAT_FRAME:AddMessage("Portrait Health sound disabled.");
+  elseif PH_sound == 0 then
+    PH_sound = 1;
+    DEFAULT_CHAT_FRAME:AddMessage("Portrait Health sound enabled.");
+  end
+end
+
+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
+
+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
 end

 function PH_display()