Guest Ajuga

LuaTexts - The new DogTags

236 posts in this topic

and I get | Interfaceiconsicon_arcbrill:0

Also I'd for a Mage I only care if they have one of the 4 types of Intellect buffs, not if they don't have all 4.

You need |T to start the icon, followed by the path and then a : and then a number for the size and then |t to end it.

You can just use one variable. This is probably what you want:

local i = 1

local int = true

while true do

  local name = UnitAura(unit,i,"HELPFUL")

  if not name then

    break

  elseif name == "Arcane Intellect" then

    int = false

    break

  elseif name == "Arcane Brilliance" then

    int = false

    break

  elseif name == "Dalaran Brilliance" then

    int = false

    break

  end

  i = i + 1

end

if int then

  return "|T\\interface\\icons\\icon_int:0|t"

end

The breaks stop the loop as soon as it finds one of the buffs. Since you only care if any of them are there. Also note you need to use two \\ to mean one since \ is an escape character in Lua.

Share this post


Link to post
Share on other sites

I know im asking a lot, but since i can't seem to learn lua properly myself you guys are my only chance to get all of this working.

Huge thanks with optional hugs for whatever help you guys can give with this!

I'll try to get through these later. Some of those are gonna take me a bit to go through and "unparse". So I can write them as LuaTexts.

Share this post


Link to post
Share on other sites

A) Thanks for the continued work on pitbull

B) How much memory would I be looking at saving by switching to luatexts from dogtags, I have a MASSIVE amount of tags that I run at the moment and the idea of having to try and swap some of these over to LUA is incredibly daunting as some of them took me multiple hours just to figure out in dogtags (and I would go so far as to say I am very good at using dog tags) and I'm wondering just how memory saving will this be?

Share this post


Link to post
Share on other sites
A) Thanks for the continued work on pitbull

B) How much memory would I be looking at saving by switching to luatexts from dogtags, I have a MASSIVE amount of tags that I run at the moment and the idea of having to try and swap some of these over to LUA is incredibly daunting as some of them took me multiple hours just to figure out in dogtags (and I would go so far as to say I am very good at using dog tags) and I'm wondering just how memory saving will this be?

A) Sure thing.

B) Hmm I haven't paid that much attention to the memory savings lately but it's likely to be fairly significant if you actually top running LibDogTag-3.0 and LibDogTag-Unit-3.0 entirely. In my experience LuaTexts nominally increases PB4's memory usage and you eliminate all of those library usages. I'd figure on LuaTexts adding 200k or so to PB4. Might be more or less depending on your tags. Then just subtract out whatever those libraries are using.

If you're using DogTags in something else like CowTip then you won't be able to eliminate these libraries and you won't probably see any memory reduction since they'll still be running.

Share this post


Link to post
Share on other sites

from "Class: Standard"

local dr,dg,db = DifficultyColor(unit)

local form = DruidForm(unit)

if UnitIsPlayer(unit) or (not UnitIsFriend(unit,"player") and not IsPet(unit)) then

local cr,cg,cb = ClassColor(unit)

if form then

return "%s |cff%02x%02x%02x%s|r |cff%02x%02x%02x%s|r (%s) %s",Classification(unit) or '',dr,dg,db,Level(unit),cr,cg,cb,Class(unit),form,SmartRace(unit) or ''

else

return "%s |cff%02x%02x%02x%s|r |cff%02x%02x%02x%s|r %s",Classification(unit) or '',dr,dg,db,Level(unit),cr,cg,cb,Class(unit),SmartRace(unit) or ''

end

else

if form then

return "%s |cff%02x%02x%02x%s|r (%s) %s",Classification(unit) or '',dr,dg,db,Level(unit),form,SmartRace(unit) or ''

else

return "%s |cff%02x%02x%02x%s|r %s",Classification(unit) or '',dr,dg,db,Level(unit),SmartRace(unit) or ''

end

end

the Classification(unit) or '' sill leaves a space at the beginning of the string "%s |cff%..." i wonder how to get rid of that... Append(' ') somewhere?

thanks

Share this post


Link to post
Share on other sites

