Thread Tools Display Modes
Prev Previous Post   Next Post Next
02-23-16, 03:18 AM   #1
jeAz_
A Deviate Faerie Dragon
Join Date: Feb 2016
Posts: 13
How could I make this code much neater?

So, I currently have the following code written.

Lua Code:
  1. A.CreateDruidMana = function(f, unit)
  2.  local DruidMana = CreateFrame("StatusBar", "DruidMana", f);
  3.  DruidMana:SetStatusBarTexture(POWER_BAR);
  4.  DruidMana:SetOrientation("VERTICAL");
  5.  
  6.  DruidMana.background = DruidMana:CreateTexture(nil, "BACKGROUND");
  7.  DruidMana.background:SetTexture(BACKDROP);
  8.  DruidMana.background:SetVertexColor(0.1, 0.1, 0.1, 1);
  9.  DruidMana.background:SetSize(10, f:GetHeight());
  10.  DruidMana.background:SetPoint("LEFT", f, "RIGHT", 2, 0);
  11.  
  12.  DruidMana:SetPoint("TOPLEFT", DruidMana.background, "TOPLEFT", 2, -2);
  13.  DruidMana:SetPoint("BOTTOMRIGHT", DruidMana.background, "BOTTOMRIGHT", -2, 2);
  14.  
  15.  local bg = DruidMana:CreateTexture(nil, "BACKGROUND");
  16.  bg:SetAllPoints(true);
  17.  bg:SetTexture(BACKDROP);
  18.  
  19.  A.AddOptions(DruidMana, "frequentUpdates");
  20.  bg.multiplier = 0.2;
  21.  
  22.  f.DruidMana = DruidMana;
  23.  f.DruidMana.bg = bg;
  24. end

The reason that I created another texture called Background is to create a outer background like the following image:



However, I would like to Create "DruidMana" as a "Frame" rather than "StatusBar" and create "StatusBar" called "Bar" which becomes child object of "DruidMana" then Set Backdrop for "DruidMana" which I would like to use as outer frame instead of using texture called "Background".

Which would become:

Lua Code:
  1. local DruidMana = CreateFrame("Frame", "DruidMana", f);
  2. local Bar = CreateFrame("StatusBar", nil, DruidMana);
  3. local bg = Bar:CreateTexture(nil, "BACKGROUND");

I actually tried it, but it was not possible to set "DruidMana" as "f.DruidMana" since "DruidMana" was set to "Frame", not "StatusBar".

In addition to that even if I set "Bar" as "f.DruidMana", "DruidMana" does not hide on shape shift...

Could I please get an advice regarding this?
  Reply With Quote
 

WoWInterface » Featured Projects » oUF (Otravi Unit Frames) » How could I make this code much neater?


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