vanilla-wow-addons – Rev 1

Subversion Repositories:
Rev:
<Ui xmlns="http://www.blizzard.com/wow/ui/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://www.blizzard.com/wow/ui/ ..\..\FrameXML\UI.xsd">
        <Frame name="StatRingsPetHealth" parent="UIParent" inherits="StatRingsRingTemplate">
                <Anchors>
                        <Anchor point="TOPLEFT" relativeTo="StatRingsHealth" relativePoint="TOPLEFT">
                                <Offset>
                                        <AbsDimension x="15" y="0"/>
                                </Offset>
                        </Anchor>
                </Anchors>
                <Scripts>
                        <OnLoad>
                                StatRings_RegisterRing(this, "Pet Health");
                                
                        StatRingsRingTemplate_OnLoad();
                        this.isInCombat = false;
                                this:SetAlpha(0.1);

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

                                this:UpdateColor({["r"] = 1, ["g"] = 0.5, ["b"] = 0});
                                if not UnitExists("pet") then
                                        this:SetMax(100);
                                        this:SetValue(0);
                                else 
                                        this:SetMax(UnitHealthMax("pet"));
                                        this:SetValue(UnitHealth("pet"), UnitHealthMax("pet"));
                                end


                                function this:UpdateAlpha()
                                        --if not getglobal(this:GetName().."MoveAnchor"):IsVisible() then
                                                if this.isInCombat then
                                                        StatRingsTest_SetAlpha(self, 0.5);
                                                elseif this.startValue &lt; this.maxValue then
                                                        StatRingsTest_SetAlpha(self, 0.5);
                                                elseif not this.isInCombat then
                                                        StatRingsTest_SetAlpha(self, 0.1);
                                                end
                                        --end
                                end
                                this:AddUpdateFunction(this.UpdateAlpha);
                        </OnLoad>
                        <OnEvent>
                                if (event == "UNIT_PET") then
                                        if (arg1 == "player") then
                                                if not UnitExists("pet") then
                                                        this:SetMax(100);
                                                        this:SetValue(0);
                                                else 
                                                        this:SetMax(UnitHealthMax("pet"));
                                                        this:SetValue(UnitHealth("pet"));
                                                end
                                                return;
                                        end
                                end

                                if (event == "PLAYER_ENTERING_WORLD") then
                                        this:UpdateColor({["r"] = 1, ["g"] = 0.5, ["b"] = 0});
                                        if not UnitExists("pet") then
                                                this:SetMax(100);
                                                this:SetValue(0);
                                        else 
                                                this:SetMax(UnitHealthMax("pet"));
                                                this:SetValue(UnitHealth("pet"));
                                        end
                                        return;
                                elseif event == "PLAYER_ENTER_COMBAT" or event == "PLAYER_REGEN_DISABLED" then
                                        this.isInCombat = true;
                                        this.alphaState = -1;
                                elseif event == "PLAYER_LEAVE_COMBAT" or event == "PLAYER_REGEN_ENABLED" then
                                        this.isInCombat = false;
                                        this.alphaState = -1;
                                elseif event == "PLAYER_LEVEL_UP" then
                                        this:SetMax(UnitHealthMax("pet"));
                                end
                                if (arg1 == "pet") then
                                        if (event == "UNIT_MAXHEALTH") then
                                                this:SetMax(UnitHealthMax("pet"));
                                        else
                                                this:SetValue(UnitHealth("pet"));
                                        end
                                end
                        </OnEvent>
                </Scripts>
        </Frame>
</Ui>

Generated by GNU Enscript 1.6.5.90.