i got 2 lines of text on left side of frame name and class like so

Rakka

 80 Troll Warrior
that extra space comes from the space after the classification text for any unit that does not have a classification... could it be something like
Classification(unit)+' ' or ''

edit: i think this is not noticed because usually class right aligned?

Share this post


Link to post
Share on other sites

Allright I'll bight and ask for a conversion or 2 of the larger tags.

[(if IsMouseOver then

    HP:White

else

    (if ~IsMaxHP and InCombat then

        (if HP = 0 then

            Dead

        elseif HP > 999999 then

            (HP:Round(1) * (10 ^ -6)):Round(1)

        elseif HP > 999 then

            (HP:Round(-2) * (10 ^ -3))

        elseif HP > 0 then

            HP

        end):White

    end) (if ~IsMouseOver and ~IsMaxHP and InCombat then

        (if HP <= 999 then

            nil

        elseif HP > 999999 then

            "M":White

        elseif HP > 999 then

            "k":White

        end)

    end)

end)]

Share this post


Link to post
Share on other sites

local cur,max = HP(unit),MaxHP(unit)

if IsMouseOver() then

 return "%s",cur

 else

  if cur~=max and UnitAffectingCombat('player') then

   if cur==0 then

    return "Dead"

   elseif cur>999999 then

    return "%sM",floor(cur/1000000)

   elseif cur>999 then

    return "%sK",floor(cur/1000)

   else

    return "%s",cur

   end

  end

end

The only issue lies in there being no Event for IsMouseOver() or UnitAffectingCombat() in LuaText

ps: "Bight" != "Bite"

Share this post


Link to post
Share on other sites
The only issue lies in there being no Event for IsMouseOver() or UnitAffectingCombat() in LuaText

IsMouseOver() doesn't need an event. Using the function flags the text for update when the mouse enters or leave the frame the text is attached to.

PLAYER_REGEN_DISABLED and PLAYER_REGEN_ENABLED can be setup to work as an event for UnitAffectingCombat("player") (doesn't work for any other unit other than yourself, but then the code you were using was just for yourself anyway). Go to Modules, LuaTexts create new events with the names given above. Check the box for player and uncheck unit.

Share this post


Link to post
Share on other sites
i got 2 lines of text on left side of frame name and class like so

Rakka

 80 Troll Warrior
that extra space comes from the space after the classification text for any unit that does not have a classification... could it be something like
Classification(unit)+' ' or ''

edit: i think this is not noticed because usually class right aligned?

Yup it's a bug where I got lazy. I'll get it fixed.

Share this post


Link to post
Share on other sites

Work in progress to convert these...

Some are done... Will work more on this after raid.

The first bunch of codes are nestled with raidframe name and don't seem to work right for DC.

I cut out the relevant code for each part (hopefully i got all the little things cut properly).

With PB4's way of managing text positions i should be able to have them all as separate texts and let PB4 handle the spaces and such.

[(IsLeader ? "!":Color("00FF00")) (IsMasterLooter ? "!":Color("FFFF33")) Name:Truncate(9, nil):Prepend(" ") (~IsMaxLevel ? "*":Color("FFFFFF"):Prepend(" ")) ShortDruidForm:Angle:Color("FFAAAA"):Prepend(" ") "    " (~Status ? IsMana ? IsMaxMP ? MaxMP:Short ! PercentMP:Percent) (DeadType ? DeadType = "Ghost" ? "Run! " ! "Rip ") DeadDuration:FormatDuration:Paren (Offline ? "DC ") OfflineDuration:FormatDuration:Paren]
Power: Show mana only, show as X.xk when full and X.x% when not full. Also when AFK, Dead/Ghost or Offline replace mana display with AFK (AFK:Time), Dead (RIP:Time), Ghost (Run!:Time) and Offline (DC:Time).
(~Status ? IsMana ? IsMaxMP ? MaxMP:Short ! PercentMP:Percent) (DeadType ? DeadType = "Ghost" ? "Run! " ! "Rip ") DeadDuration:FormatDuration:Paren (Offline ? "DC ") OfflineDuration:FormatDuration:Paren]
ML/RL: Yellow ! for ML, Green ! for Leader
Finding out if someone is MasterLooter is kinda a pain might be nice to add a helper for that.
local is_leader = UnitIsPartyLeader(unit)

