• 0

    posted a message on LuaTexts Official Thread
    I wrote a tag with GetPetTimeRemaining() and it works fantastically (although my formatting method is probably not optimal:
    ptime = GetPetTimeRemaining()
    if ptime then
     return '%s',floor(ptime/100+.5)/10
    end
    However, I can't figure out which event to use (I know I will have to add it). I looked through the WoWWiki pet events, and nothing seemed logical. Any ideas?
    Posted in: Unit Frames
  • 0

    posted a message on LuaTexts Official Thread
    The string Classification() output for rare-elites is "Rare-Elite". so it wouldn't get caught up in the mix; in the case code you wrote a rare-elite would return nothing.
    Posted in: Unit Frames
  • 0

    posted a message on LuaTexts Official Thread
    In an earlier post I said that I would show you the tag I set up for displaying levels:
    For players: Displays level, if not 80
    For NPCs: If boss, displays "Boss";
    if elite (includes Rare, Rare-Elite), displays '"%s+",lvl';
    if non-special classification displays '"%s",lvl',
    else displays '"%s%s",lvl,clas"
    local dr,dg,db = DifficultyColor(unit)
    local lvl = Level(unit)
    clas = Classification(unit)  
    if UnitIsPlayer(unit) then
     if lvl~=MAX_PLAYER_LEVEL then
      return "|cff%02x%02x%02x%s|r",dr,dg,db,lvl
      end
     else  
      if clas=='Boss' then
      return "|cff%02x%02x%02x%s|r",dr,dg,db,'Boss'
      elseif clas=='Elite' then
      return "|cff%02x%02x%02x%s+|r",dr,dg,db,lvl
      else
      return "|cff%02x%02x%02x%s|r |cff%02x%02x%02x%s|r",dr,dg,db,lvl,dr,dg,db,clas or ''
     end
    end


    Also, Kerecha, you should locally define Classifcation(unit). This will prevent potential multiple calls, the only reason I didn't do it earlier was because Classification(unit) was only called once.
    Posted in: Unit Frames
  • 0

    posted a message on LuaTexts Official Thread
    Quote from Kerecha
    How would i go about making

    return Level(unit)

    Not return ?? on bosses ?

    if Classification(unit) ~= "Boss" then
     return "%s",Level(unit)
    end
    I have a much fancier level code, I'll post that when I get home later.
    Posted in: Unit Frames
  • 0

    posted a message on LuaTexts Official Thread
    Yeah, it looks like Theondry caught my mistakes. Apparently I don't code as well at work, go figure.

    Also, based on the line number in your error, it appears that you used a version of the code that I edited away. I got rid of the r,g,b assignments, combined with %20x$20x%20x, and just put the color assignment directly in. I am not sure if this helps performance an appreciable amount, I doubt it does, but it does make the code cleaner.
    Posted in: Unit Frames
  • 0

    posted a message on LuaTexts Official Thread
    Quote from Kerecha
    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)

    I wrote up some code for your purpose. I don't know how well it works because I am at work and can't test it (don't tell my boss). Also, I added a tag for you being PvP flagged, but the unit not being flagged, I assumed Red. This could be made to automatically detect your faction, but that seems like a waste of resources, to adjust Alliance to Horde, just swap Alliance and Horde, and swap H and A
    local fact = UnitFactionGroup(unit)
    if fact=="Alliance" then
     if UnitIsPVP("player") then
      return "|cff00FF00A|r"
     else
      return "|cff0000FFA|r"
     end
    elseif fact=="Horde" then
     if not UnitIsPVP("player") and UnitIsPVP(unit) then
      return "|cffFFFF00H|r"
     elseif UnitIsPVP("player") and UnitIsPVP(unit) then
      return "|cffFF0000H|r"
     elseif UnitIsPVP("player") and not UnitIsPVP(unit) then
      return "|cffFF0000H|r"
     elseif not UnitIsPVP("player") and not UnitIsPVP(unit) then
      return "|cff0000FFH|r"
     end
    end


    Quote from Gridius
    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 go to code, in the interface or in the LUA files outside the game?
    In the interface, the same place as for DogTagText
    Posted in: Unit Frames
  • 0

    posted a message on LuaTexts Official Thread
    Quote from Kerecha
    Pretty much only missing the Faction text now.
    local fact = UnitFactionGroup(unit)
    ...
    Posted in: Unit Frames
  • 0

    posted a message on LuaTexts Official Thread
    Kerecha, you code isn't quite optimal, here is an improvement.
    You don't want to call functions you have already defined. Here are minor changes to your code:
    if not UnitIsDeadOrGhost(unit) then
     if UnitPowerType(unit) == 0 then
      local max = MaxPower(unit)
      local cur = Power(unit)
       if max > 0 and cur ~= max then
        return "%s%%",Percent(cur,max)
       else
        return Short(max)
       end
     end
    end


    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 "-%d",miss
       else
        return Short(max)
      end
      else
        return "%s/%s",Short(cur,true),Short(max,true)
    end


    Regarding Guild info:
    guildName, guildRankName, guildRankIndex = GetGuildInfo(unit)
    Posted in: Unit Frames
  • 0

    posted a message on LuaTexts Official Thread
    Quote from Kerecha
    now small thing, how do i hide when full?

    if UnitPowerType(unit) == 0 then
    local max = MaxPower(unit)
    local cur = Power(unit)
     if max > 0 and cur ~= max then
      return "%s%%",Percent(cur,max)
     end
    end

    However, I don't see the need for "max >0" since if the powertype is mana, you aren't going to have a max==0 (other than I guess RoS in BT...but that's very unique). As a result, this code would probably work just as well:
    if UnitPowerType(unit) == 0 then
    local max = MaxPower(unit)
    local cur = Power(unit)
     if cur ~= max then
      return "%s%%",Percent(cur,max)
     end
    end
    Posted in: Unit Frames
  • 0

    posted a message on LuaTexts Official Thread
    Quote from Benea
    Putting these in results in an error :/ I will play around with it more.
    Whoops, use this:
    local s = Status(unit)
    local cr,cg,cb = ClassColor(unit)
    local currenthealth, maxhealth = HP(unit), MaxHP(unit)
    if s then
      return s
    end
    return "|cff%02x%02x%02x%s || %s%%|r",cr,cg,cb,currenthealth,Percent(currenthealth,maxhealth)
    I changed from cr,cg,cb to r,g,b midway through
    Posted in: Unit Frames
  • 0

    posted a message on LuaTexts Official Thread
    Quote from Benea
    I'm sorry, I wasn't clear. My code was for the health and power text on my target frame. I want them to be in the color of the class I am targeting. There's a preset choice for classcolored names, which I played around with, but thus far I have been unsuccessful.

    Thanks :)

    For health: (Current health | %health)

    local s = Status(unit)
    local cr,cg,cb = ClassColor(unit)
    local currenthealth, maxhealth = HP(unit), MaxHP(unit)
    if s then
      return s
    end
    return "|cff%02x%02x%02x%s || %s%%|r",cr,cg,cb,currenthealth,Percent(currenthealth,maxhealth)
    Note: "||" rather than "|". This is because | is an escape key, so to actually display it you must type it twice. Same goes for "%%" rather than just "%"

    For power: (Current power)

    local max = MaxPower(unit)
    if max > 0 then
      local cr,cg,cb = ClassColor(unit)
      return "|cff%02x%02x%02x%s|r",r,g,b,Power(unit)
    end


    Something I added for some of my power related tags:
    if UnitPowerType(unit) == 0 then
    ...
    end
    If you put your normal tag in there it will only display if the power type is mana.
    Posted in: Unit Frames
  • 0

    posted a message on LuaTexts Official Thread
    I'm not exactly sure what you are saying you want classcolored, so I can't sort of tell you using an example.

    local r,g,b = ClassColor(unit)
    return '|cff%02x%02x%02x%s|r',r,g,b,Name(unit)

    This will return the unit's name, class colored.

    Here is a breakdown of each element:
    "local r,g,b = ClassColor(unit)" will assign the numeric r,g,b values to the variables r,g,b (on a local level). ie r=125, g=44, b=0
    "return" takes the following quote and prints it
    "|cff" will begin a custom coloring
    "%02x" Will take a number from the input 'data' and return it as a 2 digit hexadecimal (0 means to lead with zeroes; 2 means there will be two digits, x means to return it as a hexadecimal). The three repetitions of this are the three color entries to "|cff"
    "%s" grabs a string from the input 'data'
    "|r" ends the custom coloring
    "r,g,b,Name(unit)" are the input 'data' for this example

    Note there are four "%" points within the quotation to be returned and they match up with the four input 'data' following the quotation to be returned
    Posted in: Unit Frames
  • 0

    posted a message on LuaTexts Official Thread
    Is it possible to make Alt Modifiers an Event Trigger.
    I wrote a nice tag for my fractional HP, but without an Event it doesn't really work (I'm not 100% sure the tag itself is even correct)
    local cur, max = HP(unit), MaxHP(unit)
    if IsAltKeyDown()
      return "%s/%s",cur,max
    else
      return "%s/%s",Short(cur,true),Short(max,true)
    end
    Posted in: Unit Frames
  • To post a comment, please or register a new account.