Anyway to get the payload from an event?

I’m running this specifically,

local Player
local function LogEvent(event, ...)
   SendChatMessage("Process, " ..event .. ", something1, something2", "WHISPER", nil, Player)
end

local f = CreateFrame("Frame")
f:RegisterEvent("PLAYER_LOGIN")
f:SetScript("OnEvent", function(self, event, ...)
      Player = UnitName("player")
      hooksecurefunc("ChatFrame_OnEvent", function(self, event, ...)
            if event == "CHAT_MSG_SKILL" then
               LogEvent(event, ...)
               -- or maybe something different
            elseif event == "CHAT_MSG_LOOT" or event == "CHAT_MSG_CURRENCY" then
               LogEvent(event, ...)
               -- or maybe something different
            end
      end)
end)

When looting a mining node it produces the output,

Process, CHAT_MSG_LOOT, something1, something2

so I’m guessing I need to pull elements of the payload from the actual message and I can’t find information on how to do that.

Maybe it’s not set up to do this though IDK.

For the payload information see:
https://warcraft.wiki.gg/wiki/CHAT_MSG_LOOT
and
https://warcraft.wiki.gg/wiki/CHAT_MSG_SKILL
The payloads are the same at a quick glance.

To use, something like:

local function LogEvent(event, ...)
   local text, playerName, languageName, channelName, playerName2, specialFlags, zoneChannelID, channelIndex, channelBaseName, languageID, lineID, guid, bnSenderID, isMobile, isSubtitle, hideSenderInLetterbox, supressRaidIcons = ...
   local txt = format("Process, %s, %s,%s", event, text, playerName)
   SendChatMessage(txt, "WHISPER", nil, Player)
end

or format whatever payload arguments you need.

Once again, these could go into a SavedVariables table instantly without have to resend back into the chat system just to get a timestamp and information in a “row” format from the log.

1 Like

I knew about the CHAT_MST_LOOT link you gave, so I already knew what the payload content was, but I cant find where I’m supposed to get the

    local text, playerName, languageName, channelName, playerName2, specialFlags, zoneChannelID, channelIndex, channelBaseName, languageID, lineID, guid, bnSenderID, isMobile, isSubtitle, hideSenderInLetterbox, supressRaidIcons = ...
    local txt = format("Process, %s, %s,%s", event, text, playerName)
   SendChatMessage(txt, "WHISPER", nil, Player)

stuff. Is it in the LUA documentation that’s always down? I’m mostly just trying to learn how the thing works right now and there’s jack all for documentation/guides that I can find.

Two issues about the variable thing:

First, it’s mostly about goofing with the thing to learn how it works. So it’s better to do it multiple ways to just experiment with the thing.

Second, it can work like that yea. It will be better to restrict what’s saved down to a smaller set though so I’d really need more information on how to manipulate what’s saved. Like I really don’t need anything but the text component.

Where do I find information on how saved variables work?

The ... passed to LogEvent denotes a variable number of arguments

local a, b, c, d = ... retrieves the first 4 arguments from ...

local a = ... retrieves only the first etc.

local text, playerName, etc = ... above is all the arguments passed to LogEvent (from the CHAT_MST_LOOT etc. events from the OnEvent ... payload)

Saved Variables can save as many (or as few) pieces of information as you need. The text layout will (in most cases) be representative of a lua table as that’s the most flexible form to save in. See:
https://warcraft.wiki.gg/wiki/Saving_variables_between_game_sessions

1 Like

EDIT: Just to try it out.

So the first part should be?

local Player
local function LogEvent(event, ...)
    local text = ...
    table.insert(t,x)

t would be the list of values that are likely the characters saved variable file. I don’t know how to reference that. Just Player?

tinsert should append the list with new values if the position is not specified, which is what I want, so I can leave it blank.

x would be the events I’m interested in. For a bare minimum I need only to track the text from CHAT_MSG_OPENING, and CHAT_MSG_LOOT. So what’s x equal to? text?

The next part would be,

local f = CreatFrame("Frame")
f:RegisterEvent("PLAYER_LOGIN")
f:SetScript("OnEvent", function (self,event,...)
    hooksecurefunc("ChatFrame_OnEvent", function(self, event, ...)
        if event == "CHAT_MSG_OPENING" then
            LogEvent(event, ...)
        elseif event == "CHAT_MSG_LOOT" then
            LogEvent(event, ...)
    end
end)

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

1 Like

Oh I don’t want the data to be local to this guy. (I’m not sure that what you’re saying means that exactly.) I have two characters on various beta servers that I want to use for testing so it would have to be local to the character. I guess the account would work too.

Other than that this should be fine though.

I’ll maybe dig around more to get some x y coordinate information in there but that should be more than what’s needed. TYTY

How you store the data is up to you. You can create a sub-table for each character, you can create sub-sub tables with a seperate session information each login for each character etc. etc. That’s up to you.

1 Like

Well so you set the .toc to ##SavedVariablesPerCharacter: FOOBAR

Then what it’s just table.insert(FOOBAR, {text=text,})

1 Like

You could do that and the file is placed under the realm\charecter\SavedVariables folder. Again, it’s a matter of preference.

1 Like