Thread Tools Display Modes
01-02-21, 03:00 PM   #1
Industrial
A Fallenroot Satyr
 
Industrial's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2005
Posts: 27
Trying to implement Castbar but it stays at 100%

Hi!
I'm trying to implement the Castbar on my frames but the value of the bar stays at 100% and it's white.

This is my code:

Code:
    create_cast_bar = function(self, unit, frame)
      local Castbar = CreateFrame('StatusBar', nil, frame)
      Castbar.bg = Castbar:CreateTexture(nil, 'BACKGROUND')
      Castbar.bg:SetAllPoints(Castbar)
      Castbar.Spark = Castbar:CreateTexture(nil, 'OVERLAY')
      Castbar.Spark:SetBlendMode('ADD')
      Castbar.Time = Castbar:CreateFontString(nil, 'OVERLAY', 'GameFontNormal')
      Castbar.Time:SetFont(Castbar.Time:GetFont(), 9)
      Castbar.Time:SetTextColor(1, 1, 1, 1)
      Castbar.Time:SetHeight(9)
      Castbar.Time:SetPoint(MR, Castbar, MR, 0, 0)
      Castbar.Text = Castbar:CreateFontString(nil, 'OVERLAY', 'GameFontNormal')
      Castbar.Text:SetFont(Castbar.Text:GetFont(), 9)
      Castbar.Text:SetTextColor(1, 1, 1, 1)
      Castbar.Text:SetHeight(9)
      Castbar.Text:SetPoint(ML, Castbar, ML, 0, 0)
      Castbar.SafeZone = Castbar:CreateTexture(nil, 'OVERLAY')
      frame.Castbar = Castbar
    end,
and update code (ran after settings change):

Code:
      if db.bars.cast_bar.enabled and contains(unit, self.cast_bar_units) then
        local cast_bar_height = height_minus_padding / weights_total * db.bars.cast_bar.height
        frame.Castbar:SetStatusBarTexture(db.bars.cast_bar.texture)
        frame.Castbar.bg:SetTexture(db.bars.cast_bar.background)
        frame.Castbar.bg.multiplier = 0.2
        frame.Castbar:SetSize(width_minus_padding, cast_bar_height)
        frame.Castbar:ClearAllPoints()
        frame.Castbar:SetPoint(TC, frame.Power, BC, 0, -db.frame.size.padding)
      end

Edit:

Question 2: I would like to hide the castbar when the unit is not casting, so that I can redistribute the weights for the height of the bars and the castbar pops on and off the frame. Is there a function/property I can use to check/do this?

Last edited by Industrial : 01-02-21 at 03:05 PM.
  Reply With Quote
01-02-21, 07:15 PM   #2
p3lim
A Pyroguard Emberseer
 
p3lim's Avatar
AddOn Author - Click to view addons
Join Date: Feb 2007
Posts: 1,710
Lua Code:
  1. create_cast_bar = function(self, unit, frame)
  2.     ...
  3.     frame.Castbar = Castbar
  4. end

Is "frame" the unit frame here? The castbar element only functions when "Castbar" is a child of that object.
I'm going to guess that you'd want this to be "self.Castbar = Castbar" instead.
  Reply With Quote

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » Trying to implement Castbar but it stays at 100%

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