Put a cool down into a random say macro to prevent spam

Hi I have a macro that say a random phrase when i use a spell
#showtooltip Crimson Vial
/cast Crimson Vial
/run local t={“A toast for the Emperor!”,“With this, I toast victory.”,“This shall redouble my zeal.”,“Imbibing a potion!”,“Hold a moment while I drink!”,“Come, potion, lend me vigour.”,“This better taste good.”,“I’ll not waste a drop.”}SendChatMessage(t[random(#t)],“SAY”)

I want to add a 3 second cd to this to prevent spamming /say

I found a thread post about adding cd into sendchatmessage from here

Is there a way to merge the 2 macros together

using

/cast Create Soulwell
/run if (not _G[“T”]) then SendChatMessage(“Soulwel up! Come get your fresh Healthstones, made only from the most innocent child souls!”,“SAY”);_G[“T”]=true; C_Timer.NewTimer(5,function() _G[“T”]=false end); end

mentioned in that thread. (with the spell changed and stuff)

PS: I’m using an addon called macro toolkit. and i can use up to 1024 characters in my macros.

As an aside _G[“T”] is the same as T. Macros share the same global namespace as the rest of the lua-based UI.

You’re not concerned for space, but a more concise way to do this (using a 3-character global variable to prevent clobbering a more likely single-character one):

/run if (GetTime()-(LcT or 0))>3 then LcT=GetTime() --[[ your code here ]] end

Change the 3 to the number of seconds you want to wait. (3 may be too short imho.)

So you can just plug your /run bit where it says -[[ your code here ]]:

/cast Crimson Vial
/run if (GetTime()-(LcT or 0))>3 then LcT=GetTime() local t={“A toast for the Emperor!”,“With this, I toast victory.”,“This shall redouble my zeal.”,“Imbibing a potion!”,“Hold a moment while I drink!”,“Come, potion, lend me vigour.”,“This better taste good.”,“I’ll not waste a drop.”}SendChatMessage(t[random(#t)],“SAY”) end

(This exceeds 255 characters so you’ll need to continue using that macro addon.)

2 Likes

tyvm! it worked perfectly :smiley:

Is there a way to only do the /say part when I am not in combat?

also where do i go to learn about macro scripts for wow? I’m curious to what all those non-self explanatory commands like LcT or _G.

thx again :smiley:

/run if (GetTime()-(LcT or 0))>3 and not InCombatLockdown() then LcT=GetTime() --[[ your code here ]] end

so

/cast Crimson Vial
/run if (GetTime()-(LcT or 0))>3 and not InCombatLockdown() then LcT=GetTime() local t={“A toast for the Emperor!”,“With this, I toast victory.”,“This shall redouble my zeal.”,“Imbibing a potion!”,“Hold a moment while I drink!”,“Come, potion, lend me vigour.”,“This better taste good.”,“I’ll not waste a drop.”}SendChatMessage(t[random(#t)],“SAY”) end

Macro scripts use the same language as full-blown addons. So dipping your toes into addon writing is a good way.

These are the hundreds of functions you can use in macros:

This is a reference for lua itself:
https://www.lua.org/manual/5.1/

If you wanted to go all out, the author of Clique and TomTom has a book called World of Warcraft Programming.

Regardless how deeply you want to delve into it, I recommend an in-game addon to run Lua so you can make/run/save scripts in realtime and make tweaks without /reloading. I use TinyPad.

edit: _ G (without the space; this forum is formatting it weird) is a way to reference a global variable. It’s commonly used to concatenate strings and get the variable named after the combined string, like _ G[“BATTLE_PET_NAME_”…petType]. Using _G[“VARNAME”] is the same as using VARNAME by itself.

All macros/addons share the same global namespace (unless a setenv or other means is created for it), so if you have two macros/addons creating a T variable, they’ll interfered with one another. So when I want a global variable for a macro, my convention is to use a 3-letter name with a capital on first and last letter to ensure it’s more unique. (It’s better programming practice to use legible words for variables, but the 255 character-limit of macros makes that impractical. So LcT is a made-up variable name (in this case it stands for Last Chat Time).

1 Like

I lol’d at “more unique” - something is unique or it is not. It’s not subject to degree.

In any case being simply more nearly unique wouldn’t work anyway because stepping on only ONE global somewhere isn’t much better than stepping on a whole raft of them.

:slight_smile:

Things can be more likely to be unique. Why the pedantry?

2 Likes

True.

Just a pet peeve.

Don’t feel bad. I fault the framers of our Constitution as well for a similar error in the premable.

“…in order to form a more perfect union…” - perfect is also not subject to degree.

There is humor in everything.

Is there a way to make a say macro that isn’t this complex? I just want to be able to throw down my earthen totem while spamming the button but alert everyone that it’s down without spamming and making everyone lose focus cause chat is blowing up

A Weak Aura that detects the spell success would do it.

Please don’t resurrect year-old threads - Far better to simply ask your question anew.

1 Like