Close
Showing results 1 to 9 of 9
  1. #1

    Default simple addon to display Holy Power Party

    i ve written some code to display Holy power for my other paladins in my main screen.

    wasted some hours trying to manage Holy power from others with combat log parsing.
    this approach doesn t requires communication between clients, but it s incredibly complicated.

    Following Jamba example, with communication between clients, this task is really simple.
    I m not an expert about addon scripting, Lua and wow api.

    how it works? simple mode. atm there are not configuration options.



    - there are 2 .lua files: 1) file_1 for main; 2)file_2 for slaves
    - atm many things are not implemented. Addon shows values for Holy power using simply a numer (0-3 range).
    - no texture use atm.
    - font type and dimension is defined in "text1:SetFont("Fonts\\ARIALN.TTF", 32)" line: it s customizable path and dimension.
    -
    - Lua files are different for Main and slaves. if you want test it with a main char ='other then paladin', you need to change code a bit.
    nothing complicated but frame1 and event UNIT_POWER and handler1 function are not needed and can generate errors if left.
    - MyGrp table is my grp composition.

    now the code.
    Lua code file_1:
    Code:
    -- player [1] is always leader. others are 2-5
    -- Holy Power values are shown with text
    
    local MyGrp = {
    [1] = "Prega",
    [2] = "Alad",
    [3] = "Redcrox" ,
    [4] = "Whitecrox" ,
    [5] = "Yargo"
    }
    ---------------------------------------
    ---------------------------------------
    local gn = #MyGrp
    local myname =UnitName ("player")
    local w = "WHISPER"
    
    
    
    -------------FRAMES--------------------------------------------
    ----------- all frames are movable by default with left mouse drag
    
    
    
    --------------------------frame1=PREGA--local frame for main(prega) hp--
    frame1 = CreateFrame("Frame", "frame1", UIParent)
    text1 = frame1:CreateFontString()
    
    frame1:SetPoint("CENTER",0, -100)
    frame1:SetWidth(128)
    frame1:SetHeight(128)
    frame1:SetMovable(true)
    frame1:EnableMouse(true)
    text1:SetAllPoints(frame1)
    text1:SetFont("Fonts\\ARIALN.TTF", 32)
    
    
    frame1:RegisterForDrag("LeftButton")
    frame1:SetScript("OnDragStart", function(self) self:StartMoving() end)
    frame1:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
    
    --------------------------frame2=ALAD
    frame2 = CreateFrame("Frame", "frame2", UIParent)
    text2 = frame2:CreateFontString()
    
    frame2:SetPoint("CENTER",0, -80)
    frame2:SetWidth(128)
    frame2:SetHeight(128)
    frame2:SetMovable(true)
    frame2:EnableMouse(true)
    text2:SetAllPoints(frame2)
    text2:SetFont("Fonts\\ARIALN.TTF", 32)
    
    
    frame2:RegisterForDrag("LeftButton")
    frame2:SetScript("OnDragStart", function(self) self:StartMoving() end)
    frame2:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
    
    ---------------------------frame3=REDCROX
    frame3 = CreateFrame("Frame", "frame3", UIParent)
    text3 = frame3:CreateFontString()
    
    frame3:SetPoint("CENTER",0, -80)
    frame3:SetWidth(128)
    frame3:SetHeight(128)
    frame3:SetMovable(true)
    frame3:EnableMouse(true)
    text3:SetAllPoints(frame3)
    text3:SetFont("Fonts\\ARIALN.TTF", 32)
    
    
    frame3:RegisterForDrag("LeftButton")
    frame3:SetScript("OnDragStart", function(self) self:StartMoving() end)
    frame3:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
    
    ---------------------------frame4=WHITECROX
    frame4 = CreateFrame("Frame", "frame4", UIParent)
    text4 = frame4:CreateFontString()
    
    frame4:SetPoint("CENTER",0, -80)
    frame4:SetWidth(128)
    frame4:SetHeight(128)
    frame4:SetMovable(true)
    frame4:EnableMouse(true)
    text4:SetAllPoints(frame4)
    text4:SetFont("Fonts\\ARIALN.TTF", 32)
    
    
    frame4:RegisterForDrag("LeftButton")
    frame4:SetScript("OnDragStart", function(self) self:StartMoving() end)
    frame4:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
    ---------------------------frame5=YARGO
    frame5 = CreateFrame("Frame", "frame5", UIParent)
    text5 = frame5:CreateFontString()
    
    frame5:SetPoint("CENTER",0, -80)
    frame5:SetWidth(128)
    frame5:SetHeight(128)
    frame5:SetMovable(true)
    frame5:EnableMouse(true)
    text5:SetAllPoints(frame5)
    text5:SetFont("Fonts\\ARIALN.TTF", 32)
    
    
    frame5:RegisterForDrag("LeftButton")
    frame5:SetScript("OnDragStart", function(self) self:StartMoving() end)
    frame5:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
    
    
    
    
    --------handle event UNIT POWER for main:not useful if main is not a paladin
    function handler1(self,event, ...)
    
        local source, type = select(1, ...);
        if source == "player" and type == "HOLY_POWER" then
            p = UnitPower("player",9)
            text1:SetText(p)
    
        end
    end
    
    -----handle event CHAT_MSG_ADDON: sources are other members of team, values of HP for all are displayed on main screen only atm.
    function handler2 (self, event, ...)
        local prefix, msg, distr, sender = ...;
        if prefix == "Multihp" and  msg and sender == MyGrp[2] then
        msgn = tonumber(msg)
        text2:SetText(msgn)
        elseif prefix == "Multihp" and  msg and sender == MyGrp[3] then
        msgn = tonumber(msg)
        text3:SetText(msgn)
        elseif prefix == "Multihp" and  msg and sender == MyGrp[4] then
        msgn = tonumber(msg)
        text4:SetText(msgn)
        elseif prefix == "Multihp" and  msg and sender == MyGrp[5] then
        msgn = tonumber(msg)
        text5:SetText(msgn)
        end
    end
    
    
    
    
    
    -------- set handlers and register events for each frames
    
    frame1:SetScript("OnEvent", handler1)
    frame2:SetScript("OnEvent", handler2)
    frame3:SetScript("OnEvent", handler2)
    frame4:SetScript("OnEvent", handler2)
    frame5:SetScript("OnEvent", handler2)
    frame1:RegisterEvent("UNIT_POWER")
    frame2:RegisterEvent("CHAT_MSG_ADDON")
    frame3:RegisterEvent("CHAT_MSG_ADDON")
    frame4:RegisterEvent("CHAT_MSG_ADDON")
    frame5:RegisterEvent("CHAT_MSG_ADDON")
    and this part is for other paladins (slaves): file_2

    Code:
    ---------------------------------------
    local gl = "Prega"
    local myname =UnitName ("player")
    local w = "WHISPER"
    
    
    --------------------------frame1=LOCAL CHAR--local frame for current char hp--
    frame1 = CreateFrame("Frame", "frame1", UIParent)
    text1 = frame1:CreateFontString()
    
    frame1:SetPoint("CENTER",0, -100)
    frame1:SetWidth(128)
    frame1:SetHeight(128)
    frame1:SetMovable(true)
    frame1:EnableMouse(true)
    text1:SetAllPoints(frame1)
    text1:SetFont("Fonts\\ARIALN.TTF", 32)
    
    
    frame1:RegisterForDrag("LeftButton")
    frame1:SetScript("OnDragStart", function(self) self:StartMoving() end)
    frame1:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
    
    
    
    -------- handle event UNIT_POWER and dispatch current char HPower to main char
    
    function handler1(self,event, ...)
    
        local source, type = select(1, ...);
        if source == "player" and type == "HOLY_POWER" then
            p = UnitPower("player",9)
                text1:SetText(p)
            SendAddonMessage("Multihp", p, w, gl)
    
        end
    end
    
    
    
    
    
    
    
    
    
    
    -------Register event and define handler for event
    
    frame1:SetScript("OnEvent", handler1)
    frame1:RegisterEvent("UNIT_POWER")

  2. #2
    Member
    Join Date
    Sep 2008
    Location
    Calgary, AB and Vancouver, BC
    Posts
    7638
    Blog Entries
    2

    Default

    This is neat, and could be adapted for whatever... combo points, holy power, etc.
    EverQuest I: Bard / Enchanter / Druid / Wizard / 2x Magician.
    Diablo III: 4x Crusader & 4x Wizard.

    My Guide to IS Boxer http://www.dual-boxing.com/showthread.php?t=26231 (somewhat dated).
    Streaming in 1080p HD: www.twitch.tv/ualaa
    Twitter: @Ualaa


  3. #3

    Default

    Awesome~, Thanks for sharing.

  4. #4

    Default

    As far as I know, the API for UnitPower has types, and combo points aren't listed as usable.

    Did you add this code into a folder, or stuffed it inside another addon?
    Vek'linash - Alliance
    Morra -5 man PVE <League of Crafters>
    Prank - Rogue - Solo Toon
    PVP Druid Team - Boxone, Boxtwo, Boxthree, Boxfour, Boxfive. 2 Resto, 3 Feral

  5. #5

    Default

    As far as I know, the API for UnitPower has types, and combo points aren't listed as usable.
    yes exact.
    combo points are not "shown" with UnitPower("unit",type").
    In UnitPower "unit" is the "unit"-power to show.
    and "type" has values from 1 to 9:
    1)mana,2)rage,3).....9)holypower, no combo points but energy is avaible for rogues/cat druids here with this API function.
    for many types of energy it works for "player" as "unit" but doesnt work for specific characters names( bad limit for Mboxers), so i decided to use communications.
    In this way it works outside groups, communications are always sent and recieved if characters involved in send-recieve are online in same server at same time. Ofc characters need to be configured in the code as senders and reciever.

    not sure what happens with chars names in BG, but according some documents i read, simple chars names like "Prega", for example, in BG become "Prega-Alonsus", where alonsus is my server name.
    a simple condition added in 'IF then' statement will solve all communications issues in BG.

    Combo Points are different. the main issue is combo points are target related.
    Manage combo points surely is a bit + complicated.
    somenthing have to happen when you change target or if you targetting for mistake/lag something wrong: otherwize you display wrong values.
    But there are some events "generators" like UNIT_COMBO_POINTS, fired when combo points happen and usable in a similar logical scheme to communicate and display the values.
    Or simply use function GetComboPoints(unit, target): unit="player" and target is target explicitly declared. looks easier to use but it needs some code to manage what happens when targets are different for slaves and main.
    This happens expecially when main switch target etc.

    A lot easier looks display Rune values for DK.
    Rune works with UnitPower, it is type 5.
    Not sure about what format have data output (not tested atm).
    maybe requires some little fix.
    Explain. You know Runes are 3 "sub-types": blood, frost and unholy.
    it s good know amount avaible and, ofc, sub-type in real time, not just a simple undefined number.

    Did you add this code into a folder, or stuffed it inside another addon?
    this is a little addon internal code:
    i know it s not a complete addon...in normal sense hehe.
    but little time to create a easier way to use it.
    idea was to share general infos about how it s possible and "easy" manage things like holy power etc etc with simple code (believe me it s a simple code, rewritten trying to avoid usage of strange complex functions, avoiding xml usage, avoiding framework usage etc etc, keeping in this way code + readable)
    yes, , atm customization cant result so easy .
    here missing .toc file, a needed file for any addons: it defines .lua file association and, implicitly, addon folder.

    i try to show a step by step a customization process.

    open a notepad file, copy the whole named file_1 content in your empty notepad file. as above.
    Save this file as a .Lua, giving it as name "Multihp.lua". Tips: verify it is saved as a .lua not a.txt.

    In file_1:
    -STEP1

    Code:
    -- player [1] is always leader. others are 2-5
    -- Holy Power values are shown with text
    
    local MyGrp = {
    [1] = "Prega",
    [2] = "Alad",
    [3] = "Redcrox" ,
    [4] = "Whitecrox" ,
    [5] = "Yargo"
    }
    sub "Prega" with your main name, aka name of char where you want show holypower for all group.keep "name" format.
    after that, keeping number order, sub "Alad" name with your char nr 2 and then redcrox and so on etc etc.
    ------------------
    -STEP2

    --------------------------frame1=PREGA--local frame for main(prega) hp--
    frame1 = CreateFrame("Frame", "frame1", UIParent)
    text1 = frame1:CreateFontString()

    frame1:SetPoint("CENTER",0, -100)
    frame1:SetWidth(128)
    frame1:SetHeight(128)
    frame1:SetMovable(true)
    frame1:EnableMouse(true)
    text1:SetAllPoints(frame1)
    text1:SetFont("Fonts\\ARIALN.TTF", 32)


    frame1:RegisterForDrag("LeftButton")
    frame1:SetScript("OnDragStart", function(self) self:StartMoving() end)
    frame1:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)


    --------------------------frame2=ALAD
    frame2 = CreateFrame("Frame", "frame2", UIParent)
    text2 = frame2:CreateFontString()......................... .
    Delete the bold-underline text if you going to use a Main char is NOT A PALADIN.
    -----------------

    STEP3

    Code:
    --------handle event UNIT POWER for main:not useful if main is not a paladin
    function handler1(self,event, ...)
    
        local source, type = select(1, ...);
        if source == "player" and type == "HOLY_POWER" then
            p = UnitPower("player",9)
            text1:SetText(p)
    
        end
    end
    Again, IF YOUR MAIN IS NOT A PALADIN, delete. bold-underline text
    --------

    STEP4

    Code:
    -------- set handlers and register events for each frames
    
    frame1:SetScript("OnEvent", handler1)
    frame2:SetScript("OnEvent", handler2)
    frame3:SetScript("OnEvent", handler2)
    frame4:SetScript("OnEvent", handler2)
    frame5:SetScript("OnEvent", handler2)
    frame1:RegisterEvent("UNIT_POWER")
    frame2:RegisterEvent("CHAT_MSG_ADDON")
    frame3:RegisterEvent("CHAT_MSG_ADDON")
    frame4:RegisterEvent("CHAT_MSG_ADDON")
    frame5:RegisterEvent("CHAT_MSG_ADDON")
    Delete, IF YOUR MAIN IS NOT A PALADIN, bold-underline text

    Save and exit
    -------------------------

    STEP ON file_2.lua
    Open a new notepad empty file, copy in it code from file_2 above and give it name "Multihp1.lua" and save as .lua file type.

    in file_2 content, at 1st line

    Code:
    ---------------------------------------
    local gl = "Prega"
    local myname =UnitName ("player")
    local w = "WHISPER"
    change "Prega", with name of your Main name.
    save and exit.

    go in wow/interface/addon folder and create a new folder called "Multihp" for your main char addon.
    Put Multihp.lua in this folder.

    in this folder create a new notepad empty file, name it "Multihp.toc"
    copy/paste this content:

    Code:
    ## Author: Me
    ## Interface: 40000
    ## Title: Multihp
    ## Version: 1.0
    Multihp.lua
    save as .toc file and exit

    for each slaves, if you use multiple wow folders, or just 1 time if you use a single wow folder, create a new folder in wow/interface/addons path and name it "Multihp1". It hosts the addon for slaves.
    in this folder create the .toc with notepad, as explained and name it "Multihp1.toc"

    Code:
    ## Author: Me
    ## Interface: 40000
    ## Title: Multihp1
    ## Version: 1.0
    Multihp1.lua
    unique things different are the bold-underline text.
    put in folder Multihp1 the file Multihp1.lua file.

    at the end each folder, Multihp and Multihp1, have to contain 2 files:
    in Multihp folder, files are Multihp.lua and Multihp.toc. Multihp.lua is file_1 modified
    in Multihp1 folder, files are Multihp1.lua and Multihp1.toc. Multihp1.lua is file_2 modified.

    check for main char only Multihp is active as addon and Multihp1 is active as addon only for slaves chars.

    i know, it sounds complicated
    Last edited by Prega : 11-24-2010 at 10:44 AM

  6. #6
    Member Alge's Avatar
    Join Date
    Nov 2010
    Location
    Sydney, Australia
    Posts
    322

    Default

    for many types of energy it works for "player" as "unit" but doesnt work for specific characters names( bad limit for Mboxers), so i decided to use communications.
    I just want to make sure I understand this clearly because I would like to go back to my DK and 4 paladin team...

    Is this communication solution required because UnitPower("party2", 9) always returns zero, even if the character in slot party2 is a paladin?

    Alternatively, does UnitPower(unit, 9) only return meaningful values when unit == "player"? Is this a bug or a feature of the API?

    Thanks,

    Alge
    Last edited by Alge : 12-03-2010 at 07:08 PM Reason: quote, clarity

  7. #7

    Default

    I don't think this communication solution required it is optional.

  8. #8

    Default

    Is this communication solution required because UnitPower("party2", 9) always returns zero, even if the character in slot party2 is a paladin?

    Alternatively, does UnitPower(unit, 9) only return meaningful values when unit == "player"? Is this a bug or a feature of the API?

    Thanks,

    Alge
    i did several tests.

    Do an example.
    do a macro with this script inside. It assigns s=UnitPower and print s in the chat.

    generic script, without real parameters for UnitPower:
    /run s = UnitPower(unit,powertype); print s;

    as said, this script could be tested in a macro button, if you click this macro it prints in chat current value registered by UnitPower function.

    real example: i test mana, powertype 0.
    for my paladin, Yargo. im doing this on other char, for example on my druid Chymera.

    /run s = UnitPower("Yargo",0); print s;
    result: script shows current mana for yargo.5591

    example: i test mana for "party1". im groupped with yargo ofc.
    /run s = UnitPower("party1",0); print s;
    result: script shows current mana for party1.5591
    etc etc.

    now Holy Power type.
    test for powertype = 9, aka Holy Power

    same tests, for yargo and for party1
    /run s = UnitPower("party1",9); print s;
    result is always 0. same for "Yargo".

    i think it s not something wrong, but it s working as inteded, exactly as happens for combo points, or Rune.
    Blizzard probably thinks HolyPower is a useful value just for current player.
    Last edited by Prega : 12-04-2010 at 10:17 AM

  9. #9
    Member Alge's Avatar
    Join Date
    Nov 2010
    Location
    Sydney, Australia
    Posts
    322

    Default

    Thanks for the response Prega - very clear explanation.

    Alge

Posting Rules

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