Thread Tools Display Modes
08-12-10, 09:34 AM   #1
SignOfDoom
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jul 2010
Posts: 18
Question my addon does nothing

hi
at first i have to say that this is the first addon i create do dnt expect to much.

i have this code
Code:
frame = CreateFrame("Frame")
frame:RegisterEvent("CHAT_MSG_LOOT")

function frame:OnEvent(event, ...)
	if event == "CHAT_MSG_LOOT" then
		print("juhu")
	end
end

frame:SetScript("OnEvent", frame.OnEvent)
in my addon but ingame nothing happens. can anybody say me what i am doing wrong?
  Reply With Quote
08-12-10, 09:49 AM   #2
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
Code looks correct to me. Could you please post your .toc-file?
__________________
« Website | GitHub »

Oh hai!
  Reply With Quote
08-12-10, 09:54 AM   #3
yj589794
A Rage Talon Dragon Guard
AddOn Author - Click to view addons
Join Date: Mar 2009
Posts: 314
you should make frame local
Code:
local frame = CreateFrame("Frame")
It won't make your addon run, but it will stop you injecting a commonly named item into the global namespace.
  Reply With Quote
08-12-10, 10:39 AM   #4
cloudwolf
A Black Drake
AddOn Author - Click to view addons
Join Date: Mar 2008
Posts: 87
frame:Onevent is different than frame.onevent. your not calling your function. Also please use less generic names. Also PLEASE localize your variables. By having a global like that floating in name space you could break more than just your own addon.
  Reply With Quote
08-12-10, 11:31 AM   #5
SignOfDoom
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jul 2010
Posts: 18
i changed my code to that:
Code:
local tracker = CreateFrame("Frame")
tracker:RegisterEvent("CHAT_MSG_LOOT")

local function Looten(event, ...)
	if event == "CHAT_MSG_LOOT" then
		print("it works")
	end
end

tracker:SetScript("OnEvent", Looten)
but still nothing happens
  Reply With Quote
08-12-10, 11:36 AM   #6
dr_AllCOM3
A Cyclonian
 
dr_AllCOM3's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2006
Posts: 40
Try ChatFrame1:AddMessage() instead of print().
  Reply With Quote
08-12-10, 11:37 AM   #7
xConStruct
A Chromatic Dragonspawn
 
xConStruct's Avatar
AddOn Author - Click to view addons
Join Date: May 2008
Posts: 199
print() should do fine normally.

But this time you need to explicitly add "self" to the function, because you removed the "frame:" (which acts as 'self').

Code:
local tracker = CreateFrame("Frame")
tracker:RegisterEvent("CHAT_MSG_LOOT")

local function Looten(self, event, ...)
	if event == "CHAT_MSG_LOOT" then
		print("it works")
	end
end

tracker:SetScript("OnEvent", Looten)
Still, if it doesn't work, please post your .toc-file! Or add a print("test") to the top of your file to see if it gets loaded at all.
__________________
« Website | GitHub »

Oh hai!
  Reply With Quote
08-12-10, 11:44 AM   #8
SignOfDoom
A Deviate Faerie Dragon
AddOn Author - Click to view addons
Join Date: Jul 2010
Posts: 18
im so stupid -.-
it works now. it was the toc file ^^
thank you very much
  Reply With Quote

WoWInterface » Developer Discussions » Lua/XML Help » my addon does nothing


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