View Single Post
03-20-16, 06:17 PM   #13
Layback_
An Onyxian Warder
Join Date: Feb 2016
Posts: 358
Originally Posted by Folji View Post
Decided to try and test this, see how it'd go.

Lua Code:
  1. lib.CreateHealth = function(frame,frametype,width,height,point,x,y)
  2.  
  3.     local hp = CreateFrame('StatusBar',nil,frame)
  4.     hp:SetSize(width,height)
  5.     hp:SetPoint(point,frame,x,y)
  6.     hp:SetStatusBarTexture('Interface\\AddOns\\TestUI\\media\\playerhp')
  7.     hp:SetStatusBarColor(0,1,0)
  8.     hp:RegisterUnitEvent('UNIT_HEALTH', frametype)
  9.  
  10.     if (frametype == 'target') then
  11.         hp:SetReverseFill(true)
  12.         hp:GetStatusBarTexture():SetTexCoord(1,0,0,1)
  13.         hp:GetStatusBarTexture():SetPoint('RIGHT', hp)
  14.     end
  15.  
  16.     local function HealthUpdate()
  17.         local hpcur, hpmax = UnitHealth(frametype), UnitHealthMax(frametype)
  18.         hp:SetMinMaxValues(0,hpmax)
  19.         hp:SetValue(hpcur)
  20.     end
  21.  
  22.     hp:HookScript("OnEvent",HealthUpdate)
  23.  
  24.     local function CheckCoords()
  25.         print(frametype.." : "..hp:GetStatusBarTexture():GetPoint())
  26.         print(hp:GetStatusBarTexture():GetTexCoord())
  27.  
  28.     end
  29.  
  30.     frame:HookScript('OnMouseUp',CheckCoords)
  31. end

Seems like not being able to use hp:GetStatusBarTexture():SetTexCoord(1,0,0,1) to flip the texture is largely down to how the game handles statusbars? I don't know if I'm writing something wrong here or what, but testing around with it showed me that the statusbars were narrowing by changing the TexCoords directly. So no matter what it was set to before, it'd change back to 0,1,0,1 and then gradually drop down from there.

GetStatusBarTexture():GetPoint() defaulted to TOPLEFT, and trying to SetPoint() did absolutely nothing.
Hi Folji,

That's exactly what I have experienced.

Like you said, no matter what change is made, it changes back to 0, 1, 0, 1
  Reply With Quote