local is_ml

local name, server = UnitName(unit)

if server and server ~= "" then

  name = name .. "-" .. server

end

for i = 1, GetNumRaiderMembers() do

  local n, _, _, _, _, _, _, _, _, _, ml = GetRaidRosterInfo(i)

  if n == name then

    is_ml = ml

    break

  end

end

if is_leader and ml then

  return "|cff00ff00!|r|cffffff33!|r"

elseif is_leader then

  return "|cff00ff00!|r"

else

  return "|cffffff33!|r"

end

Level indicator: A white * if the person is not max level
White is the default anyway so pretty straightforward.
if Level(unit) ~= MAX_PLAYER_LEVEL then

  return "*"

end

Forms: 2 letters indicating druid form and 1 letter ( S ) indicating shadowform (current has druid form only)
Hmm apparently I never made a ShortDruidForm but this will work for now:
local form = DruidForm(unit)

if not form then

  return

elseif form == "Bear" then

  form = "Be"

elseif form == "Cat" then

  form = "Ca"

elseif form == "Moonkin" then

  form = "Mk"

elseif form == "Aquatic" then

  form = "Aq"

elseif form == "Flight" then

  form = "Fl"

elseif form == "Travel" then

  form = "Tv"

elseif form == "Tree" then

  form = "Tr"

end

return "|cffffaaaa<%s>|r",form
Name: Player name with 9 letters (this one probably isn't very hard thou, i just can't seem to think straight today)
return string.sub(Name(unit),1,9)
Next bunch is the target info tag (same as above about being nestled and wanting to make them separate texts)
[(~IsPlayerOrPet ? CreatureType:Hide("Unknown", "Not specified"):Append(" ")) (~IsPet ? Level:Hide("??"):DifficultyColor:Append(" ") ! Level) " " (~IsPlayerOrPet ? Classification:Contains("Rare") ? "R":Gray) (~IsPlayerOrPet ? Classification:Contains("Elite") ? "E":Yellow) (~IsPlayerOrPet ? Classification:Contains("Boss") ? "B":Red) Faction:IsIn("Alliance", "Horde"):Truncate(1, ellipses=false):Prepend([~IsFriend ? "player":PvP] ? [PvP ? Red ! Yellow] ! [PvP ? Green ! Blue]) " " (IsPet ? Guild) (IsPlayer ? Class:ClassColor:Prepend(" "))]
Creature type: basicly the beast/mechanical and so on and hiding unknown and not specified
Unknown was what DogTags used when UnitCreatureType returned nil so we don't have to actually look for it.
if not(UnitIsPlayer(unit) or UnitPlayerControlled(unit) or UnitPlayerOrPetInRaid(unit)) then

  local creature_type = UnitCreatureType(unit)

  if creature_type and creature_type ~= "Not specified" then

    return creature_type

  end

end

