Thread Tools Display Modes
01-12-06, 08:26 AM   #1
Meadowlark
A Murloc Raider
Join Date: Jan 2006
Posts: 8
Hiding Textures with Events or Key Bindings?

OK, I've got a nice HUD working through DArt.

http://www.markusinger.de/wow/drathals_hud.html

The only thing is, I would like it to disappear when the bars are full. Can these textures be hidden with some kind of event that tells it when health and mana are 100%, or can I tie all of the textures to a key that when pressed will toggle them to hide?

Thanks! I'm almost done!
  Reply With Quote
01-12-06, 08:55 AM   #2
Lozareth
An Onyxian Warder
 
Lozareth's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2005
Posts: 366
Technically you can do both but I'll only explain the first since that seems to be what you want.

Hide at max health:

OnLoad:
this:RegisterEvent("UNIT_HEALTH");

OnEvent:
if UnitHealth("player") == UnitHealthMax("player") then
DART_Hide(ti);
else
DART_Show(ti);
end

Hide at max mana:

OnLoad:
this:RegisterEvent("UNIT_RAGE");
this:RegisterEvent("UNIT_MANA");
this:RegisterEvent("UNIT_ENERGY");
this:RegisterEvent("UNIT_FOCUS");

OnEvent:
if UnitMana("player") == UnitManaMax("player") then
DART_Hide(ti);
else
DART_Show(ti);
end
__________________
High Pope of the Divine Chihuahua
http://www.discordmods.com
  Reply With Quote
01-12-06, 01:43 PM   #3
Meadowlark
A Murloc Raider
Join Date: Jan 2006
Posts: 8
Talking

Beautiful. Thanks, Lozareth.
  Reply With Quote
01-13-06, 03:19 AM   #4
Coldshiver
A Murloc Raider
Join Date: Jan 2006
Posts: 8
Originally Posted by Lozareth

Hide at max health:

OnLoad:
this:RegisterEvent("UNIT_HEALTH");

OnEvent:
if UnitHealth("player") == UnitHealthMax("player") then
DART_Hide(ti);
else
DART_Show(ti);
end

Hide at max mana:

OnLoad:
this:RegisterEvent("UNIT_RAGE");
this:RegisterEvent("UNIT_MANA");
this:RegisterEvent("UNIT_ENERGY");
this:RegisterEvent("UNIT_FOCUS");

OnEvent:
if UnitMana("player") == UnitManaMax("player") then
DART_Hide(ti);
else
DART_Show(ti);
end
Hey Lozareth? I'm trying to accomplish the same feat, however it's not working.

3 Questions which may point to my problem.

A) Do I replace Drathal's current scripting with the above, or do I add it in addition to the current scripting.

B) If I add it in addition to, does its placement matter?

C) Do I add a second "OnLoad:this:RegisterEvent("UNIT_HEALTH");" (example, I don't use quotes in the script) to the onload script area, or is the one already there sufficient?
  Reply With Quote
01-13-06, 06:53 AM   #5
Meadowlark
A Murloc Raider
Join Date: Jan 2006
Posts: 8
Originally Posted by Coldshiver
Hey Lozareth? I'm trying to accomplish the same feat, however it's not working.

3 Questions which may point to my problem.

A) Do I replace Drathal's current scripting with the above, or do I add it in addition to the current scripting.

B) If I add it in addition to, does its placement matter?

