Macro/Script to send text to channel raid/instance/party

I am trying to write a script in retail that can be used in a macro that will output a chat message to the correct channel based on the type of group I am in. Either Raid/LFR, Instance/LFG or Party.

I have done some searching and found a range of older scripts using now outdated API commands. But using these examples with the updated API commands I have hacked together what I think it should be based on my very limited code knowledge and as expected it does not work.

Here is what I have:
`

/run local C; if (IsInRaid()=TRUE) then C=“RAID”; elseif (IsInGroup(LE_PARTY_CATEGORY_INSTANCE)=TRUE) then C=“INSTANCE”; else C=“PARTY”; end SendChatMessage(“custom_chat_message_here!”,C);

`

Can anyone offer any advice or corrections to make this work as I am wanting it to work? Would be much appreciated, thanks.

Install Macro-Talk and use the /gr command.

https://www.curseforge.com/wow/addons/macro-talk

Yes, I already saw the suggestion of that addon in my research. I would prefer to do it without the use of an addon.

The main issue with not using the addon is you’re losing so much message space to the logic.

That said, if you really want to continue in that direction, I recommend you download the addon and copy the logic it uses because it’s doing it very efficiently.

lua is case sensitive TRUE is not the same a true. To equate something is ==, to assign something is =.
That said:

/run local C if IsInRaid() then C="RAID" elseif IsInGroup(LE_PARTY_CATEGORY_INSTANCE) then C="INSTANCE" else C="PARTY" end SendChatMessage("custom_chat_message_here!",C)
1 Like

Message space was never an issue, nor was macro length limit.

This is really helpful thank you very much! I am a complete Lua novice so those tips are appreciated.

However what you posted was still not working in instance chat. I discovered the chat type for instances is “INSTANCE_CHAT”. Made that one change and it is functioning correctly now.

Many thanks again Fizzlemizz.

What was the final code, please? I’m struggling with writing a code for my druid, when he mass rezz’s.

Not the one you’re replying to, but this macro will send “Mass res inc” to raid if in a raid, instance chat if in an instance group, or party otherwise

/run SendChatMessage("Mass res inc",IsInRaid() and "RAID" or IsInGroup(LE_PARTY_CATEGORY_INSTANCE) and "INSTANCE_CHAT" or "PARTY")
2 Likes

Here is an example of one that I made, basically it spams it to the 3 channels plus the guild channel, I have /5 /6 /7 - each channel is different one is a healer, another dps channel and finally my community channel. Just change the comment and the numbers to spam it in whatever channels you have but be careful not to spam too much.

/run m = "Tonight:Heroic SFO-LF Dps/Heals-Min ilvl 250/Must have Discord/Potions/Oils/Stones/Be enchanted. "; c = “CHANNEL”; g = “GUILD”; n = “nil” v = {5,6,7}; SendChatMessage(m, g); for x=1,3 do SendChatMessage(m, c, n, v[x]) end

It doesn’t work in LFR. I haven’t tried it in a real raid or keys yet. Will keep you posted.

Here are the 2 macros I use on my restoration druid.

/cast Revitalize
/run local C if IsInRaid() then C=“RAID” elseif IsInGroup(LE_PARTY_CATEGORY_INSTANCE) then C=“INSTANCE_CHAT” else C=“PARTY” end SendChatMessage(“It is not yet your time, champions. RISE!! Rise and fight once more!”,C)

and

/cast Revive
/run SendChatMessage(“By Elune! %n, it is not your time. Return to your body. Azeroth still has need of you, hero.”,IsInRaid() and “RAID” or IsInGroup(LE_PARTY_CATEGORY_INSTANCE) and “INSTANCE_CHAT” or “PARTY”)

There’s still an issue sometimes. Other than LFR (“you are not in an instance/a party”), The macro gives me occasional trouble through healbot.

Any suggestions tweeking things would help.

Macro-Talk is still the easiest way to do this, that way you’re not wasting your character limit on technical stuff and can use it for your message.