Level: Difficulty colored level (take out the Append(" ") since it won't be needed when each part is a separate text)
(~IsPet ? Level:Hide("??"):DifficultyColor:Append(" ") ! Level)
Rare, Elite, Boss indicator: Nothing special here.
(~IsPlayerOrPet ? Classification:Contains("Rare") ? "R":Gray) (~IsPlayerOrPet ? Classification:Contains("Elite") ? "E":Yellow) (~IsPlayerOrPet ? Classification:Contains("Boss") ? "B":Red)
Faction and PvP: A for alliance and H for horde, colored based on PvP flagg (about the same as the default names are colored). My faction green for pvp on, blue for pvp off. Opposite faction depends on my pvp state (yellow if im off and they are on, red if both are on and blue if both are off) Currently i only play alliance and tag might reflect that (i haven't made the tag myself so i don't really know)
Faction:IsIn("Alliance", "Horde"):Truncate(1, ellipses=false):Prepend([~IsFriend ? "player":PvP] ? [PvP ? Red ! Yellow] ! [PvP ? Green ! Blue]) " " (IsPet ? Guild) (IsPlayer ? Class:ClassColor:Prepend(" "))
And a few for target name tag aswell.
[Name:ClassColor " " (IsPlayer ? Guild:Truncate(34, nil):Bracket:Color("eeaaee")) " " (HasAura("Unstable Affliction") ? "UA":Color("Red"):Angle) (HasAura("Shadowform") ? "S":Color("dda0dd"):Angle) ShortDruidForm:Color("dda0dd"):Angle (PvP ? "!":Color("FF0000"):Prepend(" "))]
Guild: Basic guild name
(IsPlayer ? Guild:Truncate(34, nil):Bracket:Color("eeaaee"))
Extra PvP indicator: Red ! if pvp on and remove the Prepend(" ")
(PvP ? "!":Color("FF0000"):Prepend(" "))

Share this post


Link to post
Share on other sites

thanks shefki!

"Rare, Elite, Boss indicator: Nothing special here."

i guess u want text... but frame borders work well for this

Share this post


Link to post
Share on other sites
(~IsPlayerOrPet ? CreatureType:Hide("Unknown", "Not specified")
crefam = UnitCreatureFamily(unit)

if crefam=="Unkown" or crefam=="Not Specified" then

 return ""

else

 return "%s",crefam

end

Share this post


Link to post
Share on other sites
crefam = UnitCreatureFamily(unit)

if crefam=="Unkown" or crefam=="Not Specified" then

 return ""

else

 return "%s",crefam

end

See my tag above. WoW API never actually returns Unknown that's a DogTag thing. Don't bother to return "" LuaTexts already handles that for you. Makes the code cleaner to just return nothing.

Share this post


Link to post
Share on other sites
thanks shefki!

edit: can anyone tell me how to append a space to a %s value?

"Rare, Elite, Boss indicator: Nothing special here."

i guess u want text... but frame borders work well for this

Aye, want it as text since i use Roth border texture, and that won't take colors to well.

Shefki, huge thanks! I will test these out right away!

Did some digging and managed to get the class color in there, seems this old dog can actually learn some minor tricks still.

local r,g,b = ClassColor(unit)

return '|cff%02x%02x%02x%s|r ',r,g,b,string.sub(Name(unit),1,9)

One more, how would i do to make a missing HP text?

Raid health text showing X.xk when full, missing amount when not full, hidden when dead or offline.

Guessing i need some maths done with HP(unit) and MaxHP(unit).

Share this post


Link to post
Share on other sites
Well they're not all done yet. Still got some more stuuff to work on.

Has given me a more familiar base to start figuring out the code around. Its hard for me to try to figure it out from tags i don't use my self, but with familiar tags im starting to understand some of the basics.

Share this post


Link to post
Share on other sites
thanks Shefki,

Hex/base10 ARRRGHG. To be clear %02x means you are giving it numbers and 0xFF means you are giving it hex?? I'm not quite clear with how to input it as hex, although it isn't hard to input as base10.

I know I need two loops for HARMFUL and HELPFUL. There is only going to be one loop, HARMFUL in the final version. In the test form it just won't find some things it is looking for because they aren't relevant.

For people who are interested (prevent further questions) here is an image of the tag in action, and the code I am ending up using:

if not UnitIsFriend(unit,'player') then

local i = 1

local ttw,dam,hit,crit,wisdom= false,false,false,false,false

local tr,tg,tb = 255,00,00

local dr,dg,db = 255,00,00

local hr,hg,hb = 255,00,00

local cr,cg,cb = 255,00,00

local wr,wg,wb = 255,00,00

while true do

 local name,_,icon = UnitAura(unit,i,"HARMFUL")

 if not name then

   break

 elseif name == "Thunder Clap" then

   ttw = true

 elseif name == "Infected Wounds" then

   ttw = true

 elseif name == "Icy Touch" then

   ttw = true

 elseif name == "Earth and Moon" then

   dam = true

 elseif name == "Ebon Plague" then

   dam = true

 elseif name == "Curse of Elements" then

   dam = true

 elseif name == "Misery" then

   hit = true

 elseif name == "Faerie Fire" then

   hit = true

 elseif name == "Totem of Wrath" then

   crit = true

 elseif name == "Master Poisoner" then

   crit = true

 elseif name == "Heart of the Crusader" then

   crit = true

 elseif name == "Judgment of Wisdom" then

   wisdom = true

 end

 i = i + 1

end

if ttw then

 tr,tg,tb = 00,255,00

end

if dam then

 dr,dg,db = 00,255,00

end

if hit then

 hr,hg,hb = 00,255,00

end

if crit then

 cr,cg,cb = 00,255,00

end

if wisdom then

 wr,wg,wb = 00,255,00

end

return "|cff%02x%02x%02xT|r   |n|cff%02x%02x%02xD|r   |n|cff%02x%02x%02xH|r   |n|cff%02x%02x%02xC|r   |n|cff%02x%02x%02xW|r   " 


,tr,tg,tb,dr,dg,db,hr,hg,hb,cr,cg,cb,wr,wg,wb

end

PS: Hidden debuffs are evil (ie Judgment of the Just)

What would be the trick to make this horizontal instead of vertical?

And some of the Text is wrong is should be Improved Faerie Fire instead of Faerie Fire and Curse of the Elements not Curse of Elements.

Share this post


Link to post
Share on other sites
What would be the trick to make this horizontal instead of vertical?

Remove the '|n's from the return string so that it looks like:


return "|cff%02x%02x%02xT|r|cff%02x%02x%02xD|r|cff%02x%02x%02xH|r|cff%02x%02x%02xC|r|cff%02x%02x%02xW|r" ,tr,tg,tb,dr,dg,db,hr,hg,hb,cr,cg,cb,wr,wg,wb

More useful information about escape codes can be found at the wowwiki page.

Edit: Chances are you can remove all but the last |r as well, no point in resetting the colour if you're just going to change it again.

Share this post


Link to post
Share on other sites

Two simple questions:

How do you get power color? PowerColor(unit) doesn't seem to work.

How do you format numbers to be separated by commas? E.g. 2000000 -> 2,000,000.

Share this post


Link to post
Share on other sites
Classification(unit)+' ' or ''

does not work...

Classification(unit) and ' ' or ''

seems to work but not if i reverse it?

' ' and Classification(unit) or ''

ya idk what i am doing... i guess the [or ''] is for error handling not formatting?

is there some kinda append or prepend or trim methods i can use

thanks

Share this post


Link to post
Share on other sites

Ok I am a beginner and I want to learn how to do this....my question is I enabled the LuaText module but where do I actually put in the code, in the interface or in the LUA files outside the game?

Nevermind I figured it out.

Share this post


Link to post
Share on other sites
does not work...

seems to work but not if i reverse it?

ya idk what i am doing... i guess the [or ''] is for error handling not formatting?

is there some kinda append or prepend or trim methods i can use

thanks

+ is an mathematical operator, it's not useful on strings in Lua.

Lua doesn't have a proper ternary operator. You can get away with:

something and value_for_true or value_for_false

But if value_for_true actually evaluates to false then that won't work either. e.g.

something and false or true

Has to be written:

not something and true or false

You can do concatenation with .. e.g.

x = ' '..' '

Would set x to two spaces.

However, I'd suggestion that you avoid doing this. Consider the following expression:

a = a .. b

This is adding the string b onto the end of the a string. Lua doesn't just expand the a string and add the contents of b. Rather it makes new string consisting of a followed by b and replaces the old a. This means the old a has to be garbage collected and causes memory churn.

Now I'm not suggesting that you never ever do something like this. Sometimes there's just no good way to achieve what you want without doint a concatenation. For the purposes of formatting I'd suggest you put your spaces in format strings.


local classification = Classification(unit)

if classification then

  return "%s %s",foo(unit),classification

else

  return "%s",classification

end

Alternatively you can do something like this:

local classification = Classification(unit)

return "%s%s%s",foo(unit),classification and ' ' or '',classification

By returning the strings separated out like this and letting the Blizzard code put them together you actually save a lot of memory churn. This is why LuaTexts doesn't just expect you to provide a single completed string but rather the format string and arguments to pass through to SetFormattedText().

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.