1. I've looked all over the web but Im unable to find a good breakdown for the string that is returned by CHAT_MSG_LOOT. Im basically going to track Emblems with the addon and registering with that event. Is the only argument passed to me from the event the text from the chat window "Someone receives [Emblem of Valor]" or are there paramters that will tell me the "someone"??? anyone have any code snippets or anything...?

    I've looked all over the web but Im unable to find a good breakdown for the string that is returned by CHAT_MSG_LOOT. Im basically going to track Emblems with the addon and registering with that event. Is the only argument passed to me from the event the text from the chat window "Someone receives [Emblem of Valor]" or are there paramters that will tell me the "someone"??? anyone have any code snippets or anything...?

    At least according to this, you should be able to take the second argument and do a simple If Then to see if its your character looting the emblem. If it is you, up your counter or however your addon is keeping track of it.

    This is how I'd program it: http://pastey.net/109127, but it is untested. At the very least, I hope I'm pointing you in the right direction.

    That is helpful. my addon isnt going to track my emblems though. im raid leader for the guild and i want to ensure that everyone loots their emblems. a lot of the time its busy and they dont notice. so my addon populates a frame with all the player names in write and once the loot an emblem it changes their text to green.

    So Ill run some test with this info and see what i get, thanks for the help...

     

    Oh, in that case, it'd be a little different... 

    Looks like you'll need at least one array to handle the raid list of names, and maybe another to handle how many each person has looted. Unless you raid with say, the same exact 10 people, you'll have to have a function that'll update the Raid_List array depending on who is in the group, otherwise you could just hardcode the list of names.

    I'll see if i can write a better generalization in the morning for you.

    I almost have it, but I'm running into a small wall. I have everything else in working order, except for only making it count when the player has looted an emblem.

    The description of which argument that holds the actual item looted is rather vague (from the event). Once I know which argument to If..Then test to see if its either the correct item (emblem of heroism or valor, since I assume you'll be needing to track both) it'll just require a few finishing touches and then I'll have the bulk of the code ready for you.

    Well, first, tanks for all the help, I really appreciate it. Next, I don't need to count anything. This addon on is very simply a frame gets populated with all of the raid or party members with their names in white. Once they loot an emblem it turns green. once everyone is green im done and the window can be closed. I dont want to count them i just want to know who hasnt looted yet. Here is a little of my code that i have at this point.

    function TCoLEmblems_Populate()

        PlayerText = "|cffffffffParty Members: " .. GetNumPartyMembers() .. "\n\n";

        if (GetNumPartyMembers() > 0) then

            for count=1, GetNumPartyMembers(), 1 do

                PlayerText = PlayerText .. UnitName("party" .. count) .. "\n"

            end       

        end   

        return PlayerText

    end

    this is the bullk of the addon right now. I have not added the raid section yet as Im troubleshooting and working through it via party. So i start an array PlayerText with how many are in the party. I keep appending that list with each player in the raid via GetNumPartyMembers(). So far this works EXCEPT, the GetNumPartyMembers() does NOT count me. so I have to figure out how to add myself first and then run the "if" staement. The "if" statement also determines if im in a raid or party.

    as you can tell from this too, I actaully dont change anything to green this is still troubleshooting code and Im making sure i populate correctly first, but its simple enough with "|cffhexcolorPlayer Name|r". a little more code than that but you get teh picture.

     

    This function will store you and everyone in your raid. If you have the WoWLua addon installed, you can copy this in, invite a friend (or more) into a raid, and run it. Then you have your raid nice and neatly listed in the Raid_List.name array.

    I still haven't found away around splitting up the first argument of CHAT_MSG_LIST into separate strings. I try to print it, and all that comes out are various tables. I've tried creating a metatable and using tostring() to try to get it to actually print, but that won't work either.

    Here's a link to the entire lua document of what I've done. You can get rid of the counter, since you don't need it. It'll run if you want to try it out, except for the looting part, but LoadRaid() and ResetRaid() will work.

    Looks like your almost done, except for sticking in the actually hex number for the color you want. Do you have the code for transferring your PlayerText to the frame?

    Edit: jnwhiteh, feel free to jump in at any time with an elegantly simple solution. ;)

    What you have don't seem overly complex in any way.. I'd probably do much the same.

    OK, I looked at the links you sent and they are great but I did it a bit different. Below is the code for initial population of my array. Im actually creating an array and referencing it by the players name and not a number eg(PlayersArray["Taborious"] instead of PlayersArray[1]) that way when someone loots and I get the name of the player, I only have to update that specific array as opposed to parsing the array and looking for the players name. Though I still have to parse throw it to update the SetText variable, i thought this way was cool :-)

    Next is capturing and parsing the CHAT_MSG_LOOT msg. Are there any debugging tools or anything that I can test things without having to log into WOW. or something in WOW that will tell me what happened when my addon isnt working. Something to give me some information to go on...???

     

    function TCoLEmblems_Populate()

        HasntLooted = "|cffffffff"

        PlayersText = ""

        TCoLEmblems_PlayersArray = {}

        if (GetNumRaidMembers() > 0) then

            TCoLEmblems_PlayersArray["PCount"] = HasntLooted .. "Total Players: " .. (GetNumRaidMembers() + 1) .. "\n\n"

            PlayersText = TCoLEmblems_PlayersArray["PCount"]

            TCoLEmblems_PlayersArray[UnitName("player")] = HasntLooted .. UnitName("player") .. "\n"

            PlayersText = PlayersText .. TCoLEmblems_PlayersArray[UnitName("player")]

            for count=1, GetNumRaidMembers(), 1 do

                TCoLEmblems_PlayersArray[UnitName("raid" .. count)] = HasntLooted .. UnitName("raid" .. count) .. "\n"

                PlayersText = PlayersText .. TCoLEmblems_PlayersArray[UnitName("raid" .. count)]

            end

            return PlayersText

        end

        if (GetNumPartyMembers() > 0) then   

            TCoLEmblems_PlayersArray["PCount"] = HasntLooted .. "Total Players: " .. (GetNumPartyMembers() + 1) .. "\n\n"

            PlayersText = TCoLEmblems_PlayersArray["PCount"]

            TCoLEmblems_PlayersArray[UnitName("player")] = HasntLooted .. UnitName("player") .. "\n"

            PlayersText = PlayersText .. TCoLEmblems_PlayersArray[UnitName("player")]

            for count=1, GetNumPartyMembers(), 1 do

                TCoLEmblems_PlayersArray[UnitName("party" .. count)] = HasntLooted .. UnitName("party" .. count) .. "\n"

                PlayersText = PlayersText .. TCoLEmblems_PlayersArray[UnitName("party" .. count)]

            end

            return PlayersText

        end

        PlayersText = "Not in Raid or Party"

    end

    Next is capturing and parsing the CHAT_MSG_LOOT msg. Are there any debugging tools or anything that I can test things without having to log into WOW. or something in WOW that will tell me what happened when my addon isnt working. Something to give me some information to go on...???

    Download DevTools (http://www.wowinterface.com/downloads/info3999-DevTools.html ) and see what the arguments to the CHAT_MSG_LOOT event are, or just write a small snippet of code that just prints the arguments when the event fires.  

    I don't really understand what you're asking tho.. You need to be in WoW in order to test your addon, and WoW gives you plenty of information when things have gone wrong (for example error messages).  What more are you looking for?

    Nothing can tell you why your code doesn't work, you're the one who has to figure that out =)

    What I mean is, when i make a change and log into WOW sometimes it works and sometimes it doesn't and I get no popup or anything. I don't know if you have to turn on debug in wow or something so that these messages appear when an addon goes wrong or has a syntax error. Im not asking it to correct it for me just tell me what it doesn't like. Just anything aside from nothing which is what im getting now. When troubleshooting now, all i know after logging in is it doesn't work. Other types of coding will return an error popup like " Unexpected / near something" or " variable is nil" or something like that.

    I downloaded the devtools i think that will help a lot for finding the information i need from CHAT_MSG_LOOT thanks for the link...

     

    The error messages you are talking about "Unexpected / near something, etc" are all that WoW will provide.  They'll tell you when you've done something syntactically or semantically wrong.  Unfortunately nothing can tell you if your code is not doing what you INTEND it to do, because you're not coding intent.

    In short, if you want to find out what your code is doing, add some print() statements inside to see what's being called, how often it's being called and in what order.  While it's not the most sophisticated debugging technique, it definitely works!

    I understand that WOW will only provide those error messages, my point is Im NOT getting those popup messages, I get NOTHING. Is there a setting for enabling or disabling debug messages in WOW. Maybe Ive turned it off by mistake...?

     

    Interface Options, Help, Display Lua Errors

    function IsInGroup(name)
        -- note, actually check to make sure it's a raid
        for i = 1, GetNumRaidMembers() do
            if UnitName("raid"..i) == name then
                return true
            end
        end
        return false
    end
    
    
    local looter, itemLink = string.match(msg, "(%a+) receives? loot: (.+)%.");
    if (IsInGroup(looter)) then
        doStuff()
    end

    I think the only issue now is to parse the "<player> receives loot: [Emblem of Heroism]" message, so that the addon will change the player's name if they have looted an emblem...

    Unless Taborious has taken care of that part, in which case I'd love to see the finished project. :)

    I did the loot inspection a little different.

    44208 i think is Valor and 39211 is heroism

    function TCoLEmblems_OnEvent()

        local _,_,itemID = strfind(arg1, "(%d+):")

        if (itemID == "44208") or (itemID == "39211") then

            TCoLEmblems_Frame:Show()

            if TCoLEmblems_IsFirstLooted then

                TCoLEmblems_IsFirstLooted = false

                TCoLEmblems_Players:SetText(TCoLEmblems_Populate())

                TCoLEmblems_Players:SetText(TCoLEmblems_Update())

            else

                TCoLEmblems_Players:SetText(TCoLEmblems_Update())

            end

        end

    end

    As Im still writing and troubleshooting Im only using the party test not raid, i can add that in easy enough once party works right.

    function TCoLEmblems_Populate()

        local HasntLooted = "|cffffffff"

        PlayersText = ""

        TCoLEmblems_PlayersArray = {}

        if (GetNumPartyMembers() > 0) then

            TCoLEmblems_PlayersArray["PCount"] = HasntLooted .. "Total Players: " .. (GetNumPartyMembers() +1) .. "\n\n"

            PlayersText = TCoLEmblems_PlayersArray["PCount"]

            TCoLEmblems_PlayersArray[UnitName("player")] = HasntLooted .. UnitName("player") .. "\n"

            PlayersText = PlayersText .. TCoLEmblems_PlayersArray[UnitName("player")]

            for count=1, GetNumPartyMembers(), 1 do

                TCoLEmblems_PlayersArray[UnitName("party" .. count)] = HasntLooted .. UnitName("party" .. count) .. "\n"

                PlayersText = PlayersText .. TCoLEmblems_PlayersArray[UnitName("party" .. count)]

            end

            return PlayersText

        end

        PlayersText = "Not in a Party or Raid"

        return PlayersText

    end



    function TCoLEmblems_Update()

        local Looted = "|cff44cd44"

        local _,_,LootingPlayer = strfind(arg1, "(%w+)")

        if (LootingPlayer == "You") then

            LootingPlayer = UnitName("player")

        end

        TCoLEmblems_PlayersArray[LootingPlayer] = Looted .. LootingPlayer .. "\n"

        PlayersText = TCoLEmblems_PlayersArray["PCount"]

        if (GetNumPartyMembers() > 0) then

            for count=1, GetNumPartyMembers(), 1 do

                if (LootingPlayer == UnitName("player")) then

                    PlayersText = PlayersText .. TCoLEmblems_PlayersArray[UnitName("player")]

                else

                    PlayersText = PlayersText .. TCoLEmblems_PlayersArray[UnitName("party" .. count)]

                end

            end

            return PlayersText

       

       

        PlayersText = "update"

        return PlayersText

    end

     

    I am the first in my guild to write an addon so once this is complete and working I will fully document the code with comments to help the other first timers.

    Sorry, i think those 2 itemIDs are for a gray Log and shattered fang, i was using those for testing.

    Anyone have any idea why this does not work? I processes fine and prints "TCoL Emblems: Disabled" but the chat_msg_loot is still registered and fires when someone loots and opens my addon...???

    function TCoLEmblems_OnLoad()

        TCoLEmblems_IsFirstLooted = true;

        this:RegisterEvent("CHAT_MSG_LOOT");

        this:RegisterForDrag("LeftButton");

        SlashCmdList["TCoLEmblems"] = function(cmd)

        TCoLEmblems_slash(cmd);

        end

        SLASH_TCoLEmblems1 = "/tcolem";

    end



    function TCoLEmblems_slash(cmd)

        if cmd and cmd == "open" then

            TCoLEmblems_Frame:Show()

            TCoLEmblems_Players:SetText(TCoLEmblems_Populate())

        end

        if cmd and cmd == "disable" then

            this:UnregisterEvent("CHAT_MSG_LOOT")

            DEFAULT_CHAT_FRAME:AddMessage("TCoL Emblems: Disabled")

        end

    end

     

    Nevermind, forgot my slash function needs to go before OnLoad()

    Side note, you should NOT be using this.  You should be using the private versions of self that are passed to all event handlers, and detailed in the chapters in the book.  The use of this is deprecated, and I would expect it to go away any time.

    Having an issue with my registrations and slash commands. Trying to use self: but i get error trying to index global 'self'(a nil value) ??? the code below are in my lua file in the order listed below.



    function TCoLEmblems_slash(cmd)

    if cmd and cmd == "open" then

    TCoLEmblems_Frame:Show()

    TCoLEmblems_Players:SetText(TCoLEmblems_Populate())

    end

    if cmd and cmd == "disable" then

    self:UnregisterEvent("CHAT_MSG_LOOT")

    DEFAULT_CHAT_FRAME:AddMessage("TCoL Emblems: Disabled")

    end

    if cmd and cmd == "enable" then

    self:RegisterEvent("CHAT_MSG_LOOT")

    DEFAULT_CHAT_FRAME:AddMessage("TCoL Emblems: Enabled")

    end

    end



    function TCoLEmblems_OnEvent()

    local _,_,itemID = strfind(arg1, "(%d+):")

    if (itemID == "44208") or (itemID == "39211") then

    TCoLEmblems_Frame:Show()

    if TCoLEmblems_IsFirstLooted then

    TCoLEmblems_IsFirstLooted = false

    TCoLEmblems_Players:SetText(TCoLEmblems_Populate())

    TCoLEmblems_Players:SetText(TCoLEmblems_Update())

    else

    TCoLEmblems_Players:SetText(TCoLEmblems_Update())

    end

    end

    end



    function TCoLEmblems_OnLoad(self)

    TCoLEmblems_IsFirstLooted = true;

    self:RegisterEvent("CHAT_MSG_LOOT");

    self:RegisterForDrag("LeftButton");

    SlashCmdList["TCoLEmblems"] = function(cmd)

    TCoLEmblems_slash(cmd);

    end

    SLASH_TCoLEmblems1 = "/tcolem";

    end

    Self makes no sense in that context.. you're trying to use it where it isn't declared.  What are you actually trying to do?  If you want to address the frame, address it by name. The slash command handler doesn't get passed the frame object (there would be no logic to this whatsoever).

    Im going off of your post where you said I should not be using "this:" that i should be using "self:" because it was deprecated.

    Why doesn't it make sense? Im trying to register or unregister an event by changing the reference from "this" to "self"

    It doesn't make sense because there is no variable named 'self' anywhere in the scope of that code.  The only reason 'this' worked is because its a global variable.. but that's precisely why you should not be using it.  I cannot tell you what to specifically put without seeing all of the code (and please do not post it here, use http://pastey.net for that).

    Instead of using 'self' or 'this' within the slash command handler, you should use the name of the frame that you are actually trying to alter.

    So the frame for my addon is

    <Frame name="TCoLEmblems_Frame" parent="UIParent" toplevel="true" movable="true" enableMouse="true">

    So the registration and/or unregistration should be

    TCoLEmblems_Frame:RegisterEvent("CHAT_MSG_LOOT")

    ???

    Absolutely.. that's what you mean to do, isn't it?  =)