From d56fa6b41fa0ec290e175f16f322b6ad733dec2c Mon Sep 17 00:00:00 2001 From: Scott King Date: Fri, 3 Jul 2015 00:15:08 -0600 Subject: [PATCH] Added slash commands for new options (sound and display toggle) --- PortraitHealth.lua | 30 +++++++++++++++++++++++------- PortraitHealth.toc | 1 + PortraitHealth.xml | 1 + 3 files changed, 25 insertions(+), 7 deletions(-) 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 @@ HealthPercentage(event); + PH_display(); -- 1.7.9.5