WoWInterface

WoWInterface (https://www.wowinterface.com/forums/index.php)
-   AddOn Help/Support (https://www.wowinterface.com/forums/forumdisplay.php?f=3)
-   -   WeakAuras Health bar (https://www.wowinterface.com/forums/showthread.php?t=46763)

cicilia 07-02-13 01:03 PM

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?

Gethe 07-02-13 03:43 PM

The second line would need to be:
Code:

local player_health = UnitHealth("player")

cicilia 07-03-13 05:01 AM

Quote:

Originally Posted by Gethe (Post 280709)
The second line would need to be:
Code:

local player_health = UnitHealth("player")

so i changed it to.

Quote:

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?

semlar 07-03-13 05:06 AM

Put an 'end' before the return statement.

cicilia 07-03-13 05:12 AM

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"?

semlar 07-03-13 05:18 AM

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.

cicilia 07-03-13 05:28 AM

Thank you very much..


All times are GMT -6. The time now is 07:44 PM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI