Only run command some % of time

Hi folks!

Is there a way to roll / randomize a command so that it will only execute let’s say 1-5% of the time?

For example if I wanted my character to say something when I’m ressing someone, but not every time I res someone (as that might be spammy / annoying)?

Thanks :slight_smile:

create a table of sayings

local quotes = {
    "Something Cute",
    "Something Smart",
    "Something Blue",
    "Something you wouldn't say to your grandmother",
}

local useQuote = quotes[random(1, #quotes)]
-- say the random useQuote

You could always combine that with random() to decide whether to say anything at all.

1 Like

Thank you so much Fizzle!

One other question - is there a way to do a command (from an addon) only if unmounted?

Something like this:

#showtooltip Highlord’s Golden Charger
/run C_MountJournal.SummonByID(0)
/srq mount say

But the “mount say” part only runs if I’m unmounted? It’s meant to say something when I summon my mount lol :slight_smile:

Presumably your addon would have a global function that contained your sayings and random code and your macro would /run that eg. /run FireheartRandomSayFunc() . The function would detect if you’re mounted etc. and use SendChatMessage if all conditions are met.