Thread Tools Display Modes
04/03/17, 12:47 PM   #1
BoarGules
 
BoarGules's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2017
Posts: 34
Total beginner question about d() used in tutorial

I'm following the tutorial at http://wiki.esoui.com/Writing_your_first_addon which tells me that calling d() will send debug traces to the chat window.

Except that it doesn't. I know the game is calling my little event handler, because if I put a deliberate runtime error in the code just before the call to d(), ESO displays a popup complaining about it. I thought that maybe the function had been hijacked by another addon, but uninstalling all the other addons didn't fix the problem.

Is there a magic word like a command-line parameter or something else I need to do to get the function to behave as advertised?
  Reply With Quote
04/03/17, 02:14 PM   #2
votan
 
votan's Avatar
AddOn Author - Click to view addons
Join Date: Oct 2014
Posts: 577
Originally Posted by BoarGules View Post
I'm following the tutorial at http://wiki.esoui.com/Writing_your_first_addon which tells me that calling d() will send debug traces to the chat window.

Except that it doesn't. I know the game is calling my little event handler, because if I put a deliberate runtime error in the code just before the call to d(), ESO displays a popup complaining about it. I thought that maybe the function had been hijacked by another addon, but uninstalling all the other addons didn't fix the problem.

Is there a magic word like a command-line parameter or something else I need to do to get the function to behave as advertised?
if someone's addon leaks a d, this will overwrite the function. Not good.
Disable all addons and type in the chat:
/script d("Hello")

When enable your addon and try again.
  Reply With Quote
04/03/17, 02:30 PM   #3
Rhyono
AddOn Author - Click to view addons
Join Date: Sep 2016
Posts: 659
It has never worked for me if I try to put it in an addon's initialization. There are many event related times when it doesn't seem to execute it, even when the code before and after does.
  Reply With Quote
04/03/17, 02:47 PM   #4
BoarGules
 
BoarGules's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2017
Posts: 34
Ah, that is helpful. So far, all of my calls to d() are in the main chunk, or in the EVENT_ADD_ON_LOADED event handler, or in something that it calls, because I was trying to check that the initialization was working. If I should not expect the function to work until the addon is initialized, then I will stop fretting and carry on with the tutorial.

Thank you.
  Reply With Quote
04/03/17, 03:31 PM   #5
Dolgubon
 
Dolgubon's Avatar
AddOn Author - Click to view addons
Join Date: Jan 2016
Posts: 409
I highly suggest downloading pChat and adding it as an optional depends on. It will print anjy d() called before chat initialization.
  Reply With Quote
04/04/17, 02:02 AM   #6
sirinsidiator
 
sirinsidiator's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 1,578
d() sends messages to the chat, but there is one catch: The chat does not exist before EVENT_PLAYER_ACTIVATED fires for the first time. All messages you send before EVENT_PLAYER_ACTIVATED are simply discarded. You either have to install pChat which has a feature to collect and print those messages or write your own log function that caches them until the chat is ready.

But why is the chat not active early on? That's another thing you should know: Saved variables are not available before EVENT_ADDON_LOADED (the chat uses them to remember its position and other stuff). I can only guess why they decided to initialize it in EVENT_PLAYER_ACTIVATED instead of EVENT_ADDON_LOADED. One possible reason is that the event didn't exist when they wrote the chat code.

Maybe some day ZOS will update the chat to cache messages even before the main window exists, but until then we have to manage it ourselves.
  Reply With Quote

ESOUI » Developer Discussions » General Authoring Discussion » Total beginner question about d() used in tutorial

Thread Tools
Display Modes

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