Jump to content


LuaTexts - The new DogTags


  • Please log in to reply
235 replies to this topic

#21 rakkarage

rakkarage

    Glass Joe

  • Members
  • 6 posts

Posted 17 June 2009 - 12:56 AM

return '%s %s%s%s',Name(unit),Angle(AFK(unit) or DND(unit))

so that is the default name text...

what are the two extra %s for?

#22 ctrlfrk

ctrlfrk

    Glass Joe

  • Members
  • 8 posts

Posted 17 June 2009 - 01:05 AM

The Angle() function returns 3 strings, so you need three %s.
From the project page:

Angle(value)
Returns three values '<',value,'>' if value is not nil or ''. If value is '' or nil then it returns three empty strings.


It's really just a shorthand to hide the angle brackets if there is no value to display.

#23 Shefki

Shefki

    Von Kaiser

  • Members
  • 38 posts

Posted 17 June 2009 - 08:15 AM

And be warned, using Angle() in the middle of params won't work right unless it's the last one. In retrospect I kinda wish I hadn't added them at all. But it sure made the default tags a little cleaner looking.

The reason you can only use it at the end is because Lua doesn't really have a list context.

function foo()
  return 'a','b','c'
end

function bar()
  return 1,2,foo(),3,4
end

print(bar())

Will print:
1 2 a 3 4

Changing bar to:
function bar()
  return 1,2,3,4,foo()
end

will print:
1 2 3 4 a b c

So be warned that Angle() and Paren() will very likely fail you in some places.

#24 Dankz

Dankz

    Von Kaiser

  • Members
  • 58 posts

Posted 17 June 2009 - 09:30 AM

local i = 1
local fort,spirit,shadow_prot = true,true,true
while true do
  local name,_,icon = UnitAura(unit,i,"HELPFUL")
  if not name then
    break
  elseif name == "Power Word: Fortitude" then
    fort = false
  elseif name == "Divine Spirit" then
    spirit = false
  elseif name == "Shadow Protection" then
    shadow_prot = false
  end
  i = i + 1
end
return "%s%s%s",fort and "|TPATH_TO_FORT_ICON:0|t" or '',spirit and "|TPATH_TO_SPIRIT_ICON:0|t" or '',shadow_prot and "|TPATH_TO_SHADOW_PROT_ICON:0|t" or ''

The above is the code I worked up to demonstrate to someone how to do it with icons. Should be pretty simple to modify that to do what you wanted.



Ok I had a crack at it and did't work. This is what I'm using
local i = 1
local int,arc_brill,dala_brill = true,true,true
while true do
  local name,_,icon = UnitAura(unit,i,"HELPFUL")
  if not name then
    break
  elseif name == "Arcane Intellect" then
    int = false
  elseif name == "Arcane Brilliance" then
    arc_brill = false
  elseif name == "Dalaran Brilliance" then
    dala_brill = false
  end
  i = i + 1
end
return "%s%s%s",int and "|\interface\icons\icon_int:0|t" or '', arc_brill and "|\interface\icons\icon_arcbrill:0|t" or '',dala_brill and "|\interface\icons\icon_dalabrill:0|t" or  ''

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.

#25 Zeelian

Zeelian

    Glass Joe

  • Members
  • 14 posts

Posted 17 June 2009 - 02:43 PM

Okay, here goes. (Warning Huge post)

Im giving lua texts a go in hope to improve performance on my PB4, but many of my current dogtags are way beyond my level of complexity to even create the DogTag versions myself, much less the lua text ones. So im hoping that someone can help me by looking at my tags (and a small description of how i want them working) and translate them into lua texts. Unfortunately im just to bad at lua to even begin to do it myself, i have tried learning lua, but beyond some very basic editing of existing mods i haven't been able to grasp it on my own.


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.

