Writing macros, a series of lessons (1 of…)
I’d been playing my hunter alt (the Draenei Urtica, with his springpaw Lyallii. I liked the name better than Dioica.) quite a bit, recently, and so had a macro to hand to insert in comments when BBB asked a question. His response to that leads to today’s – and probably a few more days – post. I’m going to try to walk through the “how to write a macro” to the extent of helping you write your own as you need it.
Let’s begin by saying the Guru of Macros is Cogwheel. If you want to jump ahead, go to his (stickied) forum post, and from there go to his website. There are other extremely knowledgeable and readable writers on the subject, but he’s your starting point. A lot of what I’ll be saying over this series is rephrasing of things learned there.
Today is intro day, so: What is a macro? As Cogwheel says, “a macro is a slash command.” More fully, a macro is one or more slash commands, possibly with parameters (limiters of various types), set in such fashion that it can be bound to a key.
So, the next best thing would be to have a list of commands, right? Well, I’ve got bad news, and then I’ve got good news, and then I’ve got bad news. Bad news – there is no definitive list. Good news – you can create your own list (and I’ll tell you how in just a minute). Bad news – you only get the commands, you do not get the list of possible (or required) parameters.
How do you generate your own list? First, get pencil and paper – or open a word processor and be ready to do a lot of alt-tabbing (or if you’re one of those who has dual monitors, well, I’m officially jealous…). Now start the game and get on your character – in a place where you will not be interrupted. Ready? Open a chat window. Type /a. Tab. Write down the command. Tab. Write down the command. Tab. Write down the command. Repeat until you get the first item – which MIGHT BE /a, or might be something else. (I know, for example, that /c is a short-cut command that’s the same as /csay, which must be followed by a chatchannel name or number, and then followed by the text you want in that channel. But the game won’t TELL you that. See the frustration?) When you’ve cycled through /a’s, then do /b’s, /c’s, … all the way through /z’s. Don’t bother with numbers and symbols. Numbers are /csay shortcuts that jump directly to that channel. Symbols don’t do anything, so we can leave them alone. hmmm. More accurately, symbols do things, but there are no slashsymbol commands, so don’t bother cycling through them.
OK, we’re about done. A few more basic concepts and we’re off.
First – the max length of a macro is 255 characters – and spaces and carriage returns count. If you need more you need to write a script. And yes, I eventually intend to take us to scripts, but it’ll be in easy steps.
Second – a macro is a game interrupt. That means the game PAUSES until the macro is done.
This is one reason the perennial ‘I want a macro that’ll cast, wait out the GCD, and cast again’ will fail – the game clock (cooldown and everything else) stops while it waits for the macro to finish running. Two digressions here. Note that this is just the clock on YOUR computer – the server keeps right on going, mobs keep hitting you, etc., etc. And it’s HIGHLY unlikely Blizzard will ever ‘fix’ this as this goes a long way to denying bots. Bots – automated programs that play the game for you. There’s a fuzzy line behind comprehensive assistance addons and bots that you’ll run into if you advance deeply into scripting, but it’s of no concern while you’re just doing macros.
Third – Throughout this lesson I will be trying to make it clear when I’m talking of macros and when I’m actually giving you an example. For now, and subject to more clarification later, I’ll be using the blockquote and bold functions for the macros. So they’ll look like this:
/petattack [modifier:alt,nohelp,target=focus] \
Supplemental is the fact that line breaks matter to macros, but my blog makes long lines unreadable by shoving it off the right side and hiding a big chunk of that under the right column. So the backslash is a programmer shorthand for “continue the next line on this line”. In the above macro, this means the whole thing goes on one line – if you’re copying and pasting, just delete all the backslashes and any carriage returns that make it a multiple line macro.
Oh – one last remark. That macro is the one I posted on BBB’s comment that started this thing. It’s meant for hunters, but will also work for any class that has a pet out – demons, elementals, shadowfiends… See, I’m still a priest (grin).
Have fun, folks.