Originally Posted by Mayron
if ShadowUF.db:GetCurrentProfile() == "MayronUI" then
BTL:Show()
TL:Hide()
else
TL:Show()
BTL:Hide()
end
end)
[/code]
But unfortunately the:
"BTL:Show()
TL:Hide()"
part never reaches as both of the frames are showing for some reason. I had to also change "ShadowedUnitFrames" to "ShadowUF" because for some reason it came up with a lua error saying that "db" is a nil value but with that instead I do not get any errors. Not sure what that's about. I will keep up the experimenting.
|
Hey
Are BTL and TL variables which point to the frames somewhere else in your script? I'm just asking because if you've posted your full script, there's no way that your code is going to know what BTL and TL is.
I'd also consider registering to the "PLAYER_LOGIN" event too, just in-case your addon loads after ShadowedUF. If it does load after ShadowedUF, "ADDON_LOADED" will not catch the event (because it fired before your addon existed).
Lua Code:
local shadowLoaded = false;
f:RegisterEvent("ADDON_LOADED");
f:RegisterEvent("PLAYER_LOGIN");
f:SetScript("OnEvent", function(self, event, addon)
if ( ( event == "ADDON_LOADED" ) and ( addon == "ShadowUF" ) ) then
shadowLoaded = true;
elseif ( ( event == "PLAYER_LOGIN" ) and IsAddOnLoaded("ShadowUF") ) then
shadowLoaded = true;
end
if ( not shadowLoaded ) then return; end
print("ShadowUF has been loaded"); -- temporary to use as a debug tool to ensure that you're code is getting this far.
self:UnregisterEvent("ADDON_LOADED");
self:UnregisterEvent("PLAYER_LOGIN");
if ShadowUF.db:GetCurrentProfile() == "MayronUI" then
BTL:Show();
TL:Hide();
else
TL:Show();
BTL:Hide();
end
end)
Right enough, an easier way would be to simply add ShadowUF as a dependency in your TOC file if your code is pointless without ShadowUF (or an optional dependency if you'd still like your code to run even if ShadowUF has been disabled). The game will then try to ensure that ShadowUF is loaded prior to your addon which will remove some of the guesswork.
Using print() like the example above is a pretty handy way of working out where you're going wrong although I suspect that in the above example, if ShadowUF is loaded early on in the addon loading process, it might not print to chat even if your func does reach that line of code... but it's worth trying.
Aanson