Need help with Stuf Unit Frames custom LUA
Hey there,
As the title suggests, I'm looking for some help with some custom LUA coding for Stuf Unit Frames. I'll try to be as specific as I can be while trying this at 5:45am. :D What I'm trying to do is have my power bar display a percentage for any class that uses mana and a flat number for everything else (ie. energy, rage, runic power, focus, etc.) I've spent a couple hours researching the UnitPower LUA stuff, but I just couldn't get it to work. Here's the code I have so far: Code:
function(unit, cache, textframe) |
Code:
if UnitPowerType("player") == 0 then |
Thank you for your reply. My previous code did actually have an end statement. It was tucked away at the end of the else statement. Unfortunately, your code doesn't seem to work for me either. The power bar is just blank, which I really don't understand. It's like the code isn't even getting past the if statement. :confused:
I did a little bit of testing with the code, and I can get it to display UnitPowerType as text or UnitPower as a flat unit, so I know it can handle those arguments, but for whatever reason it seems to stall on the if statements. I even tried to set up a local variable and use that in the if statement to display just plain text and it didn't work. I'm beginning to wonder if Stuf Unit Frames even allows if statements at all. D: |
Quote:
If that is your actual code then it would be throwing a lua error. |
Code:
function(unit, cache, textframe) |
You need another end at the end of that to close the function.
You are only closing the "if" statement. You aren't closing the function. Lua errors need to be enabled through the "help" section of the in-game escape menu if they aren't enabled. |
Your code:
Code:
function(unit, cache, textframe) Code:
function(unit, cache, textframe) |
Well. I feel like an idiot now. :o I had been assuming that the end statement was for the function as a whole. I suppose I should have realized that, considering my programming background is with C and C++. I suppose I should have assumed that the end statement worked like } does in those languages or that you couldn't write an if else statement without closing the else like C++. I have a lot to learn about LUA still it seems. I really appreciate your help, both of you. :P Sorry if I seemed like an ass.
In any case, it seems that it works now. Even with my original code. I just needed that extra end. Damn curly brackets were always the bane of my existence with C++ too. >_> |
All times are GMT -6. The time now is 01:06 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI