View Single Post
03/01/14, 03:33 PM   #1
Son of a Sailor
Join Date: Feb 2014
Posts: 7
Help with addon and accessing code feedback

Using what I can find in the wiki, I'm trying to create an addon that puts a message in the chatbox every time a character gains XP. I'm not proficient with Lua or XML but I've programmed for four years now and can muddle my through the wiki. I think I have a proper(though crude) addon, but it doesn't work at all. I looked at some code for other addons and I think I'm doing it right but the lack of tutorials and documentation make it hard to me to find out what I'm doing wrong on my own.

I'd also like to know if there's a way to get console output for addons or access to a debugger. If I could have error returned or be able to view my addon as it runs it would be very helpful

Lua Code:
  1. local function OnXPGain(eventCode, gain, reason)
  2.     --print xp to chat
  3.     d( "XP Gained: " .. gain )
  4. end
  5.  
  6. function OnLoad()
  7.     EVENT_MANAGER:RegisterForEvent(EVENT_EXPERIENCE_GAIN, OnXPGain)
  8.     d( "loaded" )
  9. end

Code:
<GuiXml>
    <Controls>
        <TopLevelControl name="XPTracker">
            -<OnInitialized>
				OnLoad()
			</OnInitialized>
        </TopLevelControl>
    </Controls>
</GuiXml>
  Reply With Quote