View Single Post
05/01/14, 09:57 AM   #5
Garkin
 
Garkin's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 832
Originally Posted by Feroc View Post
...
Code:
function TestOne.Initialize(eventCode, addOnName)
	if (addOnName ~= "TestOne") then 
		return 
	end
	d("TestOne Loaded...")
end

EVENT_MANAGER:RegisterForEvent("TestOne", EVENT_ADD_ON_LOADED, TestOne.Initialize);
That already throws an error:


If I change TestOne.Initialize to TestOneInitialize I don't get the error anymore... but I don't get a "TestOne Loaded" in the chat either. It just does nothing.

What am I doing wrong?
You are trying to add something to table TestOne that does not exists. If you create that table first, it will work.
Lua Code:
  1. TestOne = {}
  2.  
  3. function TestOne.Initialize(eventCode, addOnName)
  4.     if (addOnName ~= "TestOne") then
  5.         return
  6.     end
  7.     d("TestOne Loaded...")
  8. end
  9.  
  10. EVENT_MANAGER:RegisterForEvent("TestOne", EVENT_ADD_ON_LOADED, TestOne.Initialize)
  Reply With Quote