Writing macros, a series of lessons (7 of…)

Today, ladies and gentlemen and others, we dip our toes in the pool of scripting.

WAIT! COME BACK! I promise it won’t hurt. Heck, I promise to share my recipe for chocolate Cheesecake cups …

oh. my. what attentive, HUNGRY looks. ummm, I’ll just share that recipe first, ok? Yes, ummm….

Oven preheated to 300 degrees F

Pans: 6-cup cupcake/muffin tin; cake pan large enough to hold the other pan

Other: 2 cup bowl or measuring cup, microwave safe. 2 qt (or larger) bowl plus electric beaters (unless you need to work out aggression – then just plan on beating a long time with a spoon or whisk.) Six paper cupcake cups. And a pitcher of water. Oh – a spatula and a spoon. Or two spoons if you don’t have a spatula. Ummm, and a small towel or washcloth.


1/2 package of graham crackers, crushed into crumbs
4 oz butter, melted

8 oz neufchatel (or cream) cheese.
1/3 cup sugar
1 egg
1/3 bag ( size 8-10 oz, so that’s approximately 3 ounces) chocolate chips (semisweet or dark, your preference)

Put the paper cupcake cups into the cupcake pan.

Mix the shell ingredients thoroughly, and divide equally between the cups. Press on bottom and sides so as to form an inner cup – tamp firmly. Bake for 10 minutes, remove from oven and set aside.

Reduce heat to 250 degrees F

Put cheese into bowl. Add sugar and cream it. (For you non-cooks, just work it all together using a lower speed on your blender till it’s smooth.) Add the egg, and mix thoroughly.

Now put the chocolate chips into your smaller bowl/measuring cup, and melt it in the microwave. That means: 10 seconds, stir, 10 seconds, stir… till it’s melted. Beats the heck out of a double boiler. Where was I…

Temper the chocoloate and return to the batter. (Again, for you non-cooks. Add two or three large spoons full of batter to the chocolate and stir, then put this back in the main bowl. This will allow the chocolate to get stirred into the batter with re-solidifying into chunks OR cooking little chunks of batter too early.) Stir thoroughly.

Divide the batter between the cups. (That means pour equal amounts into each cup. Each is going to end up half to 2/3 full.)

Put your small towel or washcloth into the cake pan. Put the cupcake pan into the cake pan next. Put the pan into the oven, and then pour water from the pitcher into the cake pan, being careful not to pour any into the batter. You want to add enough that it comes up about equal to the height of the batter in the cups. This needs explanation, bear with me…

What you’re doing is a trick to help your batter cook evenly. The water forms a thermal blanket for the batter – the towel is allowing the blanket to be under as well as beside the batter.

Bake for 20 minutes. Turn off oven and set timer for another 30 minutes. THEN remove pans from oven. (HINT: remove cupcake pan from cakepan instead of trying to carry both at once. This will prevent hot water splashing you or the cakes.) You can eat it now, or you can move the individual cups to the refrigerator – depends on your willpower, I suppose.

Two minor variations.  1) beat the batter on high for 3-5 minutes and it’ll add air which will make your cheesecake less dense.  2) Use sour cream instead of chocolate.  If doing this, cheat — put a tablespoon of preserves (of your preference) in the bottom of each cup before baking the cups – the heat will also melt this so it’s an even layer.

Go ahead. Cook, eat, I’ll wait…

There. Now you’re bribed, er, calmed, er… yes. (grin) Seriously, consider that a gift.  Now we’re going to look at scripting. But today it’s only an introduction. Just like macros, if we take it in little bits your head won’t explode. And just like macros, we’re going to start by talking ABOUT it instead of actually DOING it.

Let’s begin by answering the Question of Dread – “Isn’t scripting Programming?”

The blunt answer is yes. (heh – I can hear the Real Programmers ™ screaming from here.) The more complete answer is “Yes, sort of.  So is writing a macro.” (And that popping sound you’re now hearing is the heads of the Real Programmers ™ exploding.) Sorry, I couldn’t resist – especially as it’s true.

Here’s the deal. A program is a set of instructions to tell the computer to do something. The classic introductory program for just about every computer is the hello world program. OK:

/s Hello world.

There, so much for the Real Programmers ™. And more importantly, for you. We’ve been programming for six lessons now. All we’re doing with scripting is digging a little deeper. Which brings the next question – not so much dread this time, but important nonetheless.

