Post by pelf
Formatting of initial stuff started.
Let me know if you have some thoughts on how I'm doing the formatting. I want to get a consistent feel for each section.
Notes To SelfNote about optional parameters using brackets.
EDIT: If any of you guys remember some of those ones that were posted in a thread and you thought, "Oh, neat. That's well done," then please post them in here. Otherwise, I'm going to start reading back through a few pages of threads in this forum to look for the ones that I liked.
TABLE OF CONTENTS FOR THIS POSTSAYING SOMETHING IN PARTY OR RAID IF YOU ARE IN EITHER(
Refinements and revisions courtesy of WanderingFox and Safturento.)
- General Form
/stopmacro
/run local c=GetNumRaidMembers()>0 and "RAID" or "PARTY" SendChatMessage("__message_text__",c) - With target Included
/stopmacro
/run local c,t=GetNumRaidMembers()>0 and "RAID" or "PARTY",UnitName("target") if t and c then SendChatMessage("__message_prefix__"..t.."__message_suffix__",c) end - Code Expanded
local channelName, targetName = GetNumRaidMembers() > 0 and "RAID" or "PARTY", UnitName("target");
if targetName and channelName then
SendChatMessage("__message_prefix__"..targetName.."__message_suffix__", channelName);
end - Example
#showtooltip
/cast Revive
/stopmacro
/run local c,t=GetNumRaidMembers()>0 and "RAID" or "PARTY",UnitName("target") if t and c then SendChatMessage("Resurrecting <<"..t..">>.",c) end
SIMULATING A BUTTON CLICKThis is usually used to activate a pet ability by its location on your pet bar, perhaps if it has the same name as one of your abilities so you can't cast it by name.
However, this can be used to activate anything that can receive a click.- Find the Button Name
After running this, you will see a small window that changes depending on what you have moused over. The name of the button will be one of the items in this list. Some practice will help you determine which one you want. Running this again will toggle off the frame stack display.
/framestack - Simulate the Click
/click __button_frame_name__ - Pet Button Example
/click PetActionButton4 - Static Popup Example
This macro will click the left-most button on the default static yes/no okay/cancel popup dialog.
This is useful for including an auto-accept on the replace poison question for a rogue poison macro.
/click StaticPopup1Button1 - Poison Example
#showtooltip
/use Crippling Poison; Wound Poison
/use 17; 16
/click StaticPopup1Button1
CASTING SPELLS WITH ERROR MESSAGES AND SOUNDS SUPPRESSEDThis kind of macro will allow you to use-when-ready any spell or item that does not invoke a GCD without
being spammed with error messages about how they are not ready while they are on cooldown.- General Form
#showtooltip __main_spell__
/console Sound_EnableSFX 0
/cast __non_gcd_spell__
/use __non_gcd_item__
/run UIErrorsFrame:Clear()
/console Sound_EnableSFX 1
/cast __main_spell__ - Example
This macro will activate whichever of your trinkets is available, Inner Focus, if available, and then cast Greater Heal.
#showtooltip Greater Heal
/console Sound_EnableSFX 0
/use 14
/use 15
/cast Inner Focus
/run UIErrorsFrame:Clear()
/console Sound_EnableSFX 1
/cast Greater Heal
SETTING RAID TARGETSThis will cover the two marking API functions and their differences.- Choose Your API Call
There are two possibilities for which API you can call to set a raid target.
--Puts a raid target marker on a unit.
SetRaidTarget("unit", index)
or
--Puts a raid target marker on a unit, toggling it off if the same index is called twice.
SetRaidTargetIcon("unit",index) - API Parameter Information
unit - A unit to mark (string, unitID) - index - Index of a target marker (number)
• 0 - Clear any raid target markers
• 1 - Star
• 2 - Circle
• 3 - Diamond
• 4 - Triangle
• 5 - Moon
• 6 - Square
• 7 - Cross
• 8 - Skull
Example With target
, ToggleableThis will set the Skull on
target or toggle it off when run while
target already has a Skull.
/run SetRaidTargetIcon("target",8)
Example With mouseover
, No ToggleThis will set the Cross on
mouseover, but will not clear it on successive runs.
/run SetRaidTarget("mouseover",7)
DOING THINGS RANDOMLYThis will cover the random function and some possible uses.- The Lua random Function
As far as I can tell, the random that you call, like that, is a wrapper for the Lua random in the math library.
You can call it either way, though obviously omitting the math. is shorter.
random(]) - random Parameter Information
m - Optional. Lower bound (number) - n - Optional. Upper bound (number)
Information About random
random will produce a
pseudo-random number (real or integer, depending on how it is called).
- No Parameters - a pseudo-random, real number in the range .
- Two Parameters (m, n) - a pseudo-random integer in the range .
Companion ExampleThis will summon a random companion using random combined with the number of companions you have learned.
In this case,
random is being called with a single parameter, so you will get an integer in the range
.
/run CallCompanion("CRITTER", random(GetNumCompanions("CRITTER") ) )
Say Something Random ExampleThis one will define a set of phrases and pick one of them to say at random.
/run local p={"I've got nicotine stains on my fingers.","I've got a silver spoon on a chain.","I've got a grand piano to prop up my mortal remains."} SendChatMessage(p,"SAY")
Say Something Random Example, Method 2Credit for this alternate method goes to
Wikipedia. None of us even knew
GetRandomArgument existed. Also,
HighFive likes it.
I know it doesn't even use the
random function; but, it does do something randomly, so it fits.
/run SendChatMessage(GetRandomArgument("I've got nicotine stains on my fingers.","I've got a silver spoon on a chain.","I've got a grand piano to prop up my mortal remains."), "SAY")
Say Something One (1) Out Of n Times The script Is Run- General Form
/run if random(n) == 1 then SendChatMessage("__message__","SAY") end - One Out Of 20 Times
/run if random(20) == 1 then SendChatMessage("Confucious say, bad singers break into song because they can't find the key.","SAY") end
MULTI-PURPOSE PALADIN MOUNT, AURA AND A SPELL MACROI made this macro when I was trying to figure out how to keybind all of my paladin abilities without being a pianist.- General Form
#showtooltip
/cast !Crusader Aura
/cast __mount__
/stopmacro
/cast !__default_aura__
/dismount
/cast __spell__ - Explanation
Out of combat, while not mounted, with shift pressed, activate Crusader Aura, use __mount__; stop the macro. - If mounted or control pressed, activate __default_aura__.
- If mounted, without control pressed, dismount.
- Else, without control pressed, cast __spell__.
N.B. __default_aura__ activation will work at all times; so, even if you forget to dismount using this macro, you can hold control and activate it (in or out of combat).
ExampleI use this macro on my Paladin who is just a tank; so, I cast Devotion and Hammer of Wrath.
#showtooltip
/cast !Crusader Aura
/cast Charger
/stopmacro
/cast !Devotion Aura
/dismount
/cast Hammer of Wrath
MACRO THAT SHOULD BE USED WITH ALL FRIENDLY SPELLSAs far as I'm concerned, this functionality should be the default for friendly spells.- General Form
/cast __friendly_targetable_spell__ - Example
/cast Flash Heal
NIFTY MOUSEOVER BUFF SEQUENCE MACROThis will cast a sequence of spells on your mouseover. Once you've acquired your target, you can move your mouse.
Choose a new target by activating the macro while mousing over a new target. The sequence will reset and you can start again.- General Form
/target mouseover
/castsequence reset=target __spell_1__]] - Note
Each run of the /castsequence, it will assign mouseover to target, if you have a mouseover; but, since it will be the same person the reset condition of the /castsequence won't be met, and it will just continue. If you don't have a mouseover, it will keep your current target and continue the sequence. - Example
/target mouseover
/castsequence reset=target Shadow Protection, Power Word: Fortitude, Divine Spirit
PERFORM A SPECIFIC TRADESKILL BY NAMEThis will open the panel for the desired profession, find a skill, by name, and then perform it.- General Form
#showtooltip __descriptive_icon__
/cast __profession_name__
/run for i=1,GetNumTradeSkills() do if GetTradeSkillInfo(i)=="__trade_skill_name__" then CloseTradeSkill() DoTradeSkill(i) break end end - Code Expanded
for i=1, GetNumTradeSkills() do
if GetTradeSkillInfo(i) == "__trade_skill_name__" then
CloseTradeSkill();
DoTradeSkill(i);
break;
end
end - Example
#showtooltip Frostweave Cloth
/cast Tailoring
/run for i=1,GetNumTradeSkills() do if GetTradeSkillInfo(i)=="Bolt of Frostweave" then CloseTradeSkill() DoTradeSkill(i) break end end
LINK A PROFESSION IN TRADEThis will link a profession along with a message in the trade channel.
It will print an the error message "Not In Trade!" in red, in your default chat frame, if you have not joined the trade channel.- General Form
After removing __profession_name__ and __message__, you have 74 characters for the name of your profession, as it is in the spell book,
plus a small message. If you want the message after the link, move the "".. to the end, as .."". Place your message within the quotes.
/run local c=GetChannelName("Trade - City")if c~=0 then SendChatMessage("__message__"..select(2,GetSpellLink("__profession_name__")),"CHANNEL",nil,c) else DEFAULT_CHAT_FRAME:AddMessage("Not In Trade!",1,0,0) end - Code Expanded
local tradeChannel = GetChannelName("Trade - City");
if tradeChannel ~= 0 then
SendChatMessage("__message__"..select(2, GetSpellLink("__profession_name__")), "CHANNEL", nil, tradeChannel);
else
DEFAULT_CHAT_FRAME:AddMessage("Not In Trade!", 1, 0, 0);
end - Example
This adds the message after the link and sends a link for Enchanting.
There was enough space to add the #showtooltip line to give the macro the Enchanting tooltip.
#showtooltip Enchanting
/run local c=GetChannelName("Trade - City")if c~=0 then SendChatMessage(select(2,GetSpellLink("Enchanting")).." looking for work! Tips appreciated!","CHANNEL",nil,c) else DEFAULT_CHAT_FRAME:AddMessage("Not In Trade!",1,0,0) end
LINK MULTIPLE PROFESSIONS IN TRADETo save on space, with this one, there's no error check for not being in the trade channel. Make sure you /join trade before you run this.- General Form
After removing __message_#__ and __profession_#__, you have 107 characters for the name of your professions, as they are in the spell book, plus a small message with each profession link.
(Sorry for the scroll bar that you probably see on this code box. The script is very jammed together.)
/run local s,g,t,c=SendChatMessage,GetSpellLink,"CHANNEL",GetChannelName("Trade - City")s("__message_1__"..select(2,g("__profession_1__")),t,nil,c)s(select(2,g("__profession_2__")).."__message_2__",t,nil,c) - Code Expanded
local tradeChannel = GetChannelName("Trade - City");
SendChatMessage("__message_1__"..select(2, GetSpellLink("__profession_1__")), "CHANNEL", nil, tradeChannel);
SendChatMessage(select(2, GetSpellLink("__profession_2__")).."__message_2__", "CHANNEL", nil, tradeChannel); - Example
#showtooltip Tailoring
/run local s,g,t,c=SendChatMessage,GetSpellLink,"CHANNEL",GetChannelName("Trade - City")s("Free with your mats "..select(2,g("Tailoring"))..".",t,nil,c)s(select(2,g("Enchanting")).." I'll even give you 1000g if I skill up!",t,nil,c)
SEND AN ITEM LINK IN A CHAT MESSAGEThis is the general form of how to send an item link in a message. The examples will get more specific.
Since we're going to cover several variations, I figure here's a good time to show how to use the SendChatMessage API in detail.- SendChatMessage Syntax
SendChatMessage("text" ]]) - SendChatMessage Parameter Information
text - Message to be sent (up to 255 characters) (string) - chatType - Optional (default="SAY"). Channel to which to send the message (string)
BATTLEGROUND - Sends to a battleground raid group (/bg) - CHANNEL - Sends to a server or custom chat channel /1, /2, /n); requires channel number for channel argument
- DND - Enables Away-From-Keyboard status for the player, with text as the custom message seen by others attempting to whisper the player
- EMOTE - Custom text emotes visible to nearby players (/e)
- GUILD - Sends to guild members (/g)
- OFFICER - Sends to guild officers (/o)
- PARTY - Sends to party members (/p)
- RAID - Sends to raid members (/ra)
- RAID_WARNING - Warning to raid or party members (/rw)
- SAY - Speech to nearby players (/s)
- WHISPER - Sends to a specific character (/w); requires name of the character for channel argument
- YELL - Yell to not-so-nearby players (/y)
language - Optional (see below for default). Language in which to send the message (string)
- COMMON - (Alliance Default) Human language
- DARNASSIAN - Night Elf Language
- DRAENEI - Draenei Language
- DWARVEN - Dwarf Language
- GNOMISH - Gnome language
- GUTTERSPEAK - Undead language
- ORCISH - (Horde Default) Orc Language
- TAURAHE - Tauren Language
- THALASSIAN - Night Elf Language
- TROLL - Troll language
channel - If
chatType is
WHISPER, name of the target character; if
chatType is
CHANNEL, number identifying the target channel; ignored otherwise (string)
Say The Message/run SendChatMessage("Help, I lost my "..select(2,GetItemInfo(
6948)).." and I don't know where home is!")
Say The Message In Party/run SendChatMessage("*** USED MY "..select(2,GetItemInfo(
29530)).." ***","PARTY")
Tainted Core Macro With Item LinkObviously you'd use
/y and
/s and
/ra for this normally, but this is for educational purposes. Also, I've broken the calls out onto multiple lines, but you would want them all jammed together for this to actually work.
/use Tainted Core
/run SendChatMessage(select(2,GetItemInfo(
31088)).."TO ---> "..UnitName("target").." <---","YELL")
SendChatMessage(select(2,GetItemInfo(
31088)).."TO ---> "..UnitName("target").." <---","SAY")
SendChatMessage(select(2,GetItemInfo(
31088)).."TO ---> "..UnitName("target").." <---","RAID")
SendChatMessage("YOU HAVE THE "..select(2,GetItemInfo(
31088)).."!","WHISPER",nil,UnitName("target"))
Send A Message To Trade/run SendChatMessage("WTS "..select(2,GetItemInfo(
50379))..", 5000g OBO","CHANNEL",nil,"GetChannelName("Trade - City"))
apply a poison to mainhand, then offhand
#showtooltip
/use Deadly poison VIII; Instant Poison IX
/use 17; 16
cancel a specific totem
/run DestroyTotem(1)
http://wowprogramming.com/docs/api/DestroyTotem/use Tainted Core
/yell TAINTED CORE TO ---> %T <---
/say TAINTED CORE TO ---> %T <---
/script SendChatMessage("YOU HAVE THE CORE!" ,"WHISPER" ,nil,UnitName("target"));
tainted core for the lulz
camera distance macro information
raid warning to only myself
toggle or change the value of a cvar (console vs. run set/getcvar)
/run for i,v in ipairs{"Left","Right"} do for i = 2, 12 do local n = "MultiBar"..v.."Button" local btn = _G btn:ClearAllPoints() btn:SetPoint("LEFT", n..i - 1, "RIGHT", 6, 0) end end
flips the right two action bars to horizontal
/run for i = 1,120 do PickupAction(i) ClearCursor() end
clears all the buttons off of action bars
--
Conditionals don't work with /run. For modifiers, you need the APIs IsSiftKeyDown(), IsControlKeyDown() and IsAltKeyDown(). For buttons you need the API GetMouseButtonClicked(), which returns one of "LeftButton", "MiddleButton", "RightButton", or "ButtonN" where N is 4-15 (for extra mouse buttons).
If you're using the some sort of slash-command set equipping, you can do:
/equip pvp gear; pve dps
/run ShowHelm( GetMouseButtonClicked()=='RightButton' )
http://www.wowhead.com/forums&topic=185263&p=2575900#p2575900http://www.wowhead.com/forums&topic=189147&p=2690891--
blah. that's 7 pages back. stopping for now.
Post by pelf
Tainted core macro is DEFINITELY going in there. Fsk Vashj, by the way. (Not in the good way.)
I like the target addition. However, what's the API call to fall back on to determine if you're also not in a party? If alone and I'm resurrecting someone, or innervating or whatever, I don't want to get the "You are not in a party." thing.
EDIT: To clarify what I was thinking when I said "something or nothing"...
- Something: Just output to either SAY or to the local chatbox.
- Nothing: Do nothing.
EDIT2: Where's the macro that gets the link for a tradeskill and adds it to an outgoing message to the trade channel?
Post by Safturento
the API for that is GetNumRaidMembers() and GetNumPartyMembers(). That would make the macro so long though, that it would just be more efficient to use '/script UIErrorsFrame:Clear()'.
EDIT: To clarify what I was thinking when I said "something or nothing"...
- Something: Just output to either SAY or to the local chatbox.
- Nothing: Do nothing.
Like this?
/run if SomeConditionalHere() then SendChatMessage("insert message here","SAY") end
if the conditional is true it would output, else it would do nothing.
edit: You might want to put the code on the first post in code brackets :P