Jump to content


LuaTexts - The new DogTags


  • Please log in to reply
235 replies to this topic

#1 Guest_Ajuga_*

Guest_Ajuga_*
  • Guests

Posted 14 June 2009 - 10:18 PM

"LuaTexts is a text provider module for PitBull4. It's a more efficient alternative to DogTagTexts. Texts are entered using Lua rather that DogTags. Custom texts are harder to write than DogTags as it requires some knowledge of Lua."

Shefki (co-author of PitBull4) writes:

State of PB4:

As of the push tonight I believe the major performance issues are taken care of and generally serious bugs are fixed. There are of course a few here and there and some feature enhancements I'd really like to do. But the point here is that I consider us pretty much to be pretty much to a beta state.

While I consider us to be at that point I won't be immediately tagging the project as a beta. I'm gonna let PB4 simmer for a little bit to see if some things come up. I figure it'll get tagged probably sometime this weekend.

All that being said I wanted to talk about performance. Particularly as to how it is going to impact this timeline. I'm very interested in performance problems. PitBull in the past has had adequate performance, but it still has been somewhat lacking. I think we can provide the configuration options that our picky users want while still maintaining top notch performance.

As of the changes tonight during a typical AV run PB3+DogTags will use about 3.6 seconds of CPU time per minute of battleground time. PB4 using LuaTexts is using about 2.5 seconds of CPU time per minute of battleground time. PB4+DogTags is using about 6.4 seconds of CPU time per minute of battleground time.


The above is with roughly identical configurations between the 3 different setups. The DogTag performance numbers is including the time the LibDogTags-3.0 and LibDogTags-Unit-3.0 libraries took (PitBull was the only addon using them).

I strongly recommend that people still using DogTags and having performance problems migrate to LuaTexts. When reporting performance problems please do say if you're using DogTagTexts or LuaTexts, as you can see there is a drastic performance difference.

I have a pretty good idea as to what is causing the performance problems with DogTagTexts. Unfortunately, I don't have a very good solution for the problem. DogTags was largely written with PitBull3 and CowTip in mind. PitBull3 puts a lot of work on the individual modules to know when to update frames, particularly frames that we do not receive events for. PB4 includes this work in the core. Unfortunately, DogTags takes on this work and it gets doubled up. This explains the performance numbers seen above as the PB4 number is slightly less than double the PB3 DogTag number.

As a result of this it's almost guaranteed that I'll be switching the default text provider to LuaTexts.

I want to be clear that I'm not giving up on fixing DogTagsTexts. However, it was always the intention of making a lighter weight text provider be the default. I'm going to encourage people to shift to LuaTexts pretty strongly. I hope this post helps people make the decision to switch.

I also hope it demonstrates that PB4 is at this point outperforming PB3 with the exception of DogTags. I look forward to your feedback.



This thread is intended to work as http://elitistjerks....ags_3_0_thread/, but obviously for LuaTexts instead. Unsure how to get started? Check this out.

#2 Shefki

Shefki

    Von Kaiser

  • Members
  • 38 posts

Posted 15 June 2009 - 02:05 AM

I'll try to keep an eye on this thread and answer questions if need be. I'm really hoping that a community will spring up around LuaTexts to help people out with them. However, LuaTexts is PB4 centric. So there probably won't be as there was with people using DogTags with Cowtip, PB3 and others.

While I'll reply I'm not gonna generally get in the mode of converting every DogTag someone happens to post here. If the tag you want converted is instructive to the community then it will probably get converted. So don't feel slighted if I don't specifically respond to your post.

#3 Dankz

Dankz

    Von Kaiser

  • Members
  • 58 posts

Posted 15 June 2009 - 07:19 AM

I'll bite first. I'd like to get rid of Grid and only use PB4. I tried I but failed to write a "Missing Buff" Dogtag, and had to settle for a "Has Buff" tag. Something like
[if hasaura ("arcane briallance") "."]


I'd like to make a Lua Script to do something like
[if hasuara ("Aracne Briallance")nil, else "."]

Can anyone point me in the right direction?

#4 Led ++

Led ++

    Piston Honda

  • Members
  • 219 posts

Posted 15 June 2009 - 08:36 AM

Little question:

the UF addon Stuf also has a .lua method for inputting your values for HP and such. Do you reckon this will work the same? Or will it work totally different?
http://thepiratebootybay.com/ THE best Addon site out there!

#5 Shefki

Shefki

    Von Kaiser

  • Members
  • 38 posts

Posted 15 June 2009 - 06:04 PM

