WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   Maelstrom Weapon Plugin for oUF (https://www.wowinterface.com/forums/showthread.php?t=40291)

Fugaru 05-26-11 06:17 AM

Maelstrom Weapon Plugin for oUF
 
Hey there oUF users, developers, authors, ...

I'm working on a oUF layout myself and was looking for a way to include Maelstrom weapon stacks into my player frame whenever I play an enhancement shaman.

Is there something like this allready out? Can someone point me into the right direction?

Huge thanks in advance!

Dawn 05-26-11 08:43 AM

You can do this with a Tag.

Code:

local MAELSTROM_WEAPON = GetSpellInfo(53817)
oUF.Tags["maelstrom"] = function(unit)
        if unit == "player" then
                local name, _, icon, count = UnitBuff("player", MAELSTROM_WEAPON)
                return name and count
        end
end       
oUF.TagEvents["maelstrom"] = "UNIT_AURA"


You can check for player's class in your layout to only "activate" it for shamans.

Code:

local _, playerClass = UnitClass('player')

if playerClass == "SHAMAN" then
blubb
end


Fugaru 05-27-11 03:08 AM

Thanks for the reply. I saw that Phanx is using the same Maelstrom tag in his oUF layout. Although I didn't run his layout I believe the Maelstrom stacks are displayed as numbers, right?

I'm no hero with lua yet but you use tags to display something in text, correct?

Perhaps I wasn't precise enough in my first post, but I'm actually aiming to generate a Maelstrom bar instead of a number.

I'm able to create an extra bar on my player frame when the class = shaman and show 5 "stacks" on it. Now I just need to figure out a way to make the bar work. I based my code on the Holy Power and made 5 points instead of 3.

So, do I still need to introduce that tag, or do I need to create some function?

Really appreciate your reply.

Rainrider 05-27-11 05:27 AM

You need a call to update the bar. Just take a look at the update function for the holy power element and adapt the code to get the stack count. Suitable locations for the update are your PostUpdate function for Buffs or CustomFilter if you use it.

Fugaru 05-27-11 08:21 AM



This is what I have so far. If someone can push me a bit closer into the direction, I would be very happy.
Btw, the first bar is my totembar, the lowest bar should be the maelstrom bar.

Not sure if this is needed but I added it to my tags.lua file anyway
Code:

local MAELSTROM_WEAPON = GetSpellInfo(53817)
oUF.TagEvents["maelstrom"] = "UNIT_AURA"
oUF.Tags["maelstrom"] = function(unit)
        if unit == "player" then
                local name, _, icon, count = UnitBuff("player", MAELSTROM_WEAPON)
                return name and count
        end
end

Than in my lib.lua I've wrote the following
Code:

lib.genMaelstrom = function(self)
        if playerClass ~= "SHAMAN" then return end
        local bars = CreateFrame("Frame", nil, self)
        bars:SetFrameStrata("LOW")
        bars:SetPoint("BOTTOMLEFT", self, "BOTTOMLEFT", 0,-37)
        bars:SetWidth(260)
        bars:SetHeight(6)

        for i = 1, 5 do                                       
                bars[i]=CreateFrame("StatusBar", nil, bars)
                bars[i]:SetHeight(bars:GetHeight())                                       
                bars[i]:SetStatusBarTexture(cfg.statusbar_texture)
                bars[i]:GetStatusBarTexture():SetHorizTile(false)

                bars[i].bg = bars[i]:CreateTexture(nil, 'BORDER')
                bars[i]:SetStatusBarColor(90/255,90/255,90/255)
                bars[i].bg:SetTexture(228/255,225/255,16/255)
                                       
                if i == 1 then
                        bars[i]:SetPoint("LEFT", bars)
                else
                        bars[i]:SetPoint("LEFT", bars[i-1], "RIGHT", 1, 0)
                end
               
                bars[i].bg:SetAllPoints(bars[i])
                bars[i]:SetWidth((bars:GetWidth() - 2)/5)
                bars[i].bg:SetTexture(cfg.statusbar_texture)                                       
                bars[i].bg:SetAlpha(.15)
        end
                               
        bars.backdrop = CreateFrame("Frame", nil, bars)
        frame1px(bars.backdrop)
        CreateShadow(bars.backdrop)
        bars.backdrop:SetBackdropBorderColor(.2,.2,.2,1)
        bars.backdrop:SetPoint("TOPLEFT", -2, 2)
        bars.backdrop:SetPoint("BOTTOMRIGHT", 2, -2)
        bars.backdrop:SetFrameLevel(bars:GetFrameLevel() - 1)
        bars.Override = UpdateMaelstrom
        self.Maelstrom = bars       
end

And like with HolyPower, I also added this
Code:

UpdateMaelstrom = function(self, event, unit, unitBuff)
                if(self.unit ~= unit or (unitBuff and unitBuff ~= 'MAELSTROM_WEAPON')) then return end
                local num = UnitBuff(unit, MAELSTROM_WEAPON)
                for i = 1, MAX_MAELSTROM do
                        if(i <= num) then
                                self.Maelstrom[i]:SetAlpha(1)
                        else
                                self.Maelstrom[i]:SetAlpha(.2)
                        end
                end
        end

I'm probably doing a lot of things wrong but I got a bar up there, it just doesn't fill up. Atleast I'm not getting lua errors, that's something.

So any idea's?

Dawn 05-27-11 08:23 AM

No time to look at the code, just want to say that you don't need the tag at all if you want to display the stacks with a bar. Except you want a bar and the stack count as a number, at once. Which would be pretty much overkill, imho.

Fugaru 05-27-11 08:25 AM

Okay, I'm throwing out the tag. Thanks for the fast reply!

Rainrider 05-27-11 02:14 PM

The 4th return of UnitBuff is the stack count, the first is the name of the buff. In your code num is the name, which is wrong.

What you still miss is the call to UpdateMaelstrom.

Apart from that I don't know where you got MAELSTROM_WEAPON from, it returns nil for me. Use GetSpellInfo(53817) instead.

Sauerkraut 05-28-11 11:09 AM

He had set
Code:

local MAELSTROM_WEAPON = GetSpellInfo(53817)
in his tag. If he removed the tag he would need to readd the line into his code to make it work.


All times are GMT -6. The time now is 05:03 AM.

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