It depends on what your overall goal is. If you think you need an event frame that your other addon files need to access, you can store a pointer to it in the addon table. I would suggest using more meaningful names than just
f. It will help when you decide to look at this code again later in the future.
This is what I suggest:
lua Code:
local name,addon=...;
addon.EventFrame=CreateFrame("Frame");
- and -
lua Code:
local name,addon=...;
addon.EventFrame:RegisterEvent("PLAYER_LOGIN");
addon.EventFrame:HookScript("OnEvent",function(self,event,...)
if event=="PLAYER_LOGIN" then
-- More stuff here
end
end);
The key points are using
Frame:HookScript() since this might not be your only file using the frame. As such, it would be wise to check if we're working on the event we want. Since you're sharing this frame with your other files, the frame will also run the script for events your other files register for.