Thread Tools Display Modes
07-02-13, 01:03 PM   #1
cicilia
A Murloc Raider
Join Date: Jul 2013
Posts: 4
WeakAuras Health bar

Okay so ive been trying to make a healthbar useing a Ragebar i found in a youtube video. this is the code:

Code:
function(progress, r1, g1, b1, a1, r2, g2, b2, a2)
    local player_rage = Unitpower("player", 1)
    local red, green, blue = 0,0,0
    if player_rage > 60 then
         red, green, blue = 0,1,0
    elseif player_rage > 20 then
         red,green,blue = 0,1,1
    else
         red,green,blue = 1,0,0
    return red, green, blue, 1
end
and i tried changeing it to:

Code:
function(progress, r1, g1, b1, a1, r2, g2, b2, a2)
    local player_health = health("player", 1)
    local red, green, blue = 0,0,0
    if player_health > 60 then
         red, green, blue = 0,1,0
    elseif player_health > 20 then
         red,green,blue = 0,1,1
    else
         red,green,blue = 1,0,0
    return red, green, blue, 1
end
Any1 could help me make this work?
  Reply With Quote
07-02-13, 03:43 PM   #2
Gethe
RealUI Developer
 
Gethe's Avatar
Premium Member
Featured
Join Date: Sep 2008
Posts: 942
The second line would need to be:
Code:
local player_health = UnitHealth("player")
__________________
Knowledge = Power; Be OP

  Reply With Quote
07-03-13, 05:01 AM   #3
cicilia
A Murloc Raider
Join Date: Jul 2013
Posts: 4
Originally Posted by Gethe View Post
The second line would need to be:
Code:
local player_health = UnitHealth("player")
so i changed it to.

function(progress, r1, g1, b1, a1, r2, g2, b2, a2)
local player_health = UnitHealth("player" )
local red, green, blue = 0,0,0
if player_health > 60 then
red, green, blue = 0,1,0
elseif player_health > 20 then
red,green,blue = 0,1,1
else
red,green,blue = 1,0,0
return red, green, blue, 1
end
yet it gives me the error:

[string " return function(progress, r1, g1, b1, a1, r2, b2, a2)..."]:15: 'end' expected(to close 'function' at line1) near '<eof>'

got any idea what this error means?
  Reply With Quote
07-03-13, 05:06 AM   #4
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
Put an 'end' before the return statement.
  Reply With Quote
07-03-13, 05:12 AM   #5
cicilia
A Murloc Raider
Join Date: Jul 2013
Posts: 4
function(progress, r1, g1, b1, a1, r2, g2, b2, a2)
local player_health = UnitHealth("player" )
local red, green, blue = 0,0,0
if player_health > 60 then
red, green, blue = 0,1,0
elseif player_health > 20 then
red,green,blue = 0,1,1
else
red,green,blue = 1,0,0
end
return red, green, blue, 1


like this i guess, gives the error:

[string " return function(progress, r1, g1, b1, a1, r2, b2, a2)..."]:16: 'end' expected(to close 'function' at line1) near '<eof>

does the "if player_health > 60 then" need to be something else? like "if player_health% > 60% then"?
  Reply With Quote
07-03-13, 05:18 AM   #6
semlar
A Pyroguard Emberseer
 
semlar's Avatar
AddOn Author - Click to view addons
Join Date: Sep 2007
Posts: 1,060
No, you removed the end that closes the function when you added the end to close the if statement..
Lua Code:
  1. function(progress, r1, g1, b1, a1, r2, g2, b2, a2)
  2.     local player_health = UnitHealth("player")
  3.     local red, green, blue = 0,0,0
  4.     if player_health > 60 then
  5.         red, green, blue = 0,1,0
  6.     elseif player_health > 20 then
  7.         red, green, blue = 0,1,1
  8.     else
  9.         red, green, blue = 1,0,0
  10.     end
  11.     return red, green, blue, 1
  12. end
All this function does is return a color code based on how much health you have.

Last edited by semlar : 07-03-13 at 05:27 AM.
  Reply With Quote
07-03-13, 05:28 AM   #7
cicilia
A Murloc Raider
Join Date: Jul 2013
Posts: 4
Thank you very much..
  Reply With Quote

WoWInterface » AddOns, Compilations, Macros » AddOn Help/Support » WeakAuras Health bar


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