ESOUI

ESOUI (https://www.esoui.com/forums/index.php)
-   AddOn Search/Requests (https://www.esoui.com/forums/forumdisplay.php?f=165)
-   -   Debugging with d() not working? (https://www.esoui.com/forums/showthread.php?t=6991)

Rugnir_viking 04/21/17 06:08 PM

Debugging with d() not working?
 
I seem to have a huge problem with following some of the basic addon tutorials.

Originally i thought the code was being complied but not run at all (errors fired when I made syntax error but no output whatsoever)

But it turns out that when I forged ahead anyway, xml and all that jazz works fine. It just seems that no kind of d() debug output actually appears in my chat :mad:

Its been annoying me for ages now.

Any solutions?

Rhyono 04/21/17 06:12 PM

Does this cover it?

Rugnir_viking 04/21/17 06:22 PM

Unfortunately it does not seem to cover it :(
After a bit more experimentation, I believe its not entirely to do with d() and perhaps my lack of understanding, but here is my code

I'm expecting when I enter/exit combat for stuff to appear in chat

here is my attempt at code

Lua Code:
  1. function Initialise()
  2.     EVENT_MANAGER:RegisterForEvent("TestAddon1", EVENT_PLAYER_COMBAT_STATE, combatStatusChanges)
  3. end
  4.  
  5. function combatStatusChanges()
  6.     -- literally anything sould cause it to debug output
  7.     d("help me")
  8. end
  9.  
  10. function addOnInit(event, addonName)
  11.   if addonName == "TestAddon1" then
  12.     Initialise()
  13.   end
  14. end
  15.  
  16.  
  17. EVENT_MANAGER:RegisterForEvent("TestAddon1", EVENT_ADD_ON_LOADED, addOnInit)

ArctixFox 04/21/17 07:17 PM

maybe try

Lua Code:
  1. function combatStatusChanges(eventCode, inCombat)

so the signature of the function matches what the caller expects. I haven't tried it, but... :D

Baertram 04/21/17 07:18 PM

You should think about using local variables and function names, or put the functions and variables in a table that is only used in your addon.
Otherwise you could overwrite a variable/function of another addon that got the same name :(

If you use local functions the order of the functions and variables must be correct! lua is interpreting the function/variable names from top to bottom so you need to put functions that are local and will be called BEFORE (more to the top) the place where you call it.

Lua Code:
  1. local function combatStatusChanges(eventCode, inCombat)
  2.     -- literally anything sould cause it to debug output
  3.     d("In combat: " .. tostring(inCombat))
  4. end
  5.  
  6. local function Initialise()
  7.     EVENT_MANAGER:RegisterForEvent("TestAddon1", EVENT_PLAYER_COMBAT_STATE, combatStatusChanges)
  8. end
  9.  
  10.  
  11. local function addOnInit(event, addonName)
  12.   if addonName == "TestAddon1" then
  13.     Initialise()
  14.   end
  15. end
  16.  
  17.  
  18. EVENT_MANAGER:RegisterForEvent("TestAddon1", EVENT_ADD_ON_LOADED, addOnInit)

This code should bring you your message "help me" to the chat.
Be sure to check if the chat tabs you are using got the "system" messages activated in the tab options!
right click the tab and choose options, then have a look at the middle-right and mark the checkbox for system and say close.

Rugnir_viking 04/22/17 05:37 AM

Thanks for all you guys help.

There is no system checkbox in any chat tab options. This is a completely vanilla install.

I did however find the solution. I was mixing names in the addon, so I tried something that didn't have spaces so the folder and stuff would all be the same and that worked.

For future reference, not specifying the arguments to the event function does work.

Baertram 04/23/17 08:28 AM

The system chat tab options checkbox is there in the total vanilla interface of the game, running no addons.
Right click the chat tab, choose options and check the possibilities to enable/disbale specific "chat channels" for the given chat's tab.

Ayantir 04/23/17 09:11 AM

No, it's pChat ^^

Rhyono 04/23/17 09:45 AM

By default, the system option is only in the first tab.

Baertram 04/23/17 01:22 PM

Oh, ok. Thanks Rhyono & Ayantir.
Only had checked the first tab


All times are GMT -6. The time now is 08:27 AM.

vBulletin © 2024, Jelsoft Enterprises Ltd
© 2014 - 2022 MMOUI