View Single Post
04-06-12, 05:04 PM   #12
MiRai
A Warpwood Thunder Caller
Join Date: Jul 2011
Posts: 96
Originally Posted by Phanx View Post
Before asking for help/feedback on your code, your first step should always be to load it in-game, or at least run it through a Lua syntax checker, and attempting to fix the basic syntax errors. In this case, "if for ... end else ... end" is not valid Lua syntax.
I understand. It was more of a half-ass pseudo code then anything else and I wasn't able to actually test anything in game until about 30 minutes ago.



Originally Posted by Phanx View Post
If the TimerTrackerN bars have the same structure as the MirrorTimerN bars, then you can just add them to the existing list of bars the "for ... end" loop should iterate over (on line #3):

Lua Code:
  1. -- mirror castbar!
  2.   lib.gen_mirrorcb = function(f)
  3.     for _, bar in pairs({'MirrorTimer1','MirrorTimer2','MirrorTimer3','TimerTrackerTimer1','TimerTrackerTimer2','TimerTrackerTimer3'}) do  
  4.       for i, region in pairs({_G[bar]:GetRegions()}) do
  5.         if (region.GetTexture and region:GetTexture() == 'SolidTexture') then
  6.           region:Hide()
  7.         end
  8.       end
  9.       _G[bar..'Border']:Hide()
  10.       _G[bar]:SetParent(UIParent)
  11.       _G[bar]:SetScale(1)
  12.       _G[bar]:SetHeight(16)
  13.       _G[bar]:SetWidth(280)
  14.       _G[bar]:SetBackdropColor(.1,.1,.1)
  15.       _G[bar..'Background'] = _G[bar]:CreateTexture(bar..'Background', 'BACKGROUND', _G[bar])
  16.       _G[bar..'Background']:SetTexture(cfg.statusbar_texture)
  17.       _G[bar..'Background']:SetAllPoints(bar)
  18.       _G[bar..'Background']:SetVertexColor(.15,.15,.15,.75)
  19.       _G[bar..'Text']:SetFont(cfg.font, 14, "THINOUTLINE")
  20.       _G[bar..'Text']:ClearAllPoints()
  21.       _G[bar..'Text']:SetPoint('CENTER', MirrorTimer1StatusBar, 0, 1)
  22.       _G[bar..'StatusBar']:SetAllPoints(_G[bar])
  23.       --glowing borders
  24.       local h = CreateFrame("Frame", nil, _G[bar])
  25.       h:SetFrameLevel(0)
  26.       h:SetPoint("TOPLEFT",-5,5)
  27.       h:SetPoint("BOTTOMRIGHT",5,-5)
  28.       lib.gen_backdrop(h)
  29.     end
  30.   end

The above code actually breaks the raid frames (odd?). I tested it a few times typing it out myself and directly copying and pasting it in. Also, I just saw /framestack report up to TimerTrackerTimer5 (only one bar total was actually visible) but, my main concern was on line 21. MirrorTimer uses the MirrorTimerStatusBar but TimerTrackerTimer uses TimerTrackerTimerStatusBar. I am assuming that some modification needs to be done to line 21 and I'll have to try it later tonight. I know you just said it helps to try your own code first but, I won't be able to for several hours and I just wanted to post this in case anyone who might know the answer shows up before I am able to test it out. =)

Here is what I would test:
Lua Code:
  1. _G[bar..'Text']:ClearAllPoints()
  2.            If MirrorTimer1 == true Or MirrorTimer2 == true Or MirrorTimer3 == true Then
  3.                 _G[bar..'Text']:SetPoint('CENTER', MirrorTimer1StatusBar, 0, 1)
  4.           Else
  5.                 _G[bar..'Text']:SetPoint('CENTER', TimerTracker1StatusBar, 0, 1)
  6.           End
  7.       _G[bar..'StatusBar']:SetAllPoints(_G[bar])


EDIT: The [highlight] won't accept the first set of spaces on the first line.
  Reply With Quote