Stuf Unit LUA help
I have this for my target name but I was hoping someone could help me with adding level and class color to the string.
function(unit) local name = UnitName(unit) if (name and string.len(name) > 10) then name = string.gsub(name, "([^%s]+) ", function(s) return string.sub(s,1,1) .. "." end) end return name end This code works fine as is but I can figure out how to add class color to the text or the level to it either. thanks much! |
Try this - it's based on portions of the "Target Name" text I use in my StUF uf's. This leaves the level uncolored, but colors the name by class.
Code:
function(unit) |
Just a quick question....Maybe i should start a new topic but it is directly related to what this post is about...What is the advantage of using LUA code to display name versus using the tags that exist in STUF already?
|
Quote:
BTW Worked fine but I have a weird thing with the name...between the level and the name I am getting an extra character - like on mob target its a "d" and on players it's an "5" and if I target myself, its a little 'o"(without quote marks). c/p'd twice and still same results..any clue? |
Yeah, 3 tiny typo's in the "return" line.
Change all of the *256 to *255. My bad. I'm going to edit the original post as well. |
Quote:
For example, this is what I use for my text1 Code:
function(unit, cache, textframe) What this mainly does, however, is it gives you a class-colored name. Multiple-word names ("Angry Guardsman") gives an abbreviated version ("A. Guardsman"). However, if you are not at full HP, it shows an HP Deficit text, a pipe, and then HP Percent. The only part of that, really, that I needed to use custom Lua for was the abbreviation of the names. However, because of that, I had to write the rest in Lua as well. Here's a more interesting text that I use (my "Power" text). Code:
function(unit, cache, textframe) If you're anything else, it shows your percentage of power - but if you're at full power, it just shows your maximum power. (ie, 99% OR 78532, for example). And, yes, all you Lua coders out there, please feel free to take a look at it and give me advice on how to make it better. I haven't really done any programming since 1997, and Lua wasn't very common back then, so this is all sorta tossed together with half-remembered scraps of programming theory and style. :) |
You are a doll! I am totally hijacking those for mine as they are tons more effiecent space wise than mine now - I have my power/hp on mourseover cause I havent had the room to "fit it all in" so thank you so much for sharing!
Funny how I looked /goggle for some threads on STUF LUA I could jack but found none (even the one on EJ was locked/outdated cause all my old codes no longer work with STUF any more) and the thread on the old WoW forums is gone now since Cata. So thanks again and I'll be sure if I find more to post them in hopes they help some out. OH - These below were taken from maybe Fuji or (dang I cant remember the name but they did a Paladin UI with vertical coding) these are UNTESTED for the most part but someone may know how to get the to work again....I'm sure its simple wording or something but I dont use them any more so...I will separate them with --------- BLOCK OF TEXT INC!! Code:
function(unit, cache) PET: Code:
function(unit, cache, textframe) PET HAPPY: Code:
function(unit, cache, textframe) COMBO POINTS: Code:
function(unit, cache, textframe) STRING STATES: Code:
function(unit, cache) -------------------------------- Code:
function(unit, cache, textframe) HEALTH STRING: Code:
function(unit, cache, textframe) ----------------------------- Vertical name: Code:
function(unit, cache, textframe) ---------------------------------- health vertical: Code:
function(unit, cache, textframe) |
*ahem* code blocks are your friend :)
carry on. :) |
hrm sorry but what are "code blocks"? I know it was a large wall of text >< sorry but if there was a better format then if someone can change it or tell me how :)
|
The [code] tag is what we use to mark off sections of code. It keeps formatting and allows the code to be read easier. :) When writing a post, it is the button on the toolbar with the # sign.
|
Sweet thanks Seerah!
|
You're welcome. I took the liberty of adding the whitespace back in to make it easier to read. It also made me realize that you're missing the first line to that first chunk of code. ;)
|
Fixed it I hope :)
|
The first chunk of code in her post is repeated later in her post, actually, with the missing line(s) - the "String States" section.
|
All times are GMT -6. The time now is 01:08 PM. |
vBulletin © 2024, Jelsoft Enterprises Ltd
© 2004 - 2022 MMOUI