Getting tired of fail DK tanks not being in the proper presence so i was hoping to get some help making a tag to display a single letter denoting what presence the DK is using (Blood/Unholy/Frost) so i know when to hold back and when to nag at tank ;p
Heh, cute. (Shame we can't do that for warriors!) The basis for this text is the function UnitAura. I also went ahead and color-coded the letter. (The following code is untested, but is copied from code that works.)
local text = ""
if UnitAura(unit, "Unholy Presence") ~= nil then
text = text .. format("|cff80ff80%s|r", "U")
end
if UnitAura(unit, "Blood Presence") ~= nil then
text = text .. format("|cffff8080%s|r", "B")
end
if UnitAura(unit, "Frost Presence") ~= nil then
text = text .. format("|cff8080ff%s|r", "F")
end
return text
Make sure the text is registered for UNIT_AURA. You should be able to see how to add Righteous Fury to that list, too :)
Sempre, You're asking for a lot of things and I can't figure out what you want help with. Do you need to know how string manipulation works in LUA? I thought the very short missing hp was already a default text, so you could see how that is done.
In the meantime I wrote my own injection function using some evil hooking. It works, but might easily break when PitBull changes layout internals or LuaText changes options. :rolleyes:
Heh, cute. (Shame we can't do that for warriors!) The basis for this text is the function UnitAura. I also went ahead and color-coded the letter. (The following code is untested, but is copied from code that works.)
local text = ""
if UnitAura(unit, "Unholy Presence") ~= nil then
text = text .. format("|cff80ff80%s|r", "U")
end
if UnitAura(unit, "Blood Presence") ~= nil then
text = text .. format("|cffff8080%s|r", "B")
end
if UnitAura(unit, "Frost Presence") ~= nil then
text = text .. format("|cff8080ff%s|r", "F")
end
return text
Make sure the text is registered for UNIT_AURA. You should be able to see how to add Righteous Fury to that list, too :)
Thanks ill give it a test (got an indicator for RF already since i tank with my pally, but the system i use for that dun work with DK's)
Sempre, You're asking for a lot of things and I can't figure out what you want help with. Do you need to know how string manipulation works in LUA? I thought the very short missing hp was already a default text, so you could see how that is done.
These are all for PB4. I could manage to create single parts of the things I asked for, but I couldn't put them together successfully, or, in the case of the hp text, I could not limit it to a few digits. These are things I would like to have in one text option so that they will either appear together or will only under certain conditions.
Plainly, I was unable to create these texts because I lack the knowledge to do so.
These are all for PB4. I could manage to create single parts of the things I asked for, but I couldn't put them together successfully, or, in the case of the hp text, I could not limit it to a few digits. These are things I would like to have in one text option so that they will either appear together or will only under certain conditions.
Plainly, I was unable to create these texts because I lack the knowledge to do so.
for HP use Short/VeryShort to limit the number of digits.
return VeryShort(max)
return Short(cur)
return miss
max, cur, miss needs to be set local to work
local cur, max = HP(unit), MaxHP(unit)
local miss = max - cur
Thanks Kerecha, managed to get the shortened hp. Now I want to join these..
local cur, max = HP(unit), MaxHP(unit)
local miss = max - cur
if miss ~=0 then
return VeryShort(-miss)
and
return "%s", strsub(Name(unit), 1, 3)
..so that the first three characters of the unit's name is shown if the target hasn't lost any hp. Tried using 'else' and some other things but they just returned error messages. What do I need to add?
Thanks Kerecha, managed to get the shortened hp. Now I want to join these..
local cur, max = HP(unit), MaxHP(unit)
local miss = max - cur
if miss ~=0 then
return VeryShort(-miss)
and
return "%s", strsub(Name(unit), 1, 3)
..so that the first three characters of the unit's name is shown if the target hasn't lost any hp. Tried using 'else' and some other things but they just returned error messages. What do I need to add?
Maybe my health display can give you some help.
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
if cur <300 then
return "|cffff0000-%d|r", miss
elseif cur < 6000 then
return "|cffffa500-%d|r", miss
else
return "-%d",miss
end
else
return VeryShort(max)
end
end
It shows offline/dead if they are, and if they are online and alive it shows max HP if they are at full health and if they have lost HP it shows missing HP.
Should do what you want it to if you change the
local s = Status(unit)
if s then
return s
end
To show name if maxhp
roughly
sett the locals
if statement to check if max HP
then show name
end
if miss ~=0 (missing not 0)
then show missing
end
sett the locals
if statement to check if max HP
then show name
end
if miss ~=0 (missing not 0)
then show missing
end
I think I got all of these except checking if the unit is at max HP.
local cur, max = HP(unit), MaxHP(unit)
local miss = max - cur
if max then
return "%s", strsub(Name(unit), 1, 3)
end
if miss ~=0 then
return VeryShort(-miss)
end
This didn't give me any errors but as above, it never displayed the hp, just the name.
I think I got all of these except checking if the unit is at max HP.
local cur, max = HP(unit), MaxHP(unit)
local miss = max - cur
if max then
return "%s", strsub(Name(unit), 1, 3)
end
if miss ~=0 then
return VeryShort(-miss)
end
This didn't give me any errors but as above, it never displayed the hp, just the name.
Your not actually comparing the max to anything you would have to do "if cur == max then" afaik
Try
local cur, max = HP(unit), MaxHP(unit)
if UnitIsFriend(unit,"player") then
local miss = max - cur
if miss == 0 then
return string.sub(Name(unit),1,20)
end
if miss ~= 0 then
return "-%d",miss
end
end
You can chage the 20 in return string.sub(Name(unit),1,20) to as many letters as you want.
I actually just noticed something. The text doesn't update AT ALL. It only switches to the correct value after I /reloadui or refresh the game in some other way.
This is not the case with all texts, just this one. I am clueless as to what is causing this.
I actually just noticed something. The text doesn't update AT ALL. It only switches to the correct value after I /reloadui or refresh the game in some other way.
This is not the case with all texts, just this one. I am clueless as to what is causing this.
Have you set the event to "UNIT_HEALTH" ?
It won't update unless you have set a proper event for it.
I had it set to UNIT_HEALTH. Changed it to something completely different and back, relogged and everything works! Thanks for the reminder ;-)
Now I need to work out how to add AFK/DND notifications through lua, however I need it to display next to the abbreviated name instead of replacing it. No idea where to start :|
I had it set to UNIT_HEALTH. Changed it to something completely different and back, relogged and everything works! Thanks for the reminder ;-)
Now I need to work out how to add AFK/DND notifications through lua, however I need it to display next to the abbreviated name instead of replacing it. No idea where to start :|
just make a new text and place it after the name/hp one, thou afk/dnd are waste of space since ppl have a habbit of not unflagging those even when they are not afk/dnd. I just use offline and dead
1: Name (left align)
2: Druid form (1/2 letters) (left align)
3: Mana (very short when full, % when not hides when dead/dc to prevent overlapping with status text and timer) (center)
4: HP (veryshort when full, missing when not, colorcoded based on HP left, replaced with status and time when dead/ghost or Offline) (right align)
I actually only use absolute hp/status and mana on most frames. I just add little afk/dnd texts for group frames so I know if someone is slacking really.
Is there a way to show text as a single letter using lua? I basically want to show afk/dnd as a single letter, the duration doesn't matter to me that much.
Managed to create the following which shows me my name and afk/dnd but only the names of other people.
local afk, dnd = AFK(unit), DND(unit)
if afk then
return "a %s", strsub(Name(unit), 1, 24)
end
if dnd then
return "b %s", strsub(Name(unit), 1, 24)
end
return "%s", strsub(Name(unit), 1, 24)
I actually only use absolute hp/status and mana on most frames. I just add little afk/dnd texts for group frames so I know if someone is slacking really.
Is there a way to show text as a single letter using lua? I basically want to show afk/dnd as a single letter, the duration doesn't matter to me that much.
Yeah, you can set it to display pretty much anything, from icons to single letters, maybe just a * somewhere (i use that on my raidframes to denote a player thats not maxlvl)
This doesn't work for me unfortunately, the missing hp never replaces the name, no matter how much damage I've taken.
"else" definitely works and is much more legible. Now that you've found some other bugs that would have prevented it from working, I don't want you to go on believing else was at fault! (Note that if you want an else if, it's "elseif" in lua. The syntax error from "else if" is not helpful, either.)
if max then
return "%s", strsub(Name(unit), 1, 3)
end
To expand a bit on what Kerecha said, this doesn't do what you were expecting. "if max then" is equivalent to
if max ~= nil and (type(max) ~= "boolean" or max == true) then
Since max was always a "number", your conditional was always true. As a C++ programmer, I made that mistake a lot
Since max was always a "number", your conditional was always true. As a C++ programmer, I made that mistake a lot
In retrospect, what you've said is actually pretty obvious and it makes total sense, I can only say the reason why I tried values that I didn't even expect to work was down to not knowing how to check for something like maximum HP. Thank you for your explanation.
Managed to create the following which shows me my name and afk/dnd but only the names of other people.
local afk, dnd = AFK(unit), DND(unit)
if afk then
return "a %s", strsub(Name(unit), 1, 24)
end
if dnd then
return "b %s", strsub(Name(unit), 1, 24)
end
return "%s", strsub(Name(unit), 1, 24)
Anyone able to help with this?
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Heh, cute. (Shame we can't do that for warriors!) The basis for this text is the function UnitAura. I also went ahead and color-coded the letter. (The following code is untested, but is copied from code that works.)
Make sure the text is registered for UNIT_AURA. You should be able to see how to add Righteous Fury to that list, too :)
Nice idea, ticket filed! :)
In the meantime I wrote my own injection function using some evil hooking. It works, but might easily break when PitBull changes layout internals or LuaText changes options. :rolleyes:
Thanks ill give it a test (got an indicator for RF already since i tank with my pally, but the system i use for that dun work with DK's)
These are all for PB4. I could manage to create single parts of the things I asked for, but I couldn't put them together successfully, or, in the case of the hp text, I could not limit it to a few digits. These are things I would like to have in one text option so that they will either appear together or will only under certain conditions.
Plainly, I was unable to create these texts because I lack the knowledge to do so.
for HP use Short/VeryShort to limit the number of digits.
return VeryShort(max)
return Short(cur)
return miss
max, cur, miss needs to be set local to work
local cur, max = HP(unit), MaxHP(unit)
local miss = max - cur
local cur, max = HP(unit), MaxHP(unit)
local miss = max - cur
if miss ~=0 then
return VeryShort(-miss)
and
return "%s", strsub(Name(unit), 1, 3)
..so that the first three characters of the unit's name is shown if the target hasn't lost any hp. Tried using 'else' and some other things but they just returned error messages. What do I need to add?
Maybe my health display can give you some help.
It shows offline/dead if they are, and if they are online and alive it shows max HP if they are at full health and if they have lost HP it shows missing HP.
Should do what you want it to if you change the
To show name if maxhp
roughly
sett the locals
if statement to check if max HP
then show name
end
if miss ~=0 (missing not 0)
then show missing
end
This doesn't work for me unfortunately, the missing hp never replaces the name, no matter how much damage I've taken.
I think I got all of these except checking if the unit is at max HP.
This didn't give me any errors but as above, it never displayed the hp, just the name.
Your not actually comparing the max to anything you would have to do "if cur == max then" afaik
Try
You can chage the 20 in return string.sub(Name(unit),1,20) to as many letters as you want.
Set event to UNIT_HEALTH
Tested and seems to work fine for me
This is not the case with all texts, just this one. I am clueless as to what is causing this.
Have you set the event to "UNIT_HEALTH" ?
It won't update unless you have set a proper event for it.
The text i posted is tested and does work.
Now I need to work out how to add AFK/DND notifications through lua, however I need it to display next to the abbreviated name instead of replacing it. No idea where to start :|
Also wondering..
Why do we use == and not a single equals sign?
just make a new text and place it after the name/hp one, thou afk/dnd are waste of space since ppl have a habbit of not unflagging those even when they are not afk/dnd. I just use offline and dead
1: Name (left align)
2: Druid form (1/2 letters) (left align)
3: Mana (very short when full, % when not hides when dead/dc to prevent overlapping with status text and timer) (center)
4: HP (veryshort when full, missing when not, colorcoded based on HP left, replaced with status and time when dead/ghost or Offline) (right align)
1-2--3--4
Is there a way to show text as a single letter using lua? I basically want to show afk/dnd as a single letter, the duration doesn't matter to me that much.
Managed to create the following which shows me my name and afk/dnd but only the names of other people.
Yeah, you can set it to display pretty much anything, from icons to single letters, maybe just a * somewhere (i use that on my raidframes to denote a player thats not maxlvl)
To expand a bit on what Kerecha said, this doesn't do what you were expecting. "if max then" is equivalent to
Since max was always a "number", your conditional was always true. As a C++ programmer, I made that mistake a lot
In retrospect, what you've said is actually pretty obvious and it makes total sense, I can only say the reason why I tried values that I didn't even expect to work was down to not knowing how to check for something like maximum HP. Thank you for your explanation.
Anyone able to help with this?