 |
07/09/09, 5:51 PM
|
#121
|
|
Glass Joe
|
When I use
if UnitPowerType(unit) == 0 then
local cur,max=Power(unit),MaxPower(unit)
return "%s || %s%%",Short(cur),Percent(cur,max)
else
cur=Power(unit)
return cur
end
I get a display like this:
%d | 100%
|
|
|
|
|
07/09/09, 6:39 PM
|
#122
|
|
Piston Honda
|
Originally Posted by Tastie
I get a display like this:
%d | 100%
|
Whoops, I forgot ",true" within the Short() call. Why the default isn't true, i don't get.
use this:
if UnitPowerType(unit) == 0 then
local cur,max=Power(unit),MaxPower(unit)
return "%s || %s%%",Short(cur,true),Percent(cur,max)
else
cur=Power(unit)
return cur
end
|
correlation =/= causation
|
|
|
07/09/09, 8:06 PM
|
#123
|
|
Glass Joe
|
Let me be more visual
With the code you gave me
if UnitPowerType(unit) == 0 then
local cur,max=Power(unit),MaxPower(unit)
return "%s || %s%%",Short(cur,true),Percent(cur,max)
else
cur=Power(unit)
return cur
end
my mana still displays as absolute. I can change Short(cur,true) to VeryShort(cur,true) but as my mana goes down, it still rounds up. So if I have a base mana of 5824 and it goes down to 4900, then my mana display will look like 5k rather than 4.9k. Basically what I am asking for is for my mana/power to mirror how I have my health displayed.
Sorry if I have been unclear . Having no LUA knowledge...customizing things are a tad difficult for me. And again, thanks a lot for your responses Hotan.
|
|
|
|
|
07/09/09, 8:25 PM
|
#124
|
|
Piston Honda
|
Tastie: I'm not seeing what you are saying, or it just doesn't work:
(a) both Short() and VeryShort() round to the nearest, rather than always rounding up.
(b) Short() doesn't touch numbers under 10k, you are going to have to circumvent the use of Short() if that is the goal. The reason for this situation is that Short() forces all numbers to be displayed in 4 characters (excluding ".") or less, and four digit numbers already do that.
I think this does what you want:
if UnitPowerType(unit) == 0 then
local cur,max=Power(unit),MaxPower(unit)
if cur <999 then
return "%s || %s%%",cur,Percent(cur,max)
elseif cur<9999 then
return "%.2fk || %s%%",cur/1000,Percent(cur,max)
else
return "%s || %s%%",Short(cur,true),Percent(cur,max)
end
else
cur=Power(unit)
return cur
end
This code basically is Short() with an added condition to force four digit numbers to be displayed as #.##k
This revereses the percent and absolute displays, as it is done in health, if this is what you want:
if UnitPowerType(unit) == 0 then
local cur,max=Power(unit),MaxPower(unit)
if cur <999 then
return"%s%% || %s",Percent(cur,max),cur
elseif cur<9999 then
return "%s%% || %.2fk",Percent(cur,max),cur/1000
else
return "%s%% || %s",Percent(cur,max),Short(cur,true)
end
else
cur=Power(unit)
return cur
end
Last edited by Hotan : 07/14/09 at 7:27 PM.
Reason: changed #.#k to #.##k
|
correlation =/= causation
|
|
|
07/09/09, 8:32 PM
|
#125
|
|
Glass Joe
|
Thanks! That is exactly what I wanted.
|
|
|
|
|
07/09/09, 9:19 PM
|
#126
|
|
Von Kaiser
|
Having a bit of a issue with a threat display luatext I am working on. I based this text on the existing threat text included in Pitbull4, however I wanted to add colours to the text based on the threat level.
The issue that is occurring is after a period of time in combat in a 25 man raid everything starts lagging, and I've also had a red warning pop-up occur in game complaining that something (it didn't say what) was using a lot of memory.
I'm not totally certain which text i'm using is the guilty party (I use a number, however the rest are basically what have been posted here already and seem to work fine), however I suspect it is this one:
local unit_a,unit_b = ThreatPair(unit)
if unit_a and unit_b then
local _,_,percent = UnitDetailedThreatSituation(unit_a, unit_b)
if percent and percent < 50 then
return "|cFF00FF00%s%%|r",Round(percent,1)
elseif percent and percent < 85 then
return "|cFFFFFF00%s%%|r",Round(percent,1)
elseif percent and percent > 85 then
return "|cFFFF0000%s%%|r",Round(percent,1)
end
end
I'm not a programmer! Is it possible for something this small to create a lot of garbage?
|
|
|
|
|
07/10/09, 7:07 AM
|
#127
|
|
Glass Joe
Blood Elf Hunter
Zenedar (EU)
|
Thought I'd share some of my custom Hunter specific LuaTexts ^_^
Please let me know if they can be optimised in any way.
--Pet Name - Happiness
local happiness = GetPetHappiness()
local happy
if happiness == 1 then
happy = "D63126"
elseif happiness == 2 then
happy = "FFDB00"
elseif happiness == 3 then
happy = "1F295C"
else
happy = "FFFFFF"
end
return '|cff%s%s|r',happy,Name(unit)
Will colour your pet's name according to his happiness level. (EDIT: Forgot I got this one off this thread [Post 101] >_< Apologies)
-- Hunter's Mark
Outline()
local i = 1
local mark = true
while true do
local name,_,icon = UnitAura(unit,i,"HARMFUL")
if not name then
break
elseif name == "Hunter's Mark" then
mark = false
end
i = i + 1
end
if (UnitIsEnemy("player","target")) then
return "|cffFF6600%s|r",mark and "<<<Hunter's Mark!>>>" or ''
end
Will display "<<<Hunter's Mark!>>>" in bright orange text if the hostile target doesn't have the Hunter's Mark debuff.
The following LuaText displays one's current Attack Power, Crit%, Armor Pen and Hit Rating.
I've got one tiny issue with this one which I'd appreciate some insight on. I just can't seem to find the appropriate API function call to get one's total Attack Power. At the moment, I'm using "UnitRangedAttackPower("player")" but I've discovered that this call only returns one's base AP and not the total buffed AP. If anyone can shed some light on this one I'd appreciate it.
-- Stats
local ap,cr,arp,hr = UnitRangedAttackPower("player"), GetRangedCritChance(), GetCombatRating(25), GetCombatRating(7)
return "|cff94C7FAAP:%.0f \nCr:%.2f%% \nArP:%.0f HR:%.0f|r", ap,cr,arp,hr
Last edited by Ferretmonger : 07/10/09 at 10:02 AM.
|
|
|
|
|
07/12/09, 3:49 PM
|
#128
|
|
Von Kaiser
Gnome Warlock
Doomhammer (EU)
|
I used to remove the player race display from PitBull's Class: Player classes only preset in DogTags, but so far all my attempts with the LuaText version just ruined the tag eventually. How do I keep the race display for NPCs (for pet/NPC types) but disable it for player races?
|
Everyone always coming to Zathras with problems. Great responsibilities. But Zathras does not mind. Zathras trained in crisis management.
|
|
|
07/12/09, 7:29 PM
|
#129
|
|
Von Kaiser
|
return '%s %s', Name(unit), UnitIsPlayer(unit) and '' or SmartRace(unit)
or whatever formatting you like, but that's the general idea.
|
|
|
|
|
07/13/09, 4:28 PM
|
#130
|
|
Piston Honda
Blood Elf Mage
Thunderlord
|
I searched the thread and found nothing with crowd control, sap or poly in the post. What I'm looking for is this. I have a current dogtag that I need to be remade into the new LuaText. I am absolutely clueless when it comes to Lua. It took me quite some time to get used to dogtags, and finally got it down.
This is the code I need changed, if anyone can help me out I'd be most thankful. Also, if there is any sort of tutorial or a wiki for the new LuaTexts I'd be happy to read into it myself.

[Outline (if HasAura("Polymorph", unit="focus") and (AuraDuration("Polymorph", unit="focus") <= 5) then
"Resheep NOW!":Yellow
end) (if HasAura("Polymorph", unit="focus") and (AuraDuration("Polymorph", unit="focus") > 5) and (AuraDuration("Polymorph") <= 6) then
"Breaking in 6!":Fuchsia
end) (if HasAura("Polymorph", unit="focus") and (AuraDuration("Polymorph", unit="focus") > 6) and (AuraDuration("Polymorph") <= 7) then
"Breaking in 7!":Fuchsia
end) (if HasAura("Polymorph", unit="focus") and (AuraDuration("Polymorph", unit="focus") > 7) and (AuraDuration("Polymorph") <= 8) then
"Breaking in 8!":Fuchsia
end) (if HasAura("Polymorph", unit="focus") and (AuraDuration("Polymorph", unit="focus") > 8) and (AuraDuration("Polymorph") <= 9) then
"Breaking in 9!":Fuchsia
end) (if HasAura("Polymorph", unit="focus") and (AuraDuration("Polymorph", unit="focus") > 9) and (AuraDuration("Polymorph") <= 10) then
"Breaking in 10!":Fuchsia
end) (if HasAura("Polymorph", unit="focus") and (AuraDuration("Polymorph", unit="focus") > 10) and (AuraDuration("Polymorph") <= 11) then
"Breaking in 11!":Cyan
end) (if HasAura("Polymorph", unit="focus") and (AuraDuration("Polymorph", unit="focus") > 11) and (AuraDuration("Polymorph") <= 12) then
"Breaking in 12!":Cyan
end) (if HasAura("Polymorph", unit="focus") and (AuraDuration("Polymorph", unit="focus") > 12) and (AuraDuration("Polymorph") <= 13) then
"Breaking in 13!":Cyan
end) (if HasAura("Polymorph", unit="focus") and (AuraDuration("Polymorph", unit="focus") > 13) and (AuraDuration("Polymorph") <= 14) then
"Breaking in 14!":Cyan
end) (if HasAura("Polymorph", unit="focus") and (AuraDuration("Polymorph", unit="focus") > 14) and (AuraDuration("Polymorph") <= 15) then
"Breaking in 15!":Cyan
end) (if HasAura("Polymorph", unit="focus") and (AuraDuration("Polymorph", unit="focus") > 15) and ~Dead then
"Sheep Safe":Green
end) (if ~HasAura("Polymorph", unit="focus") and InCombat(unit="player") and ~Dead then
"Broken!":Red
end)]
I know Pitbull 4 allows you to still use dogtags, but I keep getting an error when I try to use this code that I successfully use in PB3.
Edit: There is one more that I could use help with, it's a bit simpler. Just makes names smaller and adds code for status type when they're afk/dead/offline.
[ClassColor(Offline:Truncate(7, nil)) or ClassColor(AFK:Truncate(3, nil)) or ClassColor(DeadType) or ClassColor Name:Truncate(6, nil)]
Last edited by Ohi : 07/13/09 at 4:30 PM.
Reason: added additional code
|
|
|
|
|
07/13/09, 6:09 PM
|
#131
|
|
Piston Honda
|
Ohi: The following code does do the tag, for the most part.
if not Dead(unit) then
Outline()
local poly = false
local i=1
while true do
local name,_,_,_,_,_,exp = UnitAura(unit,i,"HARMFUL")
if not name then
break
elseif name == "Polymorph" then
poly = true
rem = exp - GetTime()
break
end
i=i+1
end
if poly then
UpdateIn(0.5)
if rem > 15 then
return "|cff00ff00Sheep Safe|r"
elseif rem > 10 then
return "|cff00ffffBreaking in %d!|r",rem
elseif rem > 5 then
return "|cffff00ffBreaking in %d!|r",rem
else
return "|cffffff00Resheep NOW!|r"
end
else
return "|cffff0000BROKEN!|r"
end
end
Attach this to the Focus frame and use the UNIT_AURA event, and the UpdateIn(1) call will take care of the duration change updates.
As for the other tag:
local val = strsub(Name(unit),1,6)
local r,g,b=ClassColor(unit)
if not UnitIsConnected(unit) then
val="Offline"
elseif UnitIsAFK(unit) then
val="AFK"
elseif UnitIsDead(unit) then
val="Dead"
elseif UnitIsGhost(unit) then
val="Ghost"
end
return "|cff%02x%02x%02x%s|r",r,g,b,val
Last edited by Hotan : 07/15/09 at 6:28 PM.
|
correlation =/= causation
|
|
|
07/13/09, 7:42 PM
|
#132
|
|
Piston Honda
Blood Elf Mage
Thunderlord
|
@Hotan
Thank you very much.
The top one ONLY goes on the focus frame so it won't be an issue (or consideration on my part). Worked like a charm!
|
|
|
|
|
07/15/09, 6:56 PM
|
#133
|
|
Von Kaiser
Blood Elf Paladin
Korgath
|
I was wondering if someone could help me with name code on my target frame in pitbull4. I switched to luatexts a while ago and this has been bugging me.
Using this code for names (which I think is default):
return '%s %s%s %s',Name(unit),Angle(AFK(unit) or DND(unit))
My target frame looks like this:
http://spanko.shackspace.com/name.jpg
What I want is for the name text to go to a new line under the first when its too long. For example instead of how it looks in the screenshot it would look like this:
Spankolol
<AFK (xx:xx)>
Or on a target with a long name like "Captain Longnamelolol" it would look like this:
Captain
Longnamelolol
I had dogtags setup this way but don't even remember how I did it and I've been trying to for like 45 minutes to do it with luatexts and failed.
|
|
|
|
|
07/20/09, 3:42 PM
|
#134
|
|
Banned
Tauren Druid
Mazrigos (EU)
|
Perhaps not the place but is there a place where people are showing their Pitbull layouts and provide links/lua text examples?
|
|
|
|
|
07/20/09, 8:43 PM
|
#135
|
|
Glass Joe
|
The Pitbull4 wowace forum is fairly active. Not too many full UI posts, but some people are putting up their unitframes. (This is mainly to give visual aid to their questions though, rather than showing off)
You can find that thread here: PitBull 4.0 - WowAce Forums
I think the problem may be that most of the people creating luatexts don't feel very confident with the language, and are reluctant to post their texts except to ask for assistance.
When I get home I will post a few of the texts I'm using, perhaps it will encourage others to do the same. We can turn this thread into the sort of thread you are looking for.
In response to spanko's question:
Initially I didn't think what you were asking was possible, but after reading This I started wondering.
You could try accessing the fontstring object directly, and using API calls that are detailed on wowwiki.
If you check the object page Here it looks as though you could add
font_string:SetWidth(100)
somewhere in your text, (with 100 replaced by whatever width you want the text to start wrapping at is)
Last edited by ctrlfrk : 07/20/09 at 8:58 PM.
|
|
|
|
|
|