To save information between sessions you need to add a setting you your .toc file
for use by ALL characters (or set up a character specific mechanism here):
Code:
## SavedVariables: xxx
Information saved only usable by the current character:
Code:
## SavedVariablesPerCharacter: xxx
If your .toc had
Code:
## SavedVariablesPerCharacter: DarkruneDOTDK_DATA
To save/set the font size you could do something like:
Lua Code:
local function SetFontSize()
local fontFile, _, fontFlags = ChatFrame1:GetFont();
ChatFrame1:SetFont(fontFile, DarkruneDOTDK_DATA.fontSize, fontFlags);
end
local f = CreateFrame("Frame") -- a frame to handle events
f:SetScript("OnEvent", function(self, event, ...) -- Event handler
DarkruneDOTDK_DATA = DarkruneDOTDK_DATA or { -- check if your SavedVariables table exists
fontSize = 12, -- If not, create it and set some defaults
someOtherThing = 99,
}
SetFontSize() -- Then automatically set the saved font size each login
end)
f:RegisterEvent("PLAYER_LOGIN") -- Event to listen for. This event fires when you login after all addons have loaded
function DLU:SlashCmdHandler(msg)
local command, arg2, arg3 = strsplit(" ", msg);
command = command:lower();
if command == "size" then -- We want to set a new font size
DarkruneDOTDK_DATA.fontSize = tonumber(arg2) -- New size, save it to your SavedVariables table
SetFontSize() -- Update the chat frame with the new size
end
end
SLASH_DLU1 = "/dlu";
SlashCmdList.DLU = function(commandName)
DLU:SlashCmdHandler(commandName);
end
SavedVariables are global so the name you use for yours should be unique to your addon ie. something like DarkruneDOTDK_DATA