WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   Lua/XML Help (https://www.wowinterface.com/forums/forumdisplay.php?f=16)
-   -   Help with PetFrame 'pet experience bar' (https://www.wowinterface.com/forums/showthread.php?t=667)

Inokis 04-23-05 06:49 PM

Help with PetFrame 'pet experience bar'
 
I'm trying to add a pet experience bar to my PetFrame xml, however so far I can only get it to display after visiting the Stable Master. I'm not sure what i'm doing wrong but perhaps someone can help me out here:

LUA:
Code:

function PetFrame_OnLoad()
      this:RegisterEvent("UNIT_PET_EXPERIENCE");
      PetFrameExpBar_Update();
end

function PetFrame_Update()
      PetFrameExpBar_Update();
end

function PetFrame_OnEvent(event)
      UnitFrame_OnEvent(event);
              if ( event == "UNIT_PET_EXPERIENCE" ) then
                PetFrameExpBar_Update();
        end
end

function PetFrameExpBar_Update()
        local currXP, nextXP = GetPetExperience();
        PetFrameExpBar:SetMinMaxValues(min(0, currXP), nextXP);
        PetFrameExpBar:SetValue(currXP);
end

XML:
Code:

<StatusBar name="PetFrameExpBar" inherits="TextStatusBar">
    <Size>
        <AbsDimension x="122" y="3"/>
    </Size>
        <Anchors>
                <Anchor point="TOPLEFT">
                <Offset>
                        <AbsDimension x="-5" y="-18"/>
                </Offset>
            </Anchor>
        </Anchors>
        <Scripts>
                <OnLoad>
                        PetFrameExpBar_Update();
                        TextStatusBar_Initialize();
                        this:Show();
                </OnLoad>
                <OnEvent>
                        PetFrameExpBar_Update();
                </OnEvent>
        </Scripts>
        <BarTexture file="Interface\TargetingFrame\UI-StatusBar"/>
                <BarColor r="1.0" g=".32" b="1.0"/>
</StatusBar>


Inokis 04-24-05 02:09 AM

I finally got it to work:

this:RegisterEvent("PET_BAR_UPDATE");


All times are GMT -6. The time now is 09:01 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI