LS: Glass

LS: Glass

57.5k Downloads

1x ...Ons/ls_Glass/core/components/slidingmessageframe.lua:89: attempt to index local 'data' (a nil value)

Sluimerstand opened this issue ยท 1 comments

commented

Hello!

I wrote some code to filter out a specific message sent by a specific addon. Glass doesn't seem to like that at all, getting very confused when I pass back nil instead of the message proper.

The code I was going to use is as follows:

local function ChatFrame_AddMessageOverride(self, message, ...)
    -- Check if the message contains the specific string
    if message and message:find("Tooltip prices disabled%. Run |cFFFFFF78/oetooltip on|r to enable%.") then
        -- Don't add the message to the ChatFrame
        return
    end
    -- Add the message to the ChatFrame
    self:ChatFrame_AddMessageOriginal(message, ...)
end

-- Hook the ChatFrame's AddMessage method
for i = 1, NUM_CHAT_WINDOWS do
    local frame = _G["ChatFrame"..i]
    if frame then
        frame.ChatFrame_AddMessageOriginal = frame.AddMessage
        frame.AddMessage = ChatFrame_AddMessageOverride
    end
end

I currently have a workaround in place where it sends a blank message instead of filtering out the message entirely. So, my question: is this an issue with Glass not accommodating addons filtering out messages, or is this an issue with my own coding incompetence?

commented

This should do the trick. But "prehooking" is definitely not the safest way of doing things, however, it seems to be relatively safe in this particular case, so whatever floats your goat ๐Ÿ˜