[:1]Hi, I'm a total noob at lua and WoW addons, but a rather experienced programmer overall. I'm trying to create a simple addon that needs to listen to a few events and react to them. The problem I'm having is that my event-handler never gets called. It's probably something very simple I've overlooked. Here's the complete code:
TOC:
## Interface: 30000
## Title: MyAddon
## Notes: It rawks
## Dependencies:
MyAddon.lua
MyAddon.xml
XML:
<Ui xmlns="http://www.blizzard.com/wow/ui/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.blizzard.com/wow/ui/
..\..\FrameXML\UI.xsd">
<Frame name="MyFrame">
<Scripts>
<OnLoad>
MyAddon_OnLoad();
</OnLoad>
<OnEvent>
MyAddon_OnEvent(self, event, ...);
</OnEvent>
<OnUpdate>
MyAddon_OnUpdate(self, elapsed);
</OnUpdate>
</Scripts>
</Frame>
</Ui>
LUA:
function MyAddon_OnLoad(self)
message("Loaded!");
self:RegisterEvent("PLAYER_ENTERING_WORLD");
self:RegisterEvent("PLAYER_REGEN_DISABLED");
self:RegisterEvent("PLAYER_REGEN_ENABLED");
end
function MyAddon_OnEvent(self, event, ...)
message("Got event!");
end
function MyAddon_OnUpdate(self, elapsed)
end
I see the "Loaded!" message, but i never get any events triggering the "Got event!" message() call. Help please.|||First, you forgot to pass the 'self' parameter to the _OnLoad function. (Else, you should've got an error on that.)
Secondly, use:
DEFAULT_CHAT_FRAME:AddMessage("Got event!")
...instead of message() for your debugging.
Not sure why, but I'd hazzard a guess that message dialogs wouldn't like events being fired at them - being reliant on human input 'an all (modal).|||I think you should try including the script file as the 2nd thing you do in your .xml.
I'd also reverse the order of your files in the .toc
No comments:
Post a Comment