View Single Post
05-09-08, 10:32 PM   #7
frogofdoom
An Aku'mai Servant
AddOn Author - Click to view addons
Join Date: Oct 2005
Posts: 31
Basically, in a function that runs when a mod loads (e.g. the OnLoad for a frame), that's where you register events. The format for doing that is just to add this line into an OnLoad function:

if you're doing it in a specific frame's OnLoad:
Code:
this:RegisterEvent("EVENT_NAME");
otherwise,
Code:
framename:RegisterEvent("EVENT_NAME");
So what people are suggesting here, is to find another mod that has already registered the PLAYER_ENTERING_WORLD event, and then add your code into the event handler under PLAYER_ENTERING_WORLD. So essentially, what you'd be doing, is piggy-backing on another mod's already registered events and sticking your code into its event handler.

Now, if I were to create your code as a standalone mod, I would do it like this:

Assume that I've created a frame named Frame. I would set this function to its OnLoad
Code:
function Frame_OnLoad()
 this:RegisterEvent("PLAYER_ENTERING_WORLD");
end
... And I would set this function to its OnEvent
Code:
function Frame_OnEvent(event)
 if (event == "PLAYER_ENTERING_WORLD") then
  MainMenuBarLeftEndCap:Hide()
  MainMenuBarRightEndCap:Hide()
 end
end
The simplest way to do this, as people have said, is just to insert this code into another mod that's already been created. Using that method, all you have to do to make this code load when the game loads, is to go into any mod's lua code, check to see if it has registered the PLAYER_ENTERING_WORLD event, and then insert your code into the event handler under the PLAYER_ENTERING_WORLD conditional.

Anyway, hope that helps you understand a bit better.

Last edited by frogofdoom : 05-09-08 at 10:37 PM.
  Reply With Quote