Code:
local addon = CreateFrame("Frame", "MyAddon")
addon:RegisterEvent("ADDON_LOADED")
addon:SetScript("OnEvent", function(self, event, arg1)
if event == "ADDON_LOADED" and arg1 == "MyAddon" then
-- Call the function to update your saved table:
MyAddonSavedVariables = CopyDefaults(MyDefaults, MyAddonSavedVariables)
print(MyAddonSavedVariables)
-- Unregister this event, since there is no further use for it:
self:UnregisterEvent("ADDON_LOADED")
end
end)
This code print the valor (?) of MyAddonSavedVariables. But if I write the print function outside this, the code doesn't work
Code:
local addon = CreateFrame("Frame", "MyAddon")
addon:RegisterEvent("ADDON_LOADED")
addon:SetScript("OnEvent", function(self, event, arg1)
if event == "ADDON_LOADED" and arg1 == "MyAddon" then
-- Call the function to update your saved table:
MyAddonSavedVariables = CopyDefaults(MyDefaults, MyAddonSavedVariables)
-- Unregister this event, since there is no further use for it:
self:UnregisterEvent("ADDON_LOADED")
end
end)
print(MyAddonSavedVariables)