Original tag:
[(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).

Current
(~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

Current
(IsLeader ? "!":Color("00FF00")) (IsMasterLooter ? "!":Color("FFFF33"))


Level indicator: A white * if the person is not max level

Current
(~IsMaxLevel ? "*":Color("FFFFFF"))

Forms: 2 letters indicating druid form and 1 letter ( S ) indicating shadowform (current has druid form only)

Current
ShortDruidForm:Angle:Color("FFAAAA")

Name: Player name with 9 letters (this one probably isn't very hard thou, i just can't seem to think straight today)

Current
Name:Truncate(9, nil)


Next bunch is the target info tag (same as above about being nestled and wanting to make them separate texts)

Orignal tag:
[(~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

Current
(~IsPlayerOrPet ? CreatureType:Hide("Unknown", "Not specified")


Level: Difficulty colored level (take out the Append(" ") since it won't be needed when each part is a separate text)

Current
(~IsPet ? Level:Hide("??"):DifficultyColor:Append(" ") ! Level)


Rare, Elite, Boss indicator: Nothing special here.

Current
(~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)

Current
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.


Current
[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

Current
(IsPlayer ? Guild:Truncate(34, nil):Bracket:Color("eeaaee"))

Extra PvP indicator: Red ! if pvp on and remove the Prepend(" ")

Current
(PvP ? "!":Color("FF0000"):Prepend(" "))




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!

#26 Shefki

Shefki

    Von Kaiser

  • Members
  • 38 posts

Posted 17 June 2009 - 09:04 PM

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.

#27 Shefki

Shefki

    Von Kaiser

  • Members
  • 38 posts

Posted 17 June 2009 - 09:07 PM

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.

#28 supplicium

supplicium

    Don Flamenco

  • Members
  • 294 posts

Posted 18 June 2009 - 04:54 AM

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?

The character linked in your profile appears to be below level 10. This may account for your poor Patchwerk DPS.


#29 Shefki

Shefki

    Von Kaiser

  • Members
  • 38 posts

Posted 18 June 2009 - 05:54 AM

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.

#30 rakkarage

rakkarage

    Glass Joe

  • Members
  • 6 posts

Posted 18 June 2009 - 01:48 PM

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

#31 Hotan

Hotan

    Piston Honda

  • Members
  • 135 posts

Posted 18 June 2009 - 05:31 PM

Rakkaragee: I'm now sure what exactly you mean. Care to give us an example?
correlation =/= causation

#32 rakkarage

rakkarage

    Glass Joe

  • Members
  • 6 posts

Posted 18 June 2009 - 05:39 PM

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?

#33 supplicium

supplicium

    Don Flamenco

  • Members
  • 294 posts

Posted 18 June 2009 - 08:51 PM

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)]

The character linked in your profile appears to be below level 10. This may account for your poor Patchwerk DPS.


#34 Hotan

Hotan

    Piston Honda

  • Members
  • 135 posts

Posted 18 June 2009 - 09:15 PM

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"
correlation =/= causation

#35 Shefki

Shefki

    Von Kaiser

  • Members
  • 38 posts

Posted 18 June 2009 - 09:33 PM

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.

#36 Shefki

Shefki

    Von Kaiser

  • Members
  • 38 posts

Posted 18 June 2009 - 09:37 PM

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.

#37 Hotan

Hotan

    Piston Honda

  • Members
  • 135 posts

Posted 18 June 2009 - 09:41 PM

deleted
correlation =/= causation

#38 Shefki

Shefki

    Von Kaiser

  • Members
  • 38 posts

Posted 18 June 2009 - 10:45 PM

Work in progress to convert these...
Some are done... Will work more on this after raid.

[quote name='Zeelian']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.

[/quote]
[(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]

[quote]
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).
[/quote]

(~Status ? IsMana ? IsMaxMP ? MaxMP:Short ! PercentMP:Percent) (DeadType ? DeadType = "Ghost" ? "Run! " ! "Rip ") DeadDuration:FormatDuration:Paren (Offline ? "DC ") OfflineDuration:FormatDuration:Paren]

[quote]
ML/RL: Yellow ! for ML, Green ! for Leader
[/quote]

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

[quote]
Level indicator: A white * if the person is not max level
[/quote]

White is the default anyway so pretty straightforward.

if Level(unit) ~= MAX_PLAYER_LEVEL then
  return "*"
end

[quote]
Forms: 2 letters indicating druid form and 1 letter ( S ) indicating shadowform (current has druid form only)
[/quote]

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

[quote]
Name: Player name with 9 letters (this one probably isn't very hard thou, i just can't seem to think straight today)
[/quote]

return string.sub(Name(unit),1,9)

[quote]
Next bunch is the target info tag (same as above about being nestled and wanting to make them separate texts)
[/quote]

[(~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(" "))]

[quote]
Creature type: basicly the beast/mechanical and so on and hiding unknown and not specified
[/quote]

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

[quote]
Level: Difficulty colored level (take out the Append(" ") since it won't be needed when each part is a separate text)
[/quote]

(~IsPet ? Level:Hide("??"):DifficultyColor:Append(" ") ! Level)

[quote]
Rare, Elite, Boss indicator: Nothing special here.
[/quote]

(~IsPlayerOrPet ? Classification:Contains("Rare") ? "R":Gray) (~IsPlayerOrPet ? Classification:Contains("Elite") ? "E":Yellow) (~IsPlayerOrPet ? Classification:Contains("Boss") ? "B":Red)

[quote]
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)
[/quote]

Faction:IsIn("Alliance", "Horde"):Truncate(1, ellipses=false):Prepend([~IsFriend ? "player":PvP] ? [PvP ? Red ! Yellow] ! [PvP ? Green ! Blue]) " " (IsPet ? Guild) (IsPlayer ? Class:ClassColor:Prepend(" "))

[quote]
And a few for target name tag aswell.
[/quote]

[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(" "))]

[quote]
Guild: Basic guild name
[/quote]

(IsPlayer ? Guild:Truncate(34, nil):Bracket:Color("eeaaee"))

[quote]
Extra PvP indicator: Red ! if pvp on and remove the Prepend(" ")
[/quote]

(PvP ? "!":Color("FF0000"):Prepend(" "))


#39 rakkarage

rakkarage

    Glass Joe

  • Members
  • 6 posts

Posted 18 June 2009 - 10:58 PM

thanks shefki!


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

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

#40 Hotan

Hotan

    Piston Honda

  • Members
  • 135 posts

Posted 18 June 2009 - 10:58 PM

(~IsPlayerOrPet ? CreatureType:Hide("Unknown", "Not specified")

crefam = UnitCreatureFamily(unit)
if crefam
"Unkown" or crefam
"Not Specified" then return "" else return "%s",crefam end

correlation =/= causation




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users