View Single Post
11-26-14, 02:33 AM   #2
myrroddin
A Pyroguard Emberseer
 
myrroddin's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2008
Posts: 1,240
I did the following:
  • Got rid of the ugly and useless semicolons
  • Cleaned up the code
  • Commented where necessary
Lua Code:
  1. local killTracker = CreateFrame( "Frame" ) -- stop global leaking
  2. killTracker:RegisterEvent( "COMBAT_LOG_EVENT_UNFILTERED" )
  3.  
  4. killTracker:SetScript("OnEvent", function(_, _, _, event, _, sourceGUID, sourceName, _, _, destGUID, destName,  destFlags)
  5.     if ( event == "PARTY_KILL" )  then
  6.         local string = sourceName.." killed "..destName
  7.         UpdateKills( string ) -- is UpdateKills a local function? it had better be!
  8.         if (sourceGUID == player) then
  9.             local _, instanceType = IsInInstance()
  10.             if ( instanceType == "pvp" ) or ( instanceType == "arena" ) then
  11.                 message:AddMessage( "Killing Blow!", 1, 1, 0, 53, 3 ) -- is message a local reference? what is it, where is it?
  12.             end
  13.         end
  14.     end
  15. end
This might still be buggy, and I'm not about to test it in game, but it should be better. PARTY_KILL was running twice because you had two things responding to it, in two different parts of your code. I moved it to one chunk.

Also, you currently don't do anything with being in an instance other than what the instance type is, so that got slimmed down.

I have no idea what references UpdateKills and message you have; since both are generic names, and looking over your existing code, I'm going to assume you have leaking global references. Further, there is no function reference in your posted to code to message other than what we see, therefore the numbers after the string are meaningless and won't do anything.

But it is a start.

Last edited by myrroddin : 11-26-14 at 07:59 PM. Reason: switch from code tags to Lua tags
  Reply With Quote