Thread Tools Display Modes
Prev Previous Post   Next Post Next
07/17/14, 03:00 PM   #1
FadedJeans
 
FadedJeans's Avatar
Join Date: Apr 2014
Posts: 6
Hello World

I tried following the directions here:

http://wiki.esoui.com/Writing_your_first_addon

...just up to the point where I expect to see messages in the chat tab, but I don't. i don't get any errors, I see the "add on" listed, and it is checked off to be used, but it doesn't seem to do anything at all.

What's the best way to troubleshoot this little "Hello World" project? I don't see any logs produced. Are there dev tools to see what is going on?

Thanks! Looking forward to getting up to speed and joining the community. I've never written Lua before, but I've been writing ColdFusion applications for over a decade. Not the same thing, I know, but hopefully I can make the jump

I love the game and plan on staying for a long time.

Lua Code:
  1. -- First, we create a namespace for our addon by declaring a top-level table that will hold everything else.
  2. FooAddon = {}
  3.  
  4. -- This isn't strictly necessary, but we'll use this string later when registering events.
  5. -- Better to define it in a single place rather than retyping the same string.
  6. FooAddon.name = "FooAddon"
  7.  
  8. -- Next we create a function that will initialize our addon
  9. function FooAddon:Initialize()
  10.   self.inCombat = IsUnitInCombat("player")
  11.  
  12.   EVENT_MANAGER:RegisterForEvent(self.name, EVENT_PLAYER_COMBAT_STATE, self.OnPlayerCombatState)
  13. end
  14.  
  15. -- Then we create an event handler function which will be called when the "addon loaded" event
  16. -- occurs. We'll use this to initialize our addon after all of its resources are fully loaded.
  17. function FooAddon.OnAddOnLoaded(event, addonName)
  18.   -- The event fires each time *any* addon loads - but we only care about when our own addon loads.
  19.   if addonName == FooAddon.name then
  20.     FooAddon:Initialize()
  21.   end
  22. end
  23.  
  24. function FooAddon.OnPlayerCombatState(event, inCombat)
  25.   -- The ~= operator is "not equal to" in Lua.
  26.   if inCombat ~= FooAddon.inCombat then
  27.     -- The player's state has changed. Update the stored state...
  28.     FooAddon.inCombat = inCombat
  29.  
  30.     -- ...and then announce the change.
  31.     if inCombat then
  32.       d("Entering combat.")
  33.     else
  34.       d("Exiting combat.")
  35.     end
  36.  
  37.   end
  38. end
  39.  
  40. -- Finally, we'll register our event handler function to be called when the proper event occurs.
  41. EVENT_MANAGER:RegisterForEvent(FooAddon.name, EVENT_ADD_ON_LOADED, FooAddon.OnAddOnLoaded)

EDITED: I went ahead and added the syntax highlight, thanks for the advice! ; I feel extra lost I suppose, I don't see any syntax tools, just smilies.

Last edited by FadedJeans : 07/17/14 at 03:34 PM.
  Reply With Quote
 

ESOUI » Developer Discussions » Lua/XML Help » Hello World


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off