Thread Tools Display Modes
08-08-11, 09:54 PM   #1
starlon
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 107
multiple elements of same type

Is it possible to have two or more Health bars on the same unit frame? At a glance it doesn't appear so, but I'm hoping there's a way.
__________________
Wake up Sheeple! Cataclysm was an inside job!

Legalize WoW gold purchases directly from Blizzard! Yeah, my doctor thinks I'm crazy too. >.<

"It was either going to school for programming or working at the Genetically Modified Wildlife Preserve. I've always had a love for the wildlife, but technology won out in the end."

Note: If you know of a library that you want to make available in your own scripts. let me know and I'll see about writing a plugin for it.

LCD4WoW
  Reply With Quote
08-09-11, 04:51 AM   #2
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
No, you can't enable two health bars on one frame.

I'm guessing this is mainly for your oUF_ScriptableText plug-in, so:

I did think about allowing this once (around oUF 1.3.x) and I actually implemented a proof-of-concept. The design I used then was something like:

Code:
self.Health = {
   <StatusBar>,
   <StatusBar>
}
Then I'd just iterate the table when Enabling, Disabling and Updating the element. The change to support this isn't large at all, it just boils down to adding the iterators to the element code.

I however decided to note merge my branch into oUF and leave things as they are today. Back then I didn't see too much reason why someone would want to do something like this. For example having multiple health bars just seemd odd.

I have however thought about adding support for this to the power element for example, then merge the altpowerbar code into it. It would also allow things such as easy settings for displaying druid mana bars and such as well. But adding this isn't something I really want to do for most elements. Then there's also the fact that the power element generally is a very warm code path. Just throwing iterators at it would be too naive.

All that being said, elements are very free to do whatever they want. For example, previously the range element was just a callback, which created a frame, which iterated all oUF objects looking for .Range. Another example would be how tags just tossed its functions into the oUF table. In other words, you are very much free to do whatever you want, but please try to not step peoples toes .
__________________
「貴方は1人じゃないよ」
  Reply With Quote
08-10-11, 04:08 AM   #3
starlon
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Jul 2008
Posts: 107
It worked out. Only thing, and it's likely due to metatables?, but I can't do..

Code:
self.ScriptableText[i] = WidgetText:New(...) 
self.ScriptableText[i]:Start()
It needs to be...

Code:
local widget = WidgetText:New(...)
widget:Start()
self.ScriptableText[i] = widget
Weird. Metatable voodoo? Hmm maybe it's __index? :Start doesn't exist, but all config stuff is there. It's like what's provided by WidgetText itself isn't in the widget/table/object.

Edit: Is this going to break anything?
__________________
Wake up Sheeple! Cataclysm was an inside job!

Legalize WoW gold purchases directly from Blizzard! Yeah, my doctor thinks I'm crazy too. >.<

"It was either going to school for programming or working at the Genetically Modified Wildlife Preserve. I've always had a love for the wildlife, but technology won out in the end."

Note: If you know of a library that you want to make available in your own scripts. let me know and I'll see about writing a plugin for it.

LCD4WoW

Last edited by starlon : 08-10-11 at 04:38 AM.
  Reply With Quote
08-10-11, 04:49 AM   #4
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Those two should be equal.

Unless you've hit the bug which was discussed on the mailing list today: http://lua-users.org/lists/lua-l/2011-08/msg00262.html. It doesn't seem likely to be the case however.

I don't know your code at all, so I can't really make any further comment about it.
__________________
「貴方は1人じゃないよ」
  Reply With Quote
08-10-11, 05:55 AM   #5
haste
Featured Artist
 
haste's Avatar
Premium Member
Featured
Join Date: Dec 2005
Posts: 1,027
Originally Posted by starlon View Post
Edit: Is this going to break anything?
Nope. It will work just fine as long as your element expect it.
__________________
「貴方は1人じゃないよ」
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » multiple elements of same type


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