View Single Post
02-25-06, 12:18 AM   #14
Cairenn
Credendo Vides
 
Cairenn's Avatar
Premium Member
WoWInterface Admin
Join Date: Mar 2004
Posts: 7,134
Section 11 – How? (How do I use?)

Q: How do I create a macro? (Credit Trimble)

A: In a chat box, start by typing /macro. then click NEW, give it a name and an icon, and then start entering some commands.


Q: What is the best way to know the exact spelling of a spell to cast? (Credit Trimble)

A: 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.


Q: How can I make a conditional macro? (Credit Trimble)

A: 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:

/script if UnitName('target') == 'fred' then CastSpellByName('Healing Touch(Rank 1)') end

Note the use of "end" at the end. it's important to Lua.

Also, note that when using Lua code, you can't use /cast to cast a spell - you have to use the CastSpellByName() "function". Luckily, CastSpellByName accepts the exact spelling of the spellname given to you by the shift-click method I mentioned above (remember, you can cut and paste after using the shift-click trick). Additionally, there is another function called CastSpell(), but you must know the SPELL NUMBER to use it.

Also notice the part that says 'target'. this is a placeholder that WoW uses to represent whatever your target it. It's a kind of variable, but it isn't a Lua variable. Other placeholders are 'player', meaning yourself (no matter what your name is), 'party1' through 'party4' meaning your groupmates, and 'pet' which means your pet. MANY wow Lua functions accept these placeholders as arguments, but they are NOT Lua variables - they are more like literals to Lua. This means that while UnitName('player') is valid, UnitName(player) is not valid unless you created a Lua variable called player and did a statement like this player = 'player' to make it contain a valid placeholder value.


Q: When using Lua script code, do I need to end each line with a semicolon? (Credit Trimble)

A: 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


Q: Can I make a conditional macro that does something if I have a certain buff? (Credit Trimble)

A: It's possible, but WoW's UI doesn't come with a simple function to check for a buff. There are ways to do it, but it's tricky. The best way is to use an addon that provides this function and then use it in your macros.

NOTE: Do a search on curse-gaming.com for the IsBuffActive AddOn; this will provide you with an extremely simple method of checking for buffs on yourself or others.


Q: How do I output text to the chat window?

A: use DEFAULT_CHAT_FRAME:AddMessage(msg,r,g,b)

This is easier if you alias it something like:

cprint = DEFAULT_CHAT_FRAME:AddMessage

then you can use cprint("foo",1,0,0) or the like.

where msg is the text, r,g,b are red,green,blue (0-1) and a is alpha (0-1)


Q: Is it possible to use multiple abilities in one macro, such as cast Corruption, Curse of Agony, and then Shadowbolt? (Credit Skrag)

A: 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 recast timer, which is somewhere in the neighborhood of one second, I believe, and you cannot cast another spell until this timer is done. So, without the ability to wait in a macro, it is impossible to cast multiple spells. Also, spells can only be cast when the player presses a key or clicks their mouse, 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, to install an AddOn which automatically changes an action button to cast different spells in a user-specified list. So the first time you press the action button, you would cast Corruption; press it again, and you’d cast Curse of Agony; a third time would cast Shadowbolt. Danboo’s CastAway AddOn is a good example of an AddOn designed to do this very thing.


Q: How do I set up a macro or script to automatically cast XXX when... (Credit Skrag)

A: 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. You can attempt to call CastSpellByName after a certain amount of time, but the spell will not be cast.

NOTE: There are some AddOns that make self-rebuffing much easier to the point of being almost automated.
  Reply With Quote