#read /say chat in weakaura, and counting a certain occurence

57 messages · Page 1 of 1 (latest)

frigid cape
#

Hello, i've started doing weakaura recently and am still struggling. i'd like to make a weakaura that read a certain word on the chat, and counting the word till the end of a fight, and show at the end the number of time each person on my raid said that certain word. So far i'm trying to read /say chat, but seems like I have a problem somewhere.

buoyant ice
#

you're using a TSU but I think you're misunderstanding some of how they work

#

what is your MsgFound arg for?

dim crypt
#

You selected the one option that says "advanced" and you have to use th correct order for the Args. You applied them very random.

buoyant ice
#

also your list could be built once and accessed by key, instead of having to loop through it on each message

dim crypt
#

And the included var isn't needed, just return.

frigid cape
#

hum, im fairly new, im not sure to understand, and i tried to pick things i found on internet :/

#

the goal is : increment each person who say something on /say chat on this variable

buoyant ice
#

not sure if the tertiary operator will work how I want to here but this is roughly how I'd do it

scrap the TSU and just use a custom -> event trigger with some code like this

function(event, ...)
    if event == "CHAT_MSG_SAY" and ... then
        local sender, text = ...
        if strlower(text) == "boing" and aura_env.playerList[sender] then
        if aura_env.listOccurrence[sender] then
            aura_env.listOccurrence[sender] = aura_env.listOccurrence[sender] + 1
        else
            aura_env.listOccurrence[sender] = 1
        end
    end
    return true
end
frigid cape
#

does it "add" new player that sais "boing" the first time ? seems like they will not pass the "aura_env.playerList[sender] condition

#

perfect

buoyant ice
#

I assumed that player list was a config table that you're using to filter for specific players

#

otherwise it's not needed and you can scrap that check

frigid cape
#

seems like its counting now, can we run a function when the weakaura unload ? so that it shows on chat every person count ?

buoyant ice
#

yeah if you go to the actions tab and find "on hide" you can loop through your tally and print to the display

#

@dim crypt do you know if aura_env gets cleared on unload? or whether we need to manually do it here on encounter start/end

buoyant ice
frigid cape
#

oh :/

#

maybe i can load the weakaura when i want, and just reset the list on pull, and show on wipe ?

dim crypt
#

Yes.

buoyant ice
#

I tweaked it a bit, try this

function(event, ...)
    if event == "ENCOUNTER_START" and ... then
        aura_env.counts = {}
    elseif event == "ENCOUNTER_END" and ... then
        for player, count in pairs(aura_env.counts) do
            print(player .. ": " .. count .. " boings.")
        end
    elseif string.find(event, "CHAT_MSG") and ... then
        local text, playerName = ...
        if strlower(text) == "boing" then
            if aura_env.counts[playerName] then
                aura_env.counts[playerName] = aura_env.counts[playerName] + 1
            else
                aura_env.counts[playerName] = 1
            end
        end
    end
    return true
end
dim crypt
#

I am personally a fan of the pattern
If not array[X] then array[X] = 0

buoyant ice
#

idk how the other one was working because it was grabbing the sender as the first arg and checking that for boings

dim crypt
#

It wasnt

buoyant ice
#

ye must've been a false positive

#

note that if you're using that code you need to add ENCOUNTER_START and ENCOUNTER_END to your events section

frigid cape
#

ye i saw that

buoyant ice
#

the CHAT_MSG code will run on any event that you listen for too, so _RAID _PARTY etc

frigid cape
#

to debug and be sure it works, can i replace encounter_start and encounter_end with something else ?

#

like fighting against dummy

buoyant ice
#

if you only care about say just check for it, the find is wasted processing in that case

buoyant ice
#

double check your load condition too

frigid cape
#

its the outside combat regen ?

buoyant ice
#

_DISABLED fires when combat starts

frigid cape
#

seems like its running once

#

on pull, and then doesnt deactivate

buoyant ice
#

can you post your code and events here?

frigid cape
#
function(event, ...)
    if event == "PLAYER_REGEN_DISABLED" and ... then
        aura_env.counts = {}
    elseif event == "PLAYER_REGEN_ENABLED" and ... then
        for player, count in pairs(aura_env.counts) do
            print(player .. ": " .. count .. " boings.")
        end
    elseif event == "CHAT_MSG_SAY" and ... then
        local text, playerName = ...
        if strlower(text) == "boing" then
            if aura_env.counts[playerName] then
                aura_env.counts[playerName] = aura_env.counts[playerName] + 1
            else
                aura_env.counts[playerName] = 1
            end
        end
    end
    return true
end

#

a lua error is occuring somewhere it seems

buoyant ice
#

ah the regen events don't send args

#

remove the and ... checks while debugging

frigid cape
#

OH

#

IT WORKS

#

perfect

buoyant ice
frigid cape
#

thank you very much @buoyant ice and @dim crypt

#

i tagged it solved

buoyant ice
#

if you want to remove the realm name from your print you can call Ambiguate() like this

print(Ambiguate(player, "short") .. ": " .. count .. " boings.")

#

like this

frigid cape
#

can we send that in /say chat ?

buoyant ice
#

you can, your guild/pugs will probably hate you though

frigid cape
#

dw its for guild

buoyant ice
#

anything spammy like this is usually beft left to personal prints