What’s the difference between macros and scripting, then? Using an analogy, using the macro language (a better phraseology) is programming with training wheels. There are some safeties and restrictions that help you do things, but without quite so many bloody noses and skinned knees (or exploding brains…)

OK, then… is there a difference between writing a script (notice the change in terminology – same thing, but cleaner for understanding) and writing a program? Yes, but only sort of. Now, the following differentiation is only applicable to World of Warcraft, because in other computer venues the answer is usually “no.” In WoW, there are two aspects that differentiate a script from a program (which is, in WoW, pretty much always an addon.) First, the script is limited to 255 characters. (er, with the recognition that we can still sneak in a /click – see the previous lesson.) Second, the script is loaded on demand while the addon is – at least partially – preloaded. To make that more clear… The script, like the macro, doesn’t run at all unless you say “Run This” (by clicking the icon/button). The addon runs all the time – at a minimum there’s a portion running that monitors, and loads the rest when you call for it.

sigh – the preceding is not quite true. See, not so long ago Blizzard ‘nerfed’ scripting, making a third difference. Basically, there are things you can do if you bring it in as an addon which you cannot do from a script. In that way, then, scripting and programming addons are also not the same. The good news, however, is that this means we really are still working our way upwards. We don’t have to learn about the various requirements of an addon, and it reduces how much stuff buries us.

There are actually a few more things about addons that we might get into – depends on whether I can keep up with you all. But that’s a ways beyond where we all are right now, so just like we’ve done before, know it’s there and ignore it for now. For now, there’s only one common element between the two of which we need to be aware.

All user programming for WoW, other than macros, is done in Lua. (Lua? Wha….?)

Go back to the first couple of lessons. Remember how we discussed how with macros you could only use certain words, and how they had to be in a particular order (syntax)? Well, all a programming language is, is a list of words and a syntax. A bunch of words and the order(s) in which they can be put together so the computer does what you want it to do. Yep, back to washing hands. (See the earlier lessons if you missed that callback.) Now, macros were really, really close to plain english. Lua – like most programming languages – can get convoluted enough it appears to be Greek. Or Russian or Mandarin or some language of which your knowledge is absolutely zero. Because of that, we’re going to go REAL SLOW. Remember, I want brains expanded, not exploded (setting aside the fun of watching Real Programmer(tm) explosions).

So all we’re going to do to finish today is the simplest possible exercise – how do I get my script to run? You have two choices: /script, and /run. Since /run is three characters shorter than /script, guess which one I recommend? (grin).

Seriously… you can — in many ways WILL — fit a script into a macro.  You can also write one on the fly.  (I won’t, thank you very much.)  It’s just one more line – with all the rules of independent lines and other macro rules still applying. In fact, you’re going to find several things you already know showing up. I’m sneaky that way – and it helps that macros are scripts with training wheels.

Now, I’m getting close to the end of today’s lesson, but have a couple more points to bring up.  First and most important, it’s worth remembering that sometimes using a script is doing things the hard way. Remember you’re missing a bunch of assumptions – the training wheels. And to get the effect under some circumstances you can work HARDER to pull off the same trick – like staying upright while not moving forward. To demonstrate this… remember the first macro I demonstrated – near the top of lesson two?


Here’s a script based macro to do the same thing.

/run DoEmote(“oom”)

Yes, I can make it even longer. But I think it shows the point – sometimes the heavy tools are not the best choice. (Sometimes they are, or we wouldn’t be doing this. We’ll be coming back to the previous lesson’s long macro as a case in point. Just not today.)

I want to emphasize my last point for the day. Scripting – using Lua – is harder than ‘just’ macros. But it’s a tradeoff. It’s harder because it lets you do more things.  The more choices you have, the more you can do. The more you can do, the more confusing it can be. Just remember — you went from level 1 to whatever level you are now (for most, level 70). Level 1 was easy. Level XX is, well, harder, because you’ve got a HECK of a lot more spells and talents and other skills in your inventory. But you’ve got it in hand, right? This, too, will fall into your grasp. You just have to nibble off what you can handle, learn it, and then nibble a bit more.

Go have fun. And don’t eat all the cheesecake at once.


~ by Kirk on December 12, 2007.

One Response to “Writing macros, a series of lessons (7 of…)”

  1. […] Writing macros, a series of lessons (7 of…) « Priestly Endeavors – a WoW Blog […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: