 |
06/27/09, 12:30 PM
|
#91
|
|
Piston Honda
Human Paladin
Kul Tiras (EU)
|
Originally Posted by Shaewyn
Is there currently any way to get my raid group in a LuaText? I haven't seen it as any of the stated functions, and I haven't had any luck looking for other ways to get Pitbull to display which raid group I'm in (on my unit frame)
|
If anyone has any ideas on how to get the equivalent of [RaidGroup] in LuaText, it'd be much appreciated.
|
|
|
|
|
06/27/09, 1:16 PM
|
#92
|
|
Glass Joe
Tauren Shaman
Azshara (EU)
|
I wrote a little pom-tracker for your player-frame:
if UnitInRaid(unit) then
local raid=GetNumRaidMembers()
for r=1,raid do
local un = "raid"..r
local i=1
while true do
local name,_,_,count,_,_,expTime,unCstr,_= UnitAura(un,i,"HELPFUL")
if not name then
break
end
if name=="Prayer of Mending"and unCstr==unit and count and expTime then
local r,g,b = ClassColor(un)
return "|cff%02x%02x%02x%s|r: %d - %d",r,g,b,UnitName(un),count,expTime-GetTime()
end
i=i+1
end
end
end
For people who are interested in other people's POM can set this tag up at the target-frame.
In case you want to track other Buffs/Debuffs just edit the spellname.
Currently I'm looking for a smooth way for determinating if the player is in a raid or a party and setting up the unit-ids according to this.
I thought of something like this:
local pre
if UnitInRaid(unit) or GetNumPartyMembers() > 0 then
if GetNumRaidMembers() == 0 then pre="party" else pre="raid" end
end
The pre variable then works as an affix with the loop-id to create the unit-id. I'm still missing an option to implement the case when the player is not in a party, because in that special case the unit-id isn't player1 but player.
|
|
|
|
|
06/27/09, 3:04 PM
|
#93
|
|
Von Kaiser
|

