WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   oUF (Otravi Unit Frames) (https://www.wowinterface.com/forums/forumdisplay.php?f=87)
-   -   Trying to implement Castbar but it stays at 100% (https://www.wowinterface.com/forums/showthread.php?t=58517)

Industrial 01-02-21 03:00 PM

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?

p3lim 01-02-21 07:15 PM

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.


All times are GMT -6. The time now is 10:23 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI