Reply
Thread Tools Display Modes
Unread 05-26-11, 06:17 AM   #1
Fugaru
A Murloc Raider
Join Date: Apr 2011
Posts: 6
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!
Fugaru is offline   Reply With Quote
Unread 05-26-11, 08:43 AM   #2
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 907
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
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

Dawn is offline   Reply With Quote
Unread 05-27-11, 03:08 AM   #3
Fugaru
A Murloc Raider
Join Date: Apr 2011
Posts: 6
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.
Fugaru is offline   Reply With Quote
Unread 05-27-11, 05:27 AM   #4
Rainrider
A Rage Talon Dragon Guard
Join Date: Nov 2008
Posts: 318
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.
Rainrider is offline   Reply With Quote
Unread 05-27-11, 08:21 AM   #5
Fugaru
A Murloc Raider
Join Date: Apr 2011
Posts: 6


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?

Last edited by Fugaru : 05-27-11 at 08:27 AM.
Fugaru is offline   Reply With Quote
Unread 05-27-11, 08:23 AM   #6
Dawn
A Molten Giant
 
Dawn's Avatar
AddOn Author - Click to view addons
Join Date: May 2006
Posts: 907
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.
__________________
Rock: "We're sub-standard DPS. Nerf Paper, Scissors are fine."
Paper: "OMG, WTF, Scissors!"
Scissors: "Rock is OP and Paper are QQers. We need PvP buffs."

"neeh the game wont be remembered as the game who made blizz the most money, it will be remembered as the game who had the most QQ'ers that just couldnt quit the game for some reason..."

Dawn is offline   Reply With Quote
Unread 05-27-11, 08:25 AM   #7
Fugaru
A Murloc Raider
Join Date: Apr 2011
Posts: 6
Okay, I'm throwing out the tag. Thanks for the fast reply!
Fugaru is offline   Reply With Quote
Unread 05-27-11, 02:14 PM   #8
Rainrider
A Rage Talon Dragon Guard
Join Date: Nov 2008
Posts: 318
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.
Rainrider is offline   Reply With Quote
Unread 05-28-11, 11:09 AM   #9
Sauerkraut
A Cyclonian
 
Sauerkraut's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 46
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.
Sauerkraut is offline   Reply With Quote
Reply

Go BackWoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Maelstrom Weapon Plugin for oUF

Thread Tools
Display Modes

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