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!
=== 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";
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)