Advertisement
Guest User

Untitled

a guest
Jul 10th, 2012
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.92 KB | None | 0 0
  1. if lib.getClass('player') ~= "MONK" then return end
  2.  
  3. local chi = SPELL_POWER_LIGHT_FORCE
  4. local coloron = {.9, .9, .9, 1}
  5. local coloroff = {.2, .2, .2, 1}
  6. local chinum
  7. local chipoints = {}
  8.  
  9. local chibar = CreateFrame("Frame", "ColdChiBar" , ColdPlayer)
  10. chibar:SetSize(95, 12)
  11. chibar:SetPoint("BOTTOMRIGHT", ColdPlayer.Health, "BOTTOMRIGHT", 6.5, 1)
  12. chibar:SetFrameLevel(6)
  13.  
  14. local function ChiUpdate()
  15.     local chi = UnitPower("player", SPELL_POWER_LIGHT_FORCE)
  16.     local chimax = UnitPowerMax("player", SPELL_POWER_LIGHT_FORCE)
  17.    
  18.     if chinum ~= chimax then
  19.         if chimax == 4 then
  20.             chipoints[5]:Hide()
  21.             for i = 4, 1, -1 do
  22.                 if i == 4 then
  23.                     chipoints[i]:SetPoint("RIGHT", chibar)
  24.                 else
  25.                     chipoints[i]:SetPoint("RIGHT", chipoints[i+1], "LEFT", 0, 0)
  26.                 end
  27.             end
  28.         else
  29.             chipoints[5]:Show()
  30.             for i = 5, 1, -1 do
  31.                 if i == 5 then
  32.                     chipoints[i]:SetPoint("RIGHT", chibar)
  33.                 else
  34.                     chipoints[i]:SetPoint("RIGHT", chipoints[i+1], "LEFT", 0, 0)
  35.                 end
  36.             end
  37.         end
  38.        
  39.         chinum = chimax
  40.     end
  41.  
  42.     for i = 1, chimax do
  43.         if i <= chi then
  44.             chipoints[i]:SetTextColor(unpack(coloron))
  45.         else
  46.             chipoints[i]:SetTextColor(unpack(coloroff))
  47.         end
  48.     end
  49. end
  50.  
  51. local function CreateChi()
  52.     chibar:RegisterEvent("UNIT_POWER")
  53.     chibar:RegisterEvent("UNIT_DISPLAYPOWER")
  54.     chibar:SetScript("OnEvent", ChiUpdate)
  55.    
  56.     for i = 5, 1, -1 do
  57.         chipoints[i] = lib.SetFontString(chibar, cfg.font, cfg.fontsize, "OUTLINE, MONOCHROME")
  58.         chipoints[i]:SetText(i.."*")
  59.         if i == 1 then
  60.             chipoints[i]:SetSize(18,12)
  61.         else
  62.             chipoints[i]:SetSize(20,12)
  63.         end
  64.         if i == 5 then
  65.             chipoints[i]:SetPoint("RIGHT", chibar)
  66.             chipoints[i]:SetTextColor(1, 0, 0)
  67.         else
  68.             chipoints[i]:SetPoint("RIGHT", chipoints[i+1], "LEFT", 0, 0)
  69.         end
  70.         chipoints[i]:SetTextColor(unpack(coloroff))
  71.     end
  72.    
  73.     chinum = 5
  74.     ChiUpdate()
  75. end
  76.  
  77. chibar:RegisterEvent("PLAYER_ENTERING_WORLD")
  78. chibar:SetScript("OnEvent", CreateChi)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement