Quantcast
Can't figure out why d() isn't working from tutorial code - ESOUI
Thread Tools Display Modes
05/11/20, 09:46 AM   #1
QuantumPie
AddOn Author - Click to view addons
Join Date: Sep 2019
Posts: 23
Can't figure out why d() isn't working from tutorial code

Hey! I'm trying to get started with developing my own addon and when I tried to use d() to print output I wasn't getting anything. After doing some digging I realized it won't print in initialized so I moved it to an event with no luck. I then directly copied the tutorial "Writing your first add-on" which also wouldn't print anything to the chat window. The addon is enabled and the description / author matches the manifest file. My file structure is

- DamageType/
- DamageType.lua
- DamageType.txt

My manifest file contains:
Code:
## Title: Damage Type Tracker
## Author: QuantumPie
## AddOnVersion: 001
## Version: 0.0.1
## APIVersion: 100030
## Description: Tracks the damage type of incoming damage so your CP can be optomized

DamageType.lua
And the lua file contains:

Lua Code:
  1. FooAddon = {}
  2.  
  3. FooAddon.name = "FooAddon"
  4.  
  5.  
  6. -------------------------------------
  7. -- Initialize the addon.
  8. -------------------------------------
  9. function FooAddon.OnAddOnLoaded(event, addonName)
  10.     if addonName == FooAddon.name then
  11.         FooAddon:Initialize()
  12.     end
  13. end
  14.  
  15. -------------------------------------
  16. -- Load saved variables and register the event listeners.
  17. -------------------------------------
  18. function FooAddon:Initialize()
  19.     FooAddon.inCombat = IsUnitInCombat("player")
  20.     EVENT_MANAGER:RegisterForEvent(FooAddon.name, EVENT_PLAYER_COMBAT_STATE, FooAddon.OnPlayerCombatState)
  21. end
  22.  
  23. function FooAddon.OnPlayerCombatState(_, inCombat)
  24.     -- The ~= operator is "not equal to" in Lua.
  25.     d("In event!")
  26.     if inCombat ~= FooAddon.inCombat then
  27.         FooAddon.inCombat = inCombat
  28.    
  29.         if inCombat then
  30.             d("Entering combat.")
  31.         else
  32.             d("Exiting combat.")
  33.         end
  34.    
  35.     end
  36. end
  37.  
  38. EVENT_MANAGER:RegisterForEvent(FooAddon.name, EVENT_ADD_ON_LOADED, FooAddon.OnAddOnLoaded)

Which is a slightly modified version of the tutorial as I was troubleshooting. Is there a typo somewhere I am missing? I'd think that wouldn't be the case since it still didn't work when I had a direct copy of the code from the above tutorial.
  Reply With Quote
05/11/20, 10:02 AM   #2
Baertram
 
Baertram's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 3,092
Just a guess:

Are you testing with ONLY your addon active? If not: Do so please!
Other addons could intercept the messages of the chat.
e.g. LibDebugLogger -> Will show the d messages in the DebugLogViewer addon (if you got that one installed).

After reviewing your code:
EVENT_ADD_ON_LOADED is fired BEFORE the chat is ready!
So you need to use EVENT_PLAYER_ACTIVATED to see the chat messages.
Or an addon like pChat which enables to read these messages in the system chat channel as well.

OR you use the library mentioned above.
LibDebugLogger + the addon DebugLogViewer.

Once enabled go to the settings of DebugLogViewer and enable the Stack traceback setting and output of the messages you send via d() before the chat is ready, as well as a list of the loaded addons and their order, should be shown in the quick log and the debug log viewer UI.

Last edited by Baertram : 05/11/20 at 10:04 AM.
  Reply With Quote
05/11/20, 10:17 AM   #3
Scootworks
 
Scootworks's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2014
Posts: 290
your folder/file name is different like your addon name. that’s why it doesn’t work
__________________
EU Server - SŁĄuGhTerHØuSe
  Reply With Quote
05/11/20, 10:19 AM   #4
QuantumPie
AddOn Author - Click to view addons
Join Date: Sep 2019
Posts: 23
I certinanly had those installed. I enabled stack traces and set the log level to debug but I don't see any of my d() outputs in either the chat panel or the log window
  Reply With Quote
05/11/20, 10:20 AM   #5
QuantumPie
AddOn Author - Click to view addons
Join Date: Sep 2019
Posts: 23
Originally Posted by Scootworks View Post
your folder/file name is different like your addon name. that’s why it doesn’t work
They look the same to me

EDIT:
Scratch that out. I see what you mean. That fixed it! Thanks.
  Reply With Quote
05/11/20, 11:47 AM   #6
Scootworks
 
Scootworks's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2014
Posts: 290
Originally Posted by QuantumPie View Post
They look the same to me

EDIT:
Scratch that out. I see what you mean. That fixed it! Thanks.
good :-)
don’t forget to read this page: https://wiki.esoui.com/Addon_manifest_(.txt)_format
__________________
EU Server - SŁĄuGhTerHØuSe
  Reply With Quote
05/11/20, 11:54 AM   #7
Baertram
 
Baertram's Avatar
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 3,092
Just as a hint for the others:
FooAddon.name = "FooAddon" will not work in EVENT_ADD_ON_LOADED checks if your folder and txt filename will be different than FooAddon (e.g. DamageType)
  Reply With Quote

ESOUI » Developer Discussions » Lua/XML Help » Can't figure out why d() isn't working from tutorial code

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