Navigation menu
Personal tools
Not logged in
Talk
Contributions
Create account
Log in
Namespaces
WoW
Talk
English
Views
Read
Edit
History
More
Search
Navigation
Home
Random page
Help using wiki
Editions
for WoW
for WildStar
for Solar2D
Documentation
for WoW
for WildStar
Reference
WoW
⦁ FrameXML
⦁ AddOns
⦁ API
⦁ WoW Lua
WildStar
⦁ AddOns
⦁ API
⦁ WildStar Lua
Engine
Tools
What links here
Related changes
Special pages
Page information
Site
Recent Changes
Editing
WoW:UI FAQ/Macros and scripts
(section)
Jump to navigation
Jump to search
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== How? (How do I use?) == === General === NOTE: Macro scripts cannot be used in combat anymore {{faqq}}'''How do I create a macro? ''' {{faqa}}In a chat box, start by typing /macro. then click NEW, give it a name and an icon, and then start entering some commands. {{faqq}}'''How can I make a conditional macro? ''' {{faqa}}To use conditionals, you'll need to invoke the LUA interpreter. To do that, you start a macro with "/script" Anything after /script will be run as lua code (or a 'chunk' as lua calls it). It is VERY important to keep all parts of a Lua chunk on ONE LINE in a macro, and make it fit within 255 characters. You can then use the "if ... then ... end" codeblock to complete your macro. it should look similar to this when you're done: NOTE: As of 2.0.1 you may not use anymore conditional macros to initiate spellcasting, give orders to your pet or use an item. /script if UnitName("target") == "fred" then SendChatMessage("Hi fred!","WHISPER",nil,"fred"); end Note the use of "end" at the end. It's important to Lua. {{faqq}}'''When using Lua script code, do I need to end each line with a semicolon? ''' {{faqa}}Lua doesn't require this, but you may do so if you like. It does make it easier to read, but Lua does have strict enough syntax that it can understand commands without semicolons. Even something as ugly as this is legal: /script a =5 b =6 Message(a..b)c= a +b {{faqq}}'''How do I output text to the chat window?''' {{faqa}}Use <tt>DEFAULT_CHAT_FRAME:AddMessage(msg,r,g,b,a)</tt>, where msg is the text, and "r,g,b" are red,green,blue (0-1) and "a" is alpha (transparency; 0 for completely transparent, 1 for completely solid). The alpha parameter can be left out to mean "completely solid". This is easier if you write a function that calls the above, :AddMessage(), function: function cprint(...) DEFAULT_CHAT_FRAME:AddMessage(...) end Then you can use cprint("foo",1,0,0) multiple times in the macro without it taking quite so many characters. NOTE: As of 3.0, [[API_print|print]]() is now available. {{faqq}}'''Is it possible to wait in a macro for a certain amount of time, then continue running the rest of the macro? ''' {{faqa}}No, it is not possible. See the question regarding multiple abilities in one macro for a more detailed explanation of the sorts of things not being able to wait prevents you from doing. ADDENDUM: It is possible, if you have the [http://www.cosmosui.org/addons.php?info=Chronos Chronos] stand-alone library, the [http://wow.curse.com/downloads/wow-addons/details/ace2.aspx AceEvent-2.0] stand-alone library, or any addon that uses either of those installed, to do something like: /in 5 /say Hello, /say Fred! And in 5 seconds you will say "Hello,". But you will say "Fred!" right now. /in is not a macro pause command, it simply lets you queue up a single command to execute at a future time. HOWEVER, you cannot use /in to cast a spell, use an ability, or run a macro, due to the hardware event restriction. So, its usefulness is very limited. You can use it to talk, or to use items, but that's about it. Which is one reason I didn't mention it in the first place. Because 99% of the time people want a pause, its so they can cast another spell in the same macro, or switch inventory items and then use an ability, neither of which is possible using /in. {{faqq}}'''Why won't this macro / addon work? I'm almost positive my code is correct! ''' {{faqa}}For macros: double- and even triple-check your syntax AND SPELLING. Remember that Lua is case-sensitive! Triple-check the names of any spells, as well. CastSpellByName("Curse of Shadows(Rank 2)") is NOT the same as CastSpellByName("Curse of Shadow(Rank 2)") For AddOns: Follow the advice given in the "For macros:" section above. Remember that both Lua *and* XML are case-sensitive! <tt></OnLoad></tt> is NOT the same as <tt></onload></tt>. If your AddOn is listed in the [AddOns] list at character select, but doesn't seem to be loading in-game, check your XML, you likely have an error there somewhere. If you've tried the above and STILL can't get your script to work: Make a NEW post in this forum asking for help. Please DO NOT clutter up this thread asking for help with your broken macros! {{faqq}}'''How do I register a /slash command? ''' In my UI AddOn, what do I need to do to create a new "/slashcommand" that the user can type into the chat box? {{faqa}}Slash command information is stored in two places. The first is a global table named SlashCmdList. In order to add a new command, create a new function with one argument. That argument will contain whatever text the user typed after the name of your command. MyAddon = {}; function MyAddon.SlashCommand(Argument) DoSomethingWith(Argument); end Then create a new entry in the table for your new slash command. SlashCmdList["My_AddOn_Slash_Command"] = MyAddon.SlashCommand; The second place slash command information is stored is in a haphazard series of global variables. These variables' names all start with "SLASH_", then the name of an entry in SlashCmdList, and end with a digit. The value of each variable is the text the user types to active the command. It's important to note that while the names of the variables are case-sensitive, the command the user types is case-insensitive (so "/MASC", "/Masc" and "/masc" all do the same thing. SLASH_My_AddOn_Slash_Command1 = "/MASC"; SLASH_My_AddOn_Slash_Command2 = "/MASlashCommand"; SLASH_My_AddOn_Slash_Command3 = "/MyAddonSlashCommand"; === Spells, Abilities and Buffs === {{faqq}}'''What is the best way to know the exact spelling of a spell to cast? ''' {{faqa}}Open your spellbook along side your macro editor. Position the edit cursor in the macro window, and then hold down the SHIFT key while you LEFT click on a spell icon in your spellbook, and the game will type in the correct /cast spellname command for you. You can then cut/paste or edit it if needed. {{faqq}}'''Can I make a conditional macro that does something if I have a certain buff? ''' {{faqa}}You can't do that with such a macro since 2.0.1. {{faqq}}'''Is it possible to use multiple abilities in one macro, such as cast Corruption, Curse of Agony, and then Shadowbolt? ''' {{faqa}}No. The reason is that it is not possible to wait in a macro, but to cast one spell after another, you would have to cast the first one, wait for it to finish, then cast the other. Even instant spells activate a global cooldown timer of 1.5 second (or 1 second for rogues/warriors/druids in bear/cat form), and you cannot cast another spell until this timer is done. Even with the ability to wait in a macro, you wouldn't be able to cast multiple spells: an action from the user is required to start a spell cast (like a keypress or a mouse click, not at any other time - which is why "do something, wait a bit, then cast XXX" is impossible). It is, however, possible to do multiple things that don't require waiting. You could, for example, cast a spell and turn on attack. Or use two items (as long as they had independent refresh timers). You just can't do anything that would require waiting between action A and action B. NOTE: It is possible, however, since 2.0.1, to define a /castsequence macro which would allow you to cast a different spell on each button click. See 2.0 macro guide for more details. {{faqq}}'''How do I set up a macro or script to automatically cast XXX when... ''' {{faqa}}You don't. There is no way to automatically cast any spell or ability. You can ONLY use spells and abilities in response to a hardware event (mouse button or keyboard press), and furthermore, it appears that the hardware event must trigger a normal action button or the spell will fail to cast. Furthermore, since 2.0.1, many cast/use/pet functions have been protected and cannot be used directly by AddOns and scripts. {{faqq}}'''How do you link multiple spells together in a single macro? ''' {{faqa}}Spells can be linked into one macro if the first one does not activate the global cooldown (such as Nature's Swiftness). To do so, simply put the two spells on two different lines. E.g. /cast Presence of Mind /cast Pyroblast(Rank 1) See also the Addendum on chaining spells at the end of this FAQ. :''Note: The above has been rewritten to match 2.0.1 new restrictions. The rest of the FAQ also needs to be updated. Everything below this message is still pre-2.0.1 documented.'' === Interacting with the World === {{faqq}}'''Can you help me write a macro that will automatically loot a corpse / automatically skin and loot a corpse / automatically pickpocket and loot?''' {{faqa}}No. There is no way to loot items except via mouse clicks. {{faqq}}'''How do I make a macro that jumps and spins 180 degrees?''' {{faqa}}Movement related functions now require a hardware event to work so such a macro is no longer feasible. Even when it was, you could only turn at the same speed that the keyboard can turn you which is too slow to be usable in PvP. It is better to practice this maneuver using the mouse. The default Blizzard UI has a camera function (Main Menu->Key Bindings->Camera Functions) called "Flip Camera" which rotates the camera (but not the character) 180 degrees. {{faqq}}'''How do I make a macro/addon that tells me the distance to my target?''' {{faqa}}The ability to obtain the exact distance between you and a non-friendly target was removed. At best, you can now only obtain a range (i.e.: Between 36 and 30 units) based on which abilities on your action bar are usable ([[API IsActionInRange|IsActionInRange(slot)]]). You can get some more range information by using [[API CheckInteractDistance|CheckInteractDistance(unit, distanceType)]] {{faqq}}'''Can I make a Macro that automatically picks up the WSG flag? ''' {{faqa}}This is not possible. Any interaction with the 3d world (talking to NPCs, looting...) must be done via mouse click
Summary:
Please note that all contributions to AddOn Studio are considered to be released under the Creative Commons Attribution-NonCommercial-ShareAlike (see
AddOn Studio Wiki:Copyrights
for details).
Submissions must be written by you, or copied from a public domain or similar free resource (see
AddOn Studio Wiki:Copyrights
for details).
Cancel
Editing help
(opens in new window)