Added slash commands for new options (sound and display toggle)
Scott King [07-03-15 - 06:15]
Added slash commands for new options (sound and display toggle)
diff --git a/PortraitHealth.lua b/PortraitHealth.lua
index 2338fc6..223164d 100755
--- a/PortraitHealth.lua
+++ b/PortraitHealth.lua
@@ -5,9 +5,19 @@ PlayerClass = classID;
PlayerClassName = classDisplayName;
PlayerClassNameIndex = class;
PH_v = '3.0'; -- version number
-limit1 = 0;
+limit1 = 0; -- limiter for sounds
executeSound = "Sound\\interface\\AuctionWindowClose.ogg";
-PH_sound = 0;
+
+-- check for sound enabled
+if PH_sound == nil then
+ PH_sound = 0;
+end
+
+-- check for display enabled
+if PH_on == nil then
+ PH_on = 1;
+end
+
PH_p = {} -- Class: ID:
PH_p[1] = 20 -- Warrior 1
@@ -40,12 +50,14 @@ function PH_SlashCommandHandler( msg, class )
-- turn off the health display
if msg == 'off' then
- PortraitHealth:Hide();
+ 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();
+ PortraitHealth:Show();
+ PH_on = 1;
DEFAULT_CHAT_FRAME:AddMessage("Portrait Health enabled.");
-- show the current setup
@@ -73,9 +85,13 @@ function PH_SlashCommandHandler( msg, class )
end
end
---function PHChanged_OnLoad()
--- this:RegisterEvent("PLAYER_TARGET_CHANGED");
---end
+function PH_display()
+ if PH_on == 0 then
+ PortraitHealth:Hide();
+ else
+ PortraitHealth:Show();
+ end
+end
-- Set the text color and update health output
function HealthPercentage(event)
diff --git a/PortraitHealth.toc b/PortraitHealth.toc
index aacd313..7a8338b 100755
--- a/PortraitHealth.toc
+++ b/PortraitHealth.toc
@@ -3,5 +3,6 @@
## Notes: See your target's health percentage in bold text over their portrait.
## Author: Cilcraft
## Version: 3.0.0
+##SavedVariablesPerCharacter: PH_sound, PH_on
PortraitHealth.lua
PortraitHealth.xml
diff --git a/PortraitHealth.xml b/PortraitHealth.xml
index 75abf81..60e26cb 100755
--- a/PortraitHealth.xml
+++ b/PortraitHealth.xml
@@ -37,6 +37,7 @@
</OnLoad>
<OnEvent>
HealthPercentage(event);
+ PH_display();
</OnEvent>
</Scripts>
</Frame>