C) Do I add a second "OnLoad:this:RegisterEvent("UNIT_HEALTH");" (example, I don't use quotes in the script) to the onload script area, or is the one already there sufficient?
I don't want to speak for Lozareth, but I think the following is a good answer:

Don't overwrite or delete any of Drathal's script. Plus, you don't need to add lines into the script that are already there. And, when not there already, I put Loz's code into the top of the script field, above Drathal's stuff - although I have no idea if it matters. I did it this way and it's working as I hoped (When player's health and/or mana reaches 100%, the bars disappear).

I did the same for the borders to make them also disappear as they are part of a different texture.
  Reply With Quote
01-13-06, 07:39 AM   #6
Lozareth
An Onyxian Warder
 
Lozareth's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2005
Posts: 366
The placement depends on the existing scripts though more often than not it won't matter. You only need to register an event once though registering it more than once won't cause issues.
__________________
High Pope of the Divine Chihuahua
http://www.discordmods.com
  Reply With Quote
01-13-06, 01:59 PM   #7
Coldshiver
A Murloc Raider
Join Date: Jan 2006
Posts: 8
Well, I am not sure what I am breaking, but I am definitely breaking something lol. When I add in the hide/show at health max script from the previous postings, I am getting the following error:

[string "function DART_Texture13_Script_OnLoad(param..."]:23: attempt to call global 'Get_HColor' (a nil value)

Here's what I have done to the current code. I will italicize my additions so that my changes vs those of Drathal's original scripting are clear. Perhaps you can figure out what's causing this error, cause I'm stumped.

On Event:

if UnitHealth("player") == UnitHealthMax("player") then
DART_Hide(ti);
else
DART_Show(ti);
end


-- alpha
if DL_INCOMBAT then
DART_Alpha(ti, this.icalpha);
else
DART_Alpha(ti, this.oocalpha);
end

if arg1 == this.unit then

if UnitHealthMax(this.unit) == 0 then
return;
end

this.ph_p = UnitHealth(this.unit)/UnitHealthMax(this.unit);
local p = this.ph_p;

DART_Text(ti, math.floor( p * 100).."%");

-- flashing
if p <= .3 then
DART_StartFlashing(ti);
else
DART_StopFlashing(ti);
end

end

On Load:

this:RegisterEvent("UNIT_HEALTH");
this:RegisterEvent("PLAYER_ENTERING_WORLD");
this:RegisterEvent("PLAYER_ENTER_COMBAT");
this:RegisterEvent("PLAYER_LEAVE_COMBAT");
this:RegisterEvent("PLAYER_REGEN_ENABLED");
this:RegisterEvent("PLAYER_REGEN_DISABLED");

this.oocalpha = .2;
this.icalpha = .8;

this.step = 0.005;
this.stepfast = 0.02;

DART_Alpha(ti, this.oocalpha);

this.ph_p = 1;
this.ph_pm = 1;
this.unit = "player";

this:EnableMouseWheel();

local r, g, b = Get_HColor(1 ,"h" );
DART_Color(ti, r, g, b, DART_Settings[DART_INDEX][ti].alpha);

On Update:

local pp = math.floor(this.ph_p * 100);
local pm = math.floor(this.ph_pm * 100);

if pp < pm then
this.pc = 1;

if pm - pp > 10 then
this.ph_pm = this.ph_pm - this.stepfast;
else
this.ph_pm = this.ph_pm - this.step;
end

elseif pp > pm then
this.pc = 1;

if pp - pm > 10 then
this.ph_pm = this.ph_pm + this.stepfast;
else
this.ph_pm = this.ph_pm + this.step;
end

end

if this.pc == 1 then
this.pc = 0;
local p = this.ph_pm
local h = 256 * p;
local t = "Interface\\AddOns\\DiscordArt\\CustomTextures\\Player_HP";
local h = h + ((1-p) *10 );

DART_Height(ti, h);
DART_Texture(ti, t, {0,1,1-p,1});

local r, g, b = Get_HColor(p ,"h" );
DART_Color(ti, r, g, b, DART_Settings[DART_INDEX][ti].alpha);

end

Basically as best as I can figure out, the original code changes the alpha during in/out of combat situations, which is fine. But I'd like the HUD to hide this bar when I am at full health, and once in combat bring it up to the above listed alpha level (.2 if I am at full health, and .8 once I begin taking damage).

I am wondering if perhaps the in combat alpha scripting is conflicting with the hide/show when healthmax scripting? Either that or maybe it requires placement in another spot or merely some better coding?
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » Released AddOns » Hiding Textures with Events or Key Bindings?


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off