01-11-11, 07:48 AM | #1 | |
Dozi
Guest
Posts: n/a
|
Predictive Health Bars
Hi,
I am new to lua but have a little bit of basic programming knowledge. I decided to convert my Stuf unit frames layout to oUF, just to see if I could. I am not doing too bad, but I seem to have become a bit stuck with the predictive health bar. I have attached an image, the green bar next to my unit frame is the predictive health bar. I can't seem to figure out why it is not working. If I loose health the bar does not move. I have checked the code on the ouf wiki on git hub and ouf_ep on gut hub. Below is my code to create a Health bar, mana bar and the predictive health bar: local function CreateHPBar(self, w, h) local HpBar = CreateFrame("StatusBar", nil, self) HpBar:SetStatusBarTexture(HPBarTex) HpBar:SetSize(w, h) HpBar:SetPoint("TOP", self, "TOP", 0, -Border) HpBar.frequentUpdates = FreqUpd HpBar.colorTapping = true HpBar.Smooth = true --HPBar Color if HPClassColour then HpBar.colorClass = true HpBar.colorClassNPC = true else HpBar.colorSmooth = true end self.Health = HpBar end local function CreateMPBar(self, w, h) local MpBar = CreateFrame("StatusBar", nil, self) MpBar:SetStatusBarTexture(BarTex) MpBar:SetSize(w, h) MpBar:SetPoint("BOTTOM", self, "BOTTOM", 0, -Border) MpBar.frequentUpdates = true MpBar.colorPower = true MpBar.Smooth = true self.Power = MpBar end local function CreatePredictedHealthBar(self, w) -- Position and size local mhpb = CreateFrame('StatusBar', nil, self.Health) mhpb:SetPoint('TOPLEFT', self.Health:GetStatusBarTexture(), 'TOPRIGHT', 0, 0) mhpb:SetPoint('BOTTOMLEFT', self.Health:GetStatusBarTexture(), 'BOTTOMRIGHT', 0, 0) mhpb:SetWidth(w) mhpb:SetStatusBarTexture(BarTex) mhpb:SetStatusBarColor(0, 1, 0.5, 0.25) local ohpb = CreateFrame('StatusBar', nil, self.Health) ohpb:SetPoint('TOPLEFT', mhpb:GetStatusBarTexture(), 'TOPRIGHT', 0, 0) ohpb:SetPoint('BOTTOMLEFT', mhpb:GetStatusBarTexture(), 'BOTTOMRIGHT', 0, 0) ohpb:SetWidth(w) ohpb:SetStatusBarTexture(BarTex) ohpb:SetStatusBarColor(0, 1, 0, 0.25) -- Register it with oUF self.HealPrediction = { -- status bar to show my incoming heals myBar = mhpb, -- status bar to show other peoples incoming heals otherBar = ohpb, -- amount of overflow past the end of the health bar maxOverflow = 1.05, } end I call the above functions from the below code: local function CreateUnitFrame(self, unit) -- size the overall unit frame self:SetSize(PlayerWidth + 2 * Border, PlayerHPBarHeight + PlayerMPBarHeight + 3 * Border) -- Menu self.menu = CreateMenu self:RegisterForClicks('AnyDown') self:SetScript('OnEnter', UnitFrame_OnEnter) self:SetScript('OnLeave', UnitFrame_OnLeave) self:SetAttribute('*type2', 'menu') MoveMe(self) CreateBackGround(self) CreateHPBar(self, PlayerWidth, PlayerHPBarHeight) CreatePredictedHealthBar(self, PlayerWidth) CreateMPBar(self, PlayerWidth, PlayerMPBarHeight) CreateCastBar(self, PlayerWidth, PlayerCBHeight) -- Raid Icon local RaidIcon = self:CreateTexture(nil, "OVERLAY") RaidIcon:SetSize(18,18) RaidIcon:SetPoint("TOP", self.Health, "TOP", 0, 20) self.RaidIcon = RaidIcon if UnitSpecific[unit] then return UnitSpecific[unit](self) end end I hope that it is something really silly that I am missing. Last edited by Dozi : 01-11-11 at 08:52 AM. |
|
Dozi |
01-11-11, 09:22 AM | #2 |
Looking at the code there is nothing that jumps out at me as being wrong.
Which version of oUF are you running? Would it be possible to post a link to your layout? (It's easier to debug if I can just run the entire thing) For anyone else looking at this, here is the code Dozi posted in a nicer format: lua Code:
lua Code:
|
|
01-11-11, 02:17 PM | #3 | |
Dozi
Guest
Posts: n/a
|
Thank you for your relpy and formatting my code in a nicer way.
I have attached my layout in a zip file. I am going to strip my code back to just a player frame, health, mana and predictive bar tonight. If I can get that working hopfully I should find what part of my code is breaking things. Thank you for offering to take a look at my code Edit: I have just tested my layout after taking out everything apart from a player frame, the predictive bar works. I just need to find the code which messed it up. Last edited by Dozi : 01-11-11 at 02:31 PM. |
|
Dozi |
01-12-11, 11:15 AM | #4 | |
Dozi
Guest
Posts: n/a
|
Everything is working now.
While I was debugging I decided to clean up some code that I was not happy with, and turned several parts of my code into functions. Thanks for looking over things |
|
Dozi |
01-12-11, 03:45 PM | #5 |
np, good job in getting it sorted out yourself.
|
|
WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Predictive Health Bars |
«
Previous Thread
|
Next Thread
»
|
Display Modes |
Linear Mode |
Switch to Hybrid Mode |
Switch to Threaded Mode |
|
|