Addons all run thorught EVENT_ADD_ON_LOADED in a load order which is defined by the dependencies.
If Dark UI runs the same redirect at it's own EVENT_ADD_ON_LOADED callback it might revert yours which have been done before!
So add DarkUi to your ## OptionalDepends: list in your manifest txt so it will load before your addon and then EVENT_ADD_ON_LOADED of your addon should fire after the one of DarkUi.
For vanilla UI: It should always be called before addons so I don't know why it's not updatig the texture from your addon then properly.
Maybe the compass got a function that calls the texture update after event_add_on_loaded.
Try to use event_player_activated in your case instead of event_add_on_loaded (but only let it do that once! as it will call the same event on every zone change with loading screens too).
Btw: Unregister your EVENT_ADD_ON_LOADED after your addon code was run! Else your callback function will be called for every other addon again and again allthough it does not need to do anything anymore...
And please define functions not global! Add local inf ront else they pollute the global namespace in table _G and will overwrite other addons/vanilla variables and code!
OR define the global functions with a unique name, not SlimCompass or similar.
IF you need themt o be global add 1 global table with your addonName and then add functions to it.
SlimCompass = {}
function SlimCompass.ChangeCompass()
end
In your case a local function SlimCompass() should be enough, same for OnAddOnLoaded!!!
See best practices etc here:
https://www.esoui.com/forums/showthread.php?t=9867
Example code with EVENT_PLAYER_ACTIVATED (fires after EVENT_ADD_ON_LOADED, as player is ready in the ingame wordla dn chat is ready):
Lua Code:
local addOn = {
name = "SlimCompass",
version = "1"
}
local addonName = addOn.name
local compassTextureOrig = "esoui/art/compass/compass.dds"
local compassTextureMine = "slimcompass/textures/sc_compass.dds"
local function SlimCompass()
RedirectTexture(compassTextureOrig, compassTextureMine)
end
local function OnPlayerActivated(eventCode, wasFirst)
--Only call this event callback once
EVENT_MANAGER:UnregisterForEvent(addonName, eventCode) --will unregister EVENT_PLAYER_ACTIVATED again so it's only executed once
SlimCompass() --Change compass again
end
local function OnAddOnLoaded(eventCode, addOnName)
if addOnName ~= addonName then return end
EVENT_MANAGER:RegisterForEvent(addonName, EVENT_PLAYER_ACTIVATED, OnPlayerActivated)
SlimCompass() --Change compass now, maybe you can remove this here if EVENT_PLAYER_ACTIVATED works alone
EVENT_MANAGER:UnregisterForEvent(addonName, EVENT_ADD_ON_LOADED)
end
EVENT_MANAGER:RegisterForEvent(addonName, EVENT_ADD_ON_LOADED, OnAddOnLoaded)