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:
FooAddon = {}
FooAddon.name = "FooAddon"
-------------------------------------
-- Initialize the addon.
-------------------------------------
function FooAddon.OnAddOnLoaded(event, addonName)
if addonName == FooAddon.name then
FooAddon:Initialize()
end
end
-------------------------------------
-- Load saved variables and register the event listeners.
-------------------------------------
function FooAddon:Initialize()
FooAddon.inCombat = IsUnitInCombat("player")
EVENT_MANAGER:RegisterForEvent(FooAddon.name, EVENT_PLAYER_COMBAT_STATE, FooAddon.OnPlayerCombatState)
end
function FooAddon.OnPlayerCombatState(_, inCombat)
-- The ~= operator is "not equal to" in Lua.
d("In event!")
if inCombat ~= FooAddon.inCombat then
FooAddon.inCombat = inCombat
if inCombat then
d("Entering combat.")
else
d("Exiting combat.")
end
end
end
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.