Originally Posted by Uhman
I wrote a little pom-tracker for your player-frame:
if UnitInRaid(unit) then
local raid=GetNumRaidMembers()
for r=1,raid do
local un = "raid"..r
local i=1
while true do
local name,_,_,count,_,_,expTime,unCstr,_= UnitAura(un,i,"HELPFUL")
if not name then
break
end
if name=="Prayer of Mending"and unCstr==unit and count and expTime then
local r,g,b = ClassColor(un)
return "|cff%02x%02x%02x%s|r: %d - %d",r,g,b,UnitName(un),count,expTime-GetTime()
end
i=i+1
end
end
end
For people who are interested in other people's POM can set this tag up at the target-frame.
In case you want to track other Buffs/Debuffs just edit the spellname.
Currently I'm looking for a smooth way for determinating if the player is in a raid or a party and setting up the unit-ids according to this.
I thought of something like this:
local pre
if UnitInRaid(unit) or GetNumPartyMembers() > 0 then
if GetNumRaidMembers() == 0 then pre="party" else pre="raid" end
end
The pre variable then works as an affix with the loop-id to create the unit-id. I'm still missing an option to implement the case when the player is not in a party, because in that special case the unit-id isn't player1 but player.
|
local pre,size,start = "raid",GetNumRaidMembers(),1
if size <= 0 then
pre = "party"
size = GetNumPartyMembers()
start = 0
end
for i=start,size do
local unit
if i == 0 then
unit = "player"
else
unit = pre .. i
end
-- Whatever you want here
end
|
|
|
|
|
06/27/09, 6:41 PM
|
#94
|
|
Piston Honda
|
Originally Posted by Camaris
If anyone has any ideas on how to get the equivalent of [RaidGroup] in LuaText, it'd be much appreciated.
|
if UnitInRaid(unit) then
local size = GetNumRaidMembers()
local uname=Name(unit)
i=1
while i<=size do
local name,_,subgroup = GetRaidRosterInfo(i)
if uname==name then
return "(%s)", subgroup
end
i=i+1
end
end
You will need to add the event RAID_ROSTER_UPDATE and select Update for All.
edit: I added a version with class coloring, since that is how I want to use it.
if UnitInRaid(unit) then
local size = GetNumRaidMembers()
local r,g,b=ClassColor(unit)
local uname=Name(unit)
i=1
while i<=size do
local name,_,subgroup = GetRaidRosterInfo(i)
if uname==name then
return "|cff%02x%02x%02x(%s)|r",r,g,b,subgroup
end
i=i+1
end
end
Last edited by Hotan : 06/27/09 at 6:47 PM.
|
correlation =/= causation
|
|
|
06/28/09, 6:40 AM
|
#95
|
|
Piston Honda
Human Paladin
Kul Tiras (EU)
|
I discovered that this
local _,_, subgroup = GetRaidRosterInfo(GetNumRaidMembers())
makes subgroup the number of the raidgroup you yourself are in. If like me you're using the "RaidGroup" text on the player frame only (for the "group 4 goes left!" type of situations), this will suffice instead of the loop above.
Maybe a nice excercise for a sunday afternoon... a LuaText version of [TalentTree] (the tag that gives you "Protection", "Affliction", etc.).
|
|
|
|
|
06/29/09, 12:16 AM
|
#96
|
|
Von Kaiser
|
Originally Posted by Camaris
Maybe a nice excercise for a sunday afternoon... a LuaText version of [TalentTree] (the tag that gives you "Protection", "Affliction", etc.).
|
NotifyInspect(unit)
local talents = {}
for tab = 1, GetNumTalentTabs(true) do
local name, _, spent = GetTalentTabInfo(tab, true)
tinsert(talents, {Name = name, Spent = spent})
end
table.sort(talents, function(a, b) return a.Spent > b.Spent end)
return talents[1].Name
Depending on how LuaTexts handles updates the above might not be ideal, since you probably don't want to be creating a bunch of otherwise disposable tables on every update. It's the only way I could think to do it though, and worst case scenario is that is gives you a solid start.
|
|
|
|
|
06/29/09, 4:38 AM
|
#97
|
|
Glass Joe
Gnome Death Knight
Barthilas
|
I was a little unsatisfied with the Rune module in Pitbull4, so I decided to write a LuaTexts that did things exactly the way I like:
if UnitIsUnit("player",unit) and select(2, UnitClass(unit)) == "DEATHKNIGHT" then
local GetRuneCooldown = GetRuneCooldown
local GetRuneType = GetRuneType
local incomplete
local GetRuneString = function(rune)
local _, _, ready = GetRuneCooldown(rune)
if ready then
if GetRuneType(rune) == 1 then
return "|cffff0000B|r"
elseif GetRuneType(rune) == 2 then
return "|cff00ff00U|r"
elseif GetRuneType(rune) == 3 then
return "|cff0077ffF|r"
else
return "|cffff00ffD|r"
end
else
incomplete = true
if GetRuneType(rune) == 1 then
return "|cff333333B|r"
elseif GetRuneType(rune) == 2 then
return "|cff333333U|r"
elseif GetRuneType(rune) == 3 then
return "|cff333333F|r"
else
return "|cff333333D|r"
end
end
end
local runestring = ""
for i = 1, 6 do
runestring = runestring .. GetRuneString(i)
end
if incomplete or UnitAffectingCombat(unit) then return runestring end
end
This string is only visible on the player frame (for Death Knights only), and only when at least some of the runes are on cooldown or if we are in combat. Also, instead of that hard to read spiral, I've just got runes turning grey if they aren't ready: on or off.
It would be trivial to replace the text style with links to the blizzard icons or whatever. Hope someone finds it handy. Also, if I'm doing something plain sub-optimal or stupid then let me know.
EDIT: just stripped out some unnecessary variables and concatenations
EDIT: FYI, I've got this text listening to RUNE_POWER_UPDATE, RUNE_TYPE_UPDATE, UNIT_FLAGS.
Last edited by jokeyrhyme : 06/29/09 at 4:48 AM.
Reason: adding events
|
|
|
|
|
06/29/09, 5:13 AM
|
#98
|
|
Glass Joe
|
Hello there I was using the [HappyNum] Dogtag to color my pet's name according to its happiness. I was wondering how I could do this with luatext? Any help would be greatly appreciated.
Umm.. I did some looking around @ lua and i came up with this
local happiness, damagePercentage, loyaltyRate = GetPetHappiness()
local happy = ({"cffC41F3B", "cffFFF569", "cffABD473"})[happiness]
return '|%s%s|r',happy,Name(unit)
I am just wondering if this is the most efficient way of doing this?
Last edited by Methyl : 06/29/09 at 5:33 AM.
|
|
|
|
|
06/29/09, 8:35 AM
|
#99
|
|
Piston Honda
|
Originally Posted by Gorsgo
NotifyInspect(unit)
local talents = {}
for tab = 1, GetNumTalentTabs(true) do
local name, _, spent = GetTalentTabInfo(tab, true)
tinsert(talents, {Name = name, Spent = spent})
end
table.sort(talents, function(a, b) return a.Spent > b.Spent end)
return talents[1].Name
Depending on how LuaTexts handles updates the above might not be ideal, since you probably don't want to be creating a bunch of otherwise disposable tables on every update. It's the only way I could think to do it though, and worst case scenario is that is gives you a solid start.
|
You can't use NotifyInspect() like this. Once you request it, you have to wait for the server to send the event INSPECT_TALENT_READY before you can retrieve talent data from your target. Meanwhile, the player may have switched targets to someone else, and/or another addon may have requested talent data for someone else. It's therefore recommended to hook NotifyInspect() securely to prevent that.
You also need checks to make sure that the target is within interacting distance, that it's not an NPC, that it's not a PvP-flagged player of the opposite faction and that it's not the player targetting himself. You could get rid of the for loop by assuming 3 talent trees and checking that the target isn't a pet (unless you really want to know a pet's talent tree). A check for players with no talent points used (say below lvl 10 or respeccing) is also probably needed. Finally, a re-scan is probably needed if the target changes spec while it's targetted.
That's all the issues I can come up with in 5 minutes. Not sure how to take care of all this in LuaTexts. This might need to be one of the helper functions in PitBull 4, if Shefki thinks it's worth considering.
|
|
|
|
|
06/29/09, 1:44 PM
|
#100
|
|
Von Kaiser
|
Originally Posted by ShadowEric
That's all the issues I can come up with in 5 minutes. Not sure how to take care of all this in LuaTexts. This might need to be one of the helper functions in PitBull 4, if Shefki thinks it's worth considering.
|
In order to do the talent stuff right you have to use LibTalentQuery or whatever the lib is called. I really don't want to suck in an extra dependency for a very very very few people that might use this. However you can use the library from within a LuaText. You'd just have to be sure to install it yourself if you don't already have it from some other addon. If I do anything it'll be writing an example how to do it. I doubt I'm gonna add a helper to do it since I consider the use really rare and the overhead of an extra library for the people that don't need it is unacceptable IMHO.
|
|
|
|
|
06/29/09, 1:50 PM
|
#101
|
|
Von Kaiser
|
Originally Posted by Methyl
Umm.. I did some looking around @ lua and i came up with this
local happiness, damagePercentage, loyaltyRate = GetPetHappiness()
local happy = ({"cffC41F3B", "cffFFF569", "cffABD473"})[happiness]
return '|%s%s|r',happy,Name(unit)
I am just wondering if this is the most efficient way of doing this?
|
You really don't want to make a temporary table like that. It's certainly convenient but you're produce garbage everytime. This is much better efficiency wise:
local happiness = GetPetHappiness()
local happy
if happiness == 1 then
happy = "C41F3B"
elseif happiness == 2 then
happy = "FFF569"
elseif happiness == 3 then
happy = "ABD473"
else
happy = "FFFFFF"
end
return '|cff%s%s|r',happy,Name(unit)
Also yours wouldn't function if happiness wasn't one of the three values. This just uses white if the pet doesn't have a happiness (vehicle situations for example)
|
|
|
|
|
06/30/09, 3:58 AM
|
#102
|
|
Von Kaiser
|
I would like to fine tune my Targets HP text a bit.
If the target is at full then only show "Current HP | Max HP".
If the Target is friendly then only show "Current HP | Max HP" no matter what % its at.
If the target is below 100% HP then "Current HP | Max HP | HP %" . I would like the % Color coded to change as it begins to drop.
I also want the numbers to be formatted like they are currently, "20.6k" and not 20612. But be seperated by a "|" and not "/".
Here what I'm using atm :
Outline()
local s = Status(unit)
if s then
return s
end
local cur, max = HP(unit), MaxHP(unit)
if UnitIsFriend(unit,"player") then
local miss = max - cur
if miss ~= 0 then
return "|cffff7f7f%s|r || %s/%s || %s%%",Short(miss,true),Short(cur,true),Short(max,true),Percent(cur,max)
end
end
return "%s/%s || %s%%",Short(cur,true),Short(max,true),Percent(cur,max)
Last edited by Dankz : 06/30/09 at 4:09 AM.
|
|
|
|
|
06/30/09, 5:48 AM
|
#103
|
|
Von Kaiser
|
Originally Posted by Dankz
If the target is at full then only show "Current HP | Max HP".
If the Target is friendly then only show "Current HP | Max HP" no matter what % its at.
If the target is below 100% HP then "Current HP | Max HP | HP %" . I would like the % Color coded to change as it begins to drop.
I also want the numbers to be formatted like they are currently, "20.6k" and not 20612. But be seperated by a "|" and not "/".
|
local min, max = HP(unit), MaxHP(unit)
local r, g, b = HPColor(min, max)
local showPercent = (UnitIsEnemy(unit, "player") and min < max)
return "%s | %s %s|cff%02x%02x%02x%s", Short(min, "%.1f"), Short(max, "%.1f"), showPercent and "| " or "", r, g, b, showPercent and VeryShort(Percent(min, max), "%.1f").."%" or ""
|
|
|
|
|
06/30/09, 3:04 PM
|
#104
|
|
Von Kaiser
|
Originally Posted by Gorsgo
local min, max = HP(unit), MaxHP(unit)
local r, g, b = HPColor(min, max)
local showPercent = (UnitIsEnemy(unit, "player") and min < max)
return "%s | %s %s|cff%02x%02x%02x%s", Short(min, "%.1f"), Short(max, "%.1f"), showPercent and "| " or "", r, g, b, showPercent and VeryShort(Percent(min, max), "%.1f").."%" or ""
|
Umm you're using Short wrong. The format parameter on Short is just a boolean to say if you want Short to do the format for you or not. If it's false it returns the format string and then the value to format and if it's true it returns a formatted value.
This allows a format to be avoided if it can be e.g.:
return Short(HP(unit))
Since it's the only thing being done Short can just control the format string being returned. But if you need to do something more complex where you need to set the format string yourself you pretty much need to let Short/VeryShort do the formatting themselves.
Also, you should always use || if you want a literal | in your output since it's an escape character for WoW.
You also concatenated the % on the end. You should let the C side code handle that by just passing it through as another parameter.
Here's the fixed up code.
local min, max = HP(unit), MaxHP(unit)
local r, g, b = HPColor(min, max)
local showPercent = (UnitIsEnemy(unit, "player") and min < max)
return "%s || %s %s|cff%02x%02x%02x%s%s", Short(min, true), Short(max, true), showPercent and "|| " or "", r, g, b, showPercent and VeryShort(Percent(min, max), true) or "",showPercent and '%' or ""
|
|
|
|
|
06/30/09, 5:00 PM
|
#105
|
|
Von Kaiser
|
Originally Posted by Shefki
Since it's the only thing being done Short can just control the format string being returned. But if you need to do something more complex where you need to set the format string yourself you pretty much need to let Short/VeryShort do the formatting themselves.
Also, you should always use || if you want a literal | in your output since it's an escape character for WoW.
You also concatenated the % on the end. You should let the C side code handle that by just passing it through as another parameter.
|
When I called Short(min) without the second parameter it displayed the format (%.1f) instead of the value. The one I posted works fine, but fair enough on the escape char change.
Is there any particular advantage to passing the % through as another value rather than concatenating, though?
|
|
|
|
|
|