In your .toc file add:
## SavedVariables: Blitzvogel_Data
This tells the game to allocate and save the information in Blitzvogel_Data when you logout (it’s in the [game]\_version_\WTF\Account\[your account]\SavedVariables
folder in a file with the same name as you addon and an extension of .lua.
For mor information:
https://warcraft.wiki.gg/wiki/Saving_variables_between_game_sessions
You will need to decide how you want to store the data (eg by charcater or just a single list of just the last characters data or…) it’s up to you. Same with what data to save ie, what each field is called and how to format the information in each field.
local Player
local function LogEvent(event, ...)
local text, playerName, languageName, channelName, playerName2, specialFlags, zoneChannelID, channelIndex, channelBaseName, languageID, lineID, guid, bnSenderID, isMobile, isSubtitle, hideSenderInLetterbox, supressRaidIcons = ...
tinsert(Blitzvogel_Data, { time=date(), player=Player, text=text, })
end
local f = CreatFrame("Frame")
f:RegisterEvent("PLAYER_LOGIN")
f:SetScript("OnEvent", function (self,event,...)
Blitzvogel_Data = {} -- Initialise the SavedVariables table (it's always nil if it hasn't already been created like this. This will create a new empty table each logon)
Player = UnitName("player")
hooksecurefunc("ChatFrame_OnEvent", function(self, event, ...)
if event == "CHAT_MSG_OPENING" then
LogEvent(event, ...)
elseif event == "CHAT_MSG_LOOT" then
LogEvent(event, ...)
end
end)
Should produce an output file that looks like (but flatter as Blizz. has just started removing the indenting on save):
Blitzvogel_Data = {
{
time="Fri Jun 28 12:00:52 2024",
player="Blitzvogel",
text="Whatever the text arg is from the first event",
},
{
time="Fri Jun 28 12:00:54 2024",
player="Blitzvogel",
text="Whatever the text arg is from the next event",
},
}
Each entry would be in order from first to last.
You can save whichever fields from the … list by adding them to the tinsert (table.insert) entry