I'll bite first. I'd like to get rid of Grid and only use PB4. I tried I but failed to write a "Missing Buff" Dogtag, and had to settle for a "Has Buff" tag. Something like

[if hasaura ("arcane briallance") "."]


I'd like to make a Lua Script to do something like
[if hasuara ("Aracne Briallance")nil, else "."]

Can anyone point me in the right direction?


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.

#6 Shefki

Shefki

    Von Kaiser

  • Members
  • 38 posts

Posted 15 June 2009 - 06:05 PM

Little question:

the UF addon Stuf also has a .lua method for inputting your values for HP and such. Do you reckon this will work the same? Or will it work totally different?


Honestly, I haven't looked at the implementation in Stuf. So I really can't say. Lua itself of course will be the same, but I provide helper functions with are going to be different and I'm not sure if Stuf expects you to return a single string or the arguments to SetFormattedText like LuaTexts does.

#7 Katae

Katae

    Glass Joe

  • Members
  • 1 posts

Posted 15 June 2009 - 07:25 PM

I can't seem to concat with '..' in the texts code, I just get an error. Is there another way to write this?
if MaxPower(unit) > 0 then
  return "|cff3da5ee"..Short(Power(unit))
end
edit: figured it out, had to add format boolean to Short()

#8 Hotan

Hotan

    Piston Honda

  • Members
  • 135 posts

Posted 15 June 2009 - 07:34 PM

Edit; He fixed it himeslf

#9 Shefki

Shefki

    Von Kaiser

  • Members
  • 38 posts

Posted 15 June 2009 - 07:50 PM

I can't seem to concat with '..' in the texts code, I just get an error. Is there another way to write this?

if MaxPower(unit) > 0 then
  return "|cff3da5ee"..Short(Power(unit))
end
edit: figured it out, had to add format boolean to Short()


Don't do concat like that. Do this:
If MaxPower(unit) > 0 then
  return |cff3da5ee%s|r",Short(Power(unit),true)
end

Doing that avoids producing a lot of unnecessary garbage.

#10 Wodahs

Wodahs

    Don Flamenco

  • Members
  • 431 posts

Posted 15 June 2009 - 09:18 PM

[HP:Short "/" MaxHP:Short " " (if PercentHP > 70 then
    PercentHP:VeryShort:Percent:Green
elseif PercentHP > 35 then
    PercentHP:VeryShort:Percent:Yellow
elseif PercentHP < 35 then
    PercentHP:VeryShort:Percent:Red
end)]

This is what Ive been using to show currhp/maxhp and a color coded percentage. Is there any way to do a more graduated coloring in lua text?

#11 Shefki

Shefki

    Von Kaiser

  • Members
  • 38 posts

Posted 15 June 2009 - 10:16 PM

[HP:Short "/" MaxHP:Short " " (if PercentHP > 70 then
    PercentHP:VeryShort:Percent:Green
elseif PercentHP > 35 then
    PercentHP:VeryShort:Percent:Yellow
elseif PercentHP < 35 then
    PercentHP:VeryShort:Percent:Red
end)]

This is what Ive been using to show currhp/maxhp and a color coded percentage. Is there any way to do a more graduated coloring in lua text?


HPColor(cur,max) though I really don't understand why you didn't just use HPColor in DogTags like so:
[HP:Short "/" MaxHP:Short " " PercentHP:VeryShort:Percent:HPColor]

which would be like so in LuaTexts:
local cur,max = HP(unit),MaxHP(unit)
local r,g,b = HPColor(cur,max)
return "%s/%s |cff%02x%02x%02x%s%%|r",cur,max,r,g,b,VeryShort(Percent(cur,max),true)


#12 Hotan

Hotan

    Piston Honda

  • Members
  • 135 posts

Posted 15 June 2009 - 11:10 PM

So I have spent a few hours on this and am throwing my hands in the air. I feel like I am so close to having it working (probably not optimal, but working). My bugsack is showing everything fine until the return line

Dogtag version:
[if IsEnemy and ~IsPet then
    (if HasAura("Thunder Clap") or HasAura("Frost Fever") or HasAura("Infected Wounds") then
        "T   ":Green
    else
        "T   ":Red
    end)
end]
[if IsEnemy and ~IsPet then
    (if HasAura("Curse of the Elements") or HasAura("Earth and Moon") or HasAura("Ebon Plague") then
        "D   ":Green
    else
        "D   ":Red
    end)
end]
[if IsEnemy and ~IsPet then
    (if HasAura("Faerie Fire") or HasAura("Misery") then
        "H   ":Green
    else
        "H   ":Red
    end)
end]
[if IsEnemy and ~IsPet then
    (if HasAura("Master Poisoner") or HasAura("Heart of the Crusader") or HasAura("Totem of Wrath") then
        "C   ":Green
    else
        "C   ":Red
    end)
end]
[if IsEnemy and ~IsPet then
    "" (if HasAura("Judgement of Wisdom") then
        "W   ":Green
    else
        "W   ":Red
    end)
end]

My attempt at LuaText version:
local i = 1
local ttw,dam,hit,crit,wisdom= false,false,false,false,false
local tr,tg,tb = FF,00,00
local dr,dg,db = FF,00,00
local hr,hg,hb = FF,00,00
local cr,cg,cb = FF,00,00
local wr,wg,wb = FF,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 == "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,FF,00
elseif dam then
 dr,dg,db = 00,FF,00
elseif hit then
 hr,hg,hb = 00,FF,00
elseif crit then
 cr,cg,cb = 00,FF,00
elseif wisdom then
 wr,wg,wb = 00,FF,00
end
return “|cff%02x%02x%02x%s|r |cff%02x%02x%02x%s|r  |cff%02x%02x%02x%s|r  |cff%02x%02x%02x%s|r  |cff%02x%02x%02x%s|r" ,tr,tg,tb,"T   |n",dr,dg,db,"D   |n",hr,hg,hb,"H   |n",cr,cg,cb,"C   |n",wr,wg,wb,"W   |n" or ‘’
edit: I haven't even bothered to add the "IfEnemy" portion

#13 Kalroth

Kalroth

    Great Tiger

  • Members
  • 835 posts

Posted 16 June 2009 - 09:55 AM

So I have spent a few hours on this and am throwing my hands in the air. I feel like I am so close to having it working (probably not optimal, but working). My bugsack is showing everything fine until the return line

return “|cff%02x%02x%02x%s|r |cff%02x%02x%02x%s|r  |cff%02x%02x%02x%s|r  |cff%02x%02x%02x%s|r  |cff%02x%02x%02x%s|r" ,tr,tg,tb,"T   |n",dr,dg,db,"D   |n",hr,hg,hb,"H   |n",cr,cg,cb,"C   |n",wr,wg,wb,"W   |n" or ‘’

If this is a direct paste from your Lua code, then the first quote character is incorrect.
You're using “ when you should be using ". Also I believe that the or ‘’ part should be or "".

#14 Garaddon

Garaddon

    Glass Joe

  • Members
  • 13 posts

Posted 16 June 2009 - 11:07 AM

Your text formatting looks kinda weird.
I wonder why are you using something like
"|cff%02x%02x%02x%s|r", tr,tg,tb,"T   |n"
when it can be like
"|cff%02x%02x%02xT|r|n", tr,tg,tb
Notice where 'T' went. This way it's more uniform.
And of course take into account what Kalroth said about quotation marks.
BTW if it doesn't help, could you paste what bugsack said about that return line?

edit: forgot |n

#15 Hotan

Hotan

    Piston Honda

  • Members
  • 135 posts

Posted 16 June 2009 - 04:22 PM

Sweet, thanks for the feedback. All my lua knowledge is coding by mimicing, so...yeah.

Once maintenance is over I'll do this stuff. The spaces are there for a reason, I have the text vertically on the left edge, but I don't want it on the edge of the frame, but rather right next to it.

btw: what exactly does |r mean?
correlation =/= causation

#16 Shefki

Shefki

    Von Kaiser

  • Members
  • 38 posts

Posted 16 June 2009 - 04:46 PM

btw: what exactly does |r mean?


Stops the custom color that was started by a previous |cff escape code.

#17 Hotan

Hotan

    Piston Honda

  • Members
  • 135 posts

Posted 16 June 2009 - 06:03 PM

So my code is still not working :/

local i = 1
local ttw,dam,hit,crit,wisdom= false,false,false,false,false
local tr,tg,tb = FF,00,00
local dr,dg,db = FF,00,00
local hr,hg,hb = FF,00,00
local cr,cg,cb = FF,00,00
local wr,wg,wb = FF,00,00
while true do
 local name,_,icon = UnitAura(unit,i,"HELPFUL")
 if not name then
   break
 elseif name == "Molten Armor" then
   ttw = true
 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,FF,00
end
if dam then
 dr,dg,db = 00,FF,00
end
if hit then
 hr,hg,hb = 00,FF,00
end
if crit then
 cr,cg,cb = 00,FF,00
end
if wisdom then
 wr,wg,wb = 00,FF,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|n" ,tr,tg,tb,dr,dg,db,hr,hg,hb,cr,cg,cb,wr,wg,wb

I changed UnitAura(unit,i,"HARMFUL") to UnitAura(unit,i,"HELPFUL") and added elseif name == "Molten Armor" to aide testing, but I don't see how they could have caused any issues.

This is my bugsack report:
[2009/06/16 11:02:05-572-x1]: PitBull4_LuaTexts:Target - L:Lua:Debuff Check caused the following error::
bad argument #4 to 'SetFormattedText' (number expected, got nil):
PitBull4-r20090616012413\Modules\LuaTexts\LuaTexts.lua:639: in function <...erface\AddOns\PitBull4\Modules\LuaTexts\LuaTexts.lua:595>
PitBull4-r20090616012413\Modules\LuaTexts\LuaTexts.lua:1135: in function `AddFontString'
PitBull4-r20090616012413\ModuleHandling\TextProviderModule.lua:116: in function `UpdateFrame'
PitBull4-r20090616012413\ModuleHandling\Module.lua:271: in function `Update'
PitBull4-r20090616012413\UnitFrame.lua:527: in function `Update'
PitBull4-r20090616012413\UnitFrame.lua:553: in function `UpdateGUID'
PitBull4-r20090616012413\Main.lua:1136: in function `CheckGUIDForUnitID'
PitBull4-r20090616012413\Main.lua:1141: in function `?'
CallbackHandler-1.0-3:146: in function <...omp\libs\CallbackHandler-1.0\CallbackHandler-1.0.lua:146>
<string>:"safecall Dispatcher[1]":4: in function <[string "safecall Dispatcher[1]"]:4>
<in C code>: ?
<string>:"safecall Dispatcher[1]":13: in function `?'
CallbackHandler-1.0-3:91: in function `Fire'
AceEvent-3.0-3:119: in function <...s\ArthicsRaidComp\libs\AceEvent-3.0\AceEvent-3.0.lua:118>
<in C code>: in function `TargetUnit'
Interface\FrameXML\SecureTemplates.lua:348: in function `handler':
Interface\FrameXML\SecureTemplates.lua:460: in function `SecureActionButton_OnClick':
Interface\FrameXML\SecureTemplates.lua:501: in function <Interface\FrameXML\SecureTemplates.lua:493>:

  ---

edit: "Lua:Debuff Check" is the name of the Text
correlation =/= causation

#18 Shefki

Shefki

    Von Kaiser

  • Members
  • 38 posts

Posted 16 June 2009 - 09:45 PM

Your problem is the FF. That either needs to be 0xFF to say you're giving it a number in hex or it needs to be a decimal number 255.
Fix that and it should work.

Also you need two loops one for "HARMFUL" and one for "HELPFUL" roughly:

while true do
  local name = UnitAura(unit,i,"HELPFUL")
  if not name then
    break
  elseif name == "Buff1" then
    -- something
  elseif name == "Butff2" then
    -- somethingelse
  end
  i = i + 1
end
i = 1
while true do
  local name = UnitAura(unit,i,"HARMFUL")
  if not name then
    break
  elseif name == "Debuff1" then
    -- something
  elseif name == "Debuff2" then
    --something else
  end
  i = i + 1
end


#19 Hotan

Hotan

    Piston Honda

  • Members
  • 135 posts

Posted 16 June 2009 - 10:36 PM

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

#20 Shefki

Shefki

    Von Kaiser

  • Members
  • 38 posts

Posted 16 June 2009 - 10:55 PM

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.


The %02x is the format code for the format. It says the variable in that place will be an integer... 0 means you want it zero padded, i.e. "1" would be "01", 2 means you want two places digits and the x means you want the output to be in hexadecimal with lowercase letters (a,b,c,d,e,f). This is entirely separate from inputting numbers in Lua.

The format the numbers are actually stored in Lua is irrevelent. Pretty much all languages assume you're entering numbers in base 10. If you want to enter the numbers in hexadecimal you'd do 0xFF. So your line:
local tr,tg,tb = 255,00,00
would be:
local tr,tg,tb = 0xFF,0,0

The double zeros are redundent. Again Lua abstracts how it's storing the number from you. When you input numbers you have to say what you're using (or use the assumed default) and you have to tell it what you want when you output them, thus the %02x.

Alternatively you could use %s as your format string and use:
local tr,tg,tb = 'FF','00','00'

There's a dozen different ways to do this.




1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users