Thread Tools Display Modes
02-15-09, 08:19 PM   #1
Cowberty
A Murloc Raider
Join Date: Oct 2008
Posts: 8
What am I doing wrong?

Okay. so I'm extremely new when i comes to writing addons. I've spent a lot of time reading up on wow api, but for the life of me i can't figure out what im doing wrong here. Can someone take a look at my code and tell me if i'm doing something wrong with my formatting?

TauntTell.xml
Code:
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/ C:\Projects\WoW\Bin\Interface\FrameXML\UI.xsd">

<Script file="TauntTell.lua"/>

<Frame name="TauntTell_Frame">
	<Scripts>
		<!-- event handler -->
		<OnLoad>TauntTell_OnLoad();</OnLoad>
		<OnEvent>TauntTell_OnEvent(self, event, ...);</OnEvent>
	</Scripts>

</Frame></Ui>

TauntTell.lua
Code:
function TauntTell_OnLoad()
	this:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED");
	DEFAULT_CHAT_FRAME:AddMessage("|cffffff00 TauntTell Loaded");
end

function TauntTell_OnEvent(self, event, ...)

	local timestamp, type, sourceGUID, sourceName, sourceFlags, destGUID, destName, destFlags = select(1, ...)

	if (event == "COMBAT_LOG_EVENT_UNFILTERED")
		local spellId, spellName, spellSchool = select(9, ...)
		if (type == "SPELL_CAST_SUCCESS") and ((spellId == 6795) or (spellId == 5209) or (spellId == 355) or (spellId == 1161) or (spellId == 694) or (spellId == 31789) or (spellId == 62124) or (spellId == 56222)) then
			if (destName) then
		  DEFAULT_CHAT_FRAME:AddMessage(sourceName.." taunted "..destName);
			else
		  DEFAULT_CHAT_FRAME:AddMessage(spellName.." used by ".. sourceName);
			end
		end
	end
end

Thanks in advance for the help.
  Reply With Quote
02-16-09, 11:35 AM   #2
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
You should do it this way, for one:

Code:
<OnLoad>TauntTell_OnLoad(self)</OnLoad>
Code:
function TauntTell_OnLoad(self)
	self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
although the way you have it now should still work. I looked over your code quickly and didn't see an obvious problem. Are you getting any errors in-game? What does your .toc file look like?
  Reply With Quote
02-16-09, 02:56 PM   #3
Sythalin
Curse staff
 
Sythalin's Avatar
AddOn Author - Click to view addons
Join Date: Aug 2006
Posts: 680
Originally Posted by Akryn View Post
Code:
	self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
although the way you have it now should still work.
Although the change is correct, the latter is not. "this" was removed with 3.0, if I recall correctly, and is no longer recognized
  Reply With Quote
02-16-09, 03:01 PM   #4
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
Originally Posted by ChaosInc View Post
Although the change is correct, the latter is not. "this" was removed with 3.0, if I recall correctly, and is no longer recognized
It's deprecated and has been for some time. In 3.0, Blizzard's UI was updated so that it no longer uses it, meaning that addons no longer *have* to use it to make use of some of the Blizzard built-in object templates and such. But AFAIK, all the old globals still exist and should technically be usable.
  Reply With Quote
02-16-09, 04:12 PM   #5
Cowberty
A Murloc Raider
Join Date: Oct 2008
Posts: 8
Okay, so sorry if i wasn't entirely clear initially. First off, here's my toc file.

Code:
## Interface: 30000
## Title: TauntTell
## Notes: Displays who taunted off you in the default chat frame.
## Author: Tankadyn
## Version: 1.0
## SavedVariablesPerCharacter: TauntTell
TauntTell.xml
As for error messages in-game, I get none. Actually, if i take out the second function, "TauntTell Loaded" shows up in the chat frame as expected. However, when i stick in the second function the "TauntTell Loaded" message goes away and nothing works. (this is why i think there's got to be some kind of formatting issue). As for what this is actually supposed to do, it should see when a taunt lands and print out in chat who taunted what.

Thanks for the feedback.
  Reply With Quote
02-16-09, 04:36 PM   #6
Akryn
A Firelord
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 479
Ugh...

if (event == "COMBAT_LOG_EVENT_UNFILTERED")
"then" expected near ')'

If you're not getting an error there, you need to turn Lua errors on in the interface options, and personally I suggest installing a better error handler such as http://www.wowinterface.com/download...5-BugSack.html
  Reply With Quote
02-16-09, 05:11 PM   #7
Cowberty
A Murloc Raider
Join Date: Oct 2008
Posts: 8
Ahah! yes! that was the problem. Thanks much sir. (tbh i completely forgot to turn lua errors back on when i was debugging )
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » What am I doing wrong?


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