View Single Post
12-29-05, 10:56 AM   #3
sacha
An Aku'mai Servant
 
sacha's Avatar
AddOn Author - Click to view addons
Join Date: Jun 2005
Posts: 38
An ugly and hackish way of getting around the XML dependancy for events would be to hook an existing function that is already called via events, eg. hooking Minimap_OnEvent() etc. However I would still recommend using your own XML for event driven functions.

IF all you want is to get a function to be called as an OnLoad tag would, try putting the lua filename in your toc as follows:

Code:
## Interface: 1900
## Title: MyAddonTitle
## Author: MyName
MyAddonLuaFile.lua
Then, in your 'MyAddonLuaFile.lua' file:
Code:
MyAddonTitle_IsActive = nil;

function MyAddonTitle_OnLoad()

   -- Init code
   MyAddonTitle_IsActive = 1;

   -- You can also create hooks as decribed 
   -- above instead of registering for events 
   -- There are several ways of doing this  
   MyAddonTitle_Original_Minimap_OnEvent = Minimap_OnEvent;
   function Minimap_OnEvent()
      
      -- My addon's event driven code

      -- Call the hooked function
      MyAddonTitle_Original_Minimap_OnEvent();
   end

end

-- Now to call the 'MyAddonTitle_OnLoad()' function
MyAddonTitle_OnLoad();

Last edited by sacha : 12-29-05 at 06:37 PM.
  Reply With Quote