View Single Post
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