Thread Tools Display Modes
07-07-10, 10:50 AM   #1
wellbeing
A Cliff Giant
Join Date: Oct 2009
Posts: 71
help with COMBATLOG_LOG_EVENT_UNFILTERED

I'm trying to have a message displayed when a specific combat event takes place. i'm only a few days into my LUA/XML experience and am unable to troubleshoot this with any efficiency on my own. I'm hoping its just some syntax somewhere or something else that is clear to a veteran.

here is my code:

skillz.toc:

## Interface: 30300
## Title: Skillz
## Version: 0.1
## Author: Wellbeing
## Notes: testing
range.xml
range.lua

-------------

range.xml:

<Frame name="range_Frame"> --this line shows up with red text in edit..?
<Scripts>
<OnLoad>
range_OnLoad();
</OnLoad>
<OnEvent>
range_OnEvent(self, event, ...);
</OnEvent>
</Scripts>
</Frame>

----------

range.lua:

function range_OnLoad()
this:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
end

function range_OnEvent(self, event, ...)
local timestamp, type, = select(1, ...)
if (event=="COMBAT_LOG_EVENT_UNFILTERED") then
if (type=="SPELL_AURA_APPLIED") then
local spellName = select(10)
if (spellName=="Hammer of Justice") then
DEFAULT_CHAT_FRAME:AddMessage("You just HOJed");
end
end
end
end


help a noob?
ps. i dont know if this is important or not, but i'm not including semicolons in my lua.. they arent necessary are they?

Last edited by wellbeing : 07-07-10 at 10:55 AM.
  Reply With Quote
07-07-10, 10:56 AM   #2
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
Well I see a lot of mistakes in there but that could be posting errors but lets see.

Your Code
Code:
skillz.toc:

## Interface: 30300
## Title: Skillz
## Version: 0.1
## Author: Wellbeing
## Notes: testing
range.xml
range.lua

range.lua:

function range_OnLoad()
  this:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
end

function range_OnEvent(self, event, ...)
  local timestamp, type, = select(1, ...)
  if (event=="COMBAT_LOG_EVENT_UNFILTERED") then
    if (type=="SPELL_AURA_APPLIED") then
      local spellName = select(10)
      if (spellName=="Hammer of Justice") then -- ==true for clarity only. Not needed.
        DEFAULT_CHAT_FRAME:AddMessage("You just HOJed");
      end
    end
  end
end
How I would do this:
Code:
skillz.toc:

## Interface: 30300
## Title: Skillz
## Version: 0.1
## Author: Wellbeing
## Notes: testing
range.lua
range.xml



range.lua:

function range_OnLoad()
this:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
end

function range_OnEvent(self, event, ...)
local timestamp, type = select(1, ...)
local isPlayerCast = ( arg3 == UnitGUID("player") );
if (event=="COMBAT_LOG_EVENT_UNFILTERED") then
if (type=="SPELL_AURA_APPLIED") then
local spellName = select(10,...)
if (spellName=="Hammer of Justice") then -- ==true for clarity only. Not needed.
if ( isPlayerCast ) then
DEFAULT_CHAT_FRAME:AddMessage("You just HOJed");
else
DEFAULT_CHAT_FRAME:AddMessage("Someone else just HOJed");
end
end
end
end
edit: And nope, no need to include semi-colons. In my case it is habit from other programming languages that do require them.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818

Last edited by Xrystal : 07-07-10 at 11:00 AM.
  Reply With Quote
07-07-10, 12:47 PM   #3
wellbeing
A Cliff Giant
Join Date: Oct 2009
Posts: 71
I copy and pasted the lua and TOC... still not working.

hmmm.

should i be identifying the spell by id?
  Reply With Quote
07-07-10, 12:59 PM   #4
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
It shouldn't make a difference but you could try that. I usually use the spellID where possible so as to not be language specific but for your purposes at the moment both should work.

okay, test out what is actually happening by adding the following to the top of your onevent function.

local combatEvent = arg2
local sourceID = arg3
local sourceName = arg4
local destID = arg6
local destName = arg7
local spellID = arg9
local spellName = arg10
local playerID = UnitGUID("player")

local isPlayerID = ( sourceID == playerID or destID == playerID );

if ( isPlayerID ) then
print(combatEvent,sourceName,destName,spellID,spellName)
end

Then while running the game cast the spell you are trying to test for and see what values get printed out. The extra tests are just to stop everyones combat info being displayed needlessly.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
07-07-10, 01:30 PM   #5
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
Ah, think I figured out what might be the problem. I don't generally use xml files in my addons so it took me a while to spot it. Try the following mini addon and you should find out that it does what you want.

The screenshot attached shows it in action and displays the message you wanted amongst my debug code.
Attached Thumbnails
Click image for larger version

Name:	WoWScrnShot_070710_202734.jpg
Views:	817
Size:	274.7 KB
ID:	4580  
Attached Files
File Type: zip XCombatLog.zip (1.1 KB, 745 views)
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
07-07-10, 02:09 PM   #6
Soulofsin_007
A Flamescale Wyrmkin
AddOn Author - Click to view addons
Join Date: Apr 2008
Posts: 125
This is what I used to get the combat log events working.

Code:
  if event == "COMBAT_LOG_EVENT_UNFILTERED" then
    if (type=="SPELL_AURA_APPLIED") then

      local spellId, spellName, spellSchool = select(9, ...)
  
      if (spellName=="Fear") then
        DEFAULT_CHAT_FRAME:AddMessage("You've been feared?!");
     end
end
I dunno if you got it figured out or not Xrystal, I figured I would post it and see if it helped out or not.
  Reply With Quote
07-07-10, 02:15 PM   #7
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
Yeah, I think the problem was the xml header not being set. I noticed Scott uses it for the minimal xml files he uses so did the same in my mini addon. The rest of the code is almost identical.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote
07-07-10, 03:12 PM   #8
wellbeing
A Cliff Giant
Join Date: Oct 2009
Posts: 71
Originally Posted by Xrystal View Post
Yeah, I think the problem was the xml header not being set. I noticed Scott uses it for the minimal xml files he uses so did the same in my mini addon. The rest of the code is almost identical.
Thank you SO much.

For us noobs out there.. what is the new line in the xml file for?
  Reply With Quote
07-07-10, 05:03 PM   #9
Xrystal
nUI Maintainer
 
Xrystal's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Feb 2006
Posts: 5,934
I believe that links to the frame templates that are used in addons and the game in general.

So, I suspect that the fact you didn't have that line meant it didn't know much about the frame you created.
__________________


Characters:
Gwynedda - 70 - Demon Warlock
Galaviel - 65 - Resto Druid
Gamaliel - 61 - Disc Priest
Gwynytha - 60 - Survival Hunter
Lienae - 60 - Resto Shaman
Plus several others below level 60

Info Panel IDs : http://www.wowinterface.com/forums/s...818#post136818
  Reply With Quote

WoWInterface » Developer Discussions » General Authoring Discussion » help with COMBATLOG_LOG_EVENT_UNFILTERED


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off