1. #1

    PB4: Show <info> on mouseover. (lua texts)

    What is the lua code to show my own and my target's health on mouseover, and then name when not moused over? Is this even possible?

  2. #2
    Scarab Lord
    15+ Year Old Account
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    4,040

    Re: PB4: Show <info> on mouseover. (lua texts)

    It's possible, but I have no idea. Try the LuaTexts discussion thread over at http://www.wowace.com/forums/

  3. #3

    Re: PB4: Show <info> on mouseover. (lua texts)

    Quote Originally Posted by Taryble
    It's possible, but I have no idea. Try the LuaTexts discussion thread over at http://www.wowace.com/forums/
    I think my eyes are bleeding from all the searching I've done there, but while I continue I'm still hoping someone can give me a less general direction ^_^

  4. #4

    Re: PB4: Show <info> on mouseover. (lua texts)

    Quote Originally Posted by Palaranger
    What is the lua code to show my own and my target's health on mouseover, and then name when not moused over? Is this even possible?
    Haven't touched the lua stuff in 3+ years but iirc , from: http://www.wowwiki.com/Events/Unit_Info
    You would register your event handler in the xml , probably for the event UPDATE_MOUSEOVER_UNIT, ( though says for the event it would only work mousing over the actual unit, not the frame ;/).

    Anyway, from : http://www.wowwiki.com/World_of_Warcraft_API , you'd then call UnitHealth("unit"), (the return value would be it's health) with the unit id triggered in the event. As for displaying purposes, that's up to you where and how you'd want to display it, there are many ways.

  5. #5

    Re: PB4: Show <info> on mouseover. (lua texts)

    I trudged through the lua code for this about a week ago, so to save you the trouble, here's my code.

    I'll tell you this now, this was made for a healer UI. So, i have the code placed into it to show a percent when not moused over, and scale in color as the person reach's different levels of health/mana.

    First, the health:
    Events that must be on - Unit_Aura, Unit_Health, Unit_Healthmax
    Code:
    local s = Status(unit)
    local cur,max=HP(unit),MaxHP(unit)
    local per=Percent(cur,max)
    if s then
     return s
    end
    if IsMouseOver() then
    return "|cff009900%s|r",HP(unit),MaxHP(unit)
    else
    if per<10 then
     return "|cffff0000%s|r",Percent(HP(unit),MaxHP(unit))
    else
    if per<25 then
     return "|cffff5511%s|r",Percent(HP(unit),MaxHP(unit))
    else
    if per<50 then
     return "|cffffcc33%s|r",Percent(HP(unit),MaxHP(unit))
    else
    return "|cff009900%s|r",Percent(HP(unit),MaxHP(unit))
    end
    end
    end
    end
    Now the code for mana:
    Events that must be on - Unit_DisplayPower, Unit_Energy, Unit_Focus, Unit_Mana, Unit_Maxenergy, Unit_Maxfocus, Unit_Maxrage, Unit_Maxrunic_power, Unit_Rage, Unit_Runic_Power
    Code:
    local s = Status(unit)
    local cur,max=Power(unit),MaxPower(unit)
    local per=Percent(cur,max)
    if s then
     return s
    end
    if IsMouseOver() then
    return "|cff1188ff%s|r",Power(unit),MaxPower(unit)
    else
    if per<10 then
     return "|cffff0000%s|r",Percent(Power(unit),MaxPower(unit))
    else
    if per<25 then
     return "|cffff5511%s|r",Percent(Power(unit),MaxPower(unit))
    else
    if per<50 then
     return "|cffffcc33%s|r",Percent(Power(unit),MaxPower(unit))
    else
    return "|cff009900%s|r",Percent(Power(unit),MaxPower(unit))
    end
    end
    end
    end
    Edit: Noticed you wanted it to switch to name, this is very possible, in fact, here's the code(Note - For health):
    Events that must be on - Player_Flags_Changed, Unit_Aura, Unit_Health, Unit_Healthmax, Unit_Name_Update
    Code:
    local s = Status(unit)
    local cur,max=HP(unit),MaxHP(unit)
    local per=Percent(cur,max)
    if s then
     return s
    end
    if IsMouseOver() then
    return "|cff009900%s|r",HP(unit),MaxHP(unit)
    else
    return '%s %s%s%s',Name(unit),Angle(AFK(unit) or DND(unit))
    end
    In the odd case you want the above code for mana:
    Events that must be on - Player_Flags_Changed, Unit_Aura, Unit_Name_Update, Unit_DisplayPower, Unit_Energy, Unit_Focus, Unit_Mana, Unit_Maxenergy, Unit_Maxfocus, Unit_Maxrage, Unit_Maxrunic_power, Unit_Rage, Unit_Runic_Power
    Code:
    local s = Status(unit)
    local cur,max=Power(unit),MaxPower(unit)
    local per=Percent(cur,max)
    if s then
     return s
    end
    if IsMouseOver() then
    return "|cff009900%s|r",Power(unit),MaxPower(unit)
    else
    return '%s %s%s%s',Name(unit),Angle(AFK(unit) or DND(unit))
    end
    A not about colors - These are all set to my own colors. Lua uses hex based colors. To change the color to a color of your choice, refer to "|cff009900%s|r" The number's in bold must be changed to the correct hex value's. They go as such, with 2 numbers for each, Red, Green, Blue. numbers may range from 0-9, and a-f. Letters are higher value then numbers.

    A quick search of google gets me http://www.december.com/html/spec/color.html i recommend that sight for all your color value finding needs.

  6. #6
    Scarab Lord
    15+ Year Old Account
    Join Date
    Aug 2008
    Location
    Texas
    Posts
    4,040

    Re: PB4: Show <info> on mouseover. (lua texts)

    Thank you, Darkness Seraph. Now we can point to your post the next time this comes up.

  7. #7

    Re: PB4: Show <info> on mouseover. (lua texts)

    Yar, i spent about 8 hours studying and scripting the original health/percent scripts recreating a druid UI that a saw in the "healers post your ui" thread(it's a hobby of mine to find complicated ui's a recreate them from scratch). and a side effect is that i learned a lot about lua along the way, as you can see by my quick rig of that code to work with names.

    I could make a thread or something, but i'm pretty lazy so it'd likely just fall into disarray.... heh.

  8. #8

    Re: PB4: Show <info> on mouseover. (lua texts)

    Thank you so much

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •