View Single Post
06-16-21, 12:24 PM   #4
Fizzlemizz
I did that?
 
Fizzlemizz's Avatar
Premium Member
AddOn Author - Click to view addons
Join Date: Dec 2011
Posts: 1,877
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:
  1. local function SetFontSize()
  2.     local fontFile, _, fontFlags = ChatFrame1:GetFont();
  3.     ChatFrame1:SetFont(fontFile, DarkruneDOTDK_DATA.fontSize, fontFlags);
  4. end
  5.  
  6. local f = CreateFrame("Frame") -- a frame to handle events
  7. f:SetScript("OnEvent", function(self, event, ...) -- Event handler
  8.     DarkruneDOTDK_DATA = DarkruneDOTDK_DATA or { -- check if your SavedVariables table exists
  9.         fontSize = 12,              -- If not, create it and set some defaults
  10.         someOtherThing = 99,
  11.     }
  12.     SetFontSize() -- Then automatically set the saved font size each login
  13. end)
  14. f:RegisterEvent("PLAYER_LOGIN") -- Event to listen for. This event fires when you login after all addons have loaded
  15.  
  16.  
  17. function DLU:SlashCmdHandler(msg)
  18.     local command, arg2, arg3 = strsplit(" ", msg);
  19.     command = command:lower();
  20.     if command == "size" then -- We want to set a new font size
  21.         DarkruneDOTDK_DATA.fontSize = tonumber(arg2) -- New size, save it to your SavedVariables table
  22.         SetFontSize() -- Update the chat frame with the new size
  23.     end
  24. end
  25.  
  26. SLASH_DLU1 = "/dlu";
  27. SlashCmdList.DLU = function(commandName)
  28.     DLU:SlashCmdHandler(commandName);
  29. end

SavedVariables are global so the name you use for yours should be unique to your addon ie. something like DarkruneDOTDK_DATA
__________________
Fizzlemizz
Maintainer of Discord Unit Frames and Discord Art.
Author of FauxMazzle, FauxMazzleHUD and Move Pad Plus.

Last edited by Fizzlemizz : 06-16-21 at 12:32 PM.
  Reply With Quote