Monday, June 11, 2007

I sure am lazy

This article might be helpful for aspiring game writers such as myself:

You need to learn how to script.

I don't mean script like Hollywood, or even script like cursive. I mean script like "If A=True, then Begin B." It's pretty straightforward, actually, but most people have no idea how to do this. A good way to practice (if you're a student, especially) is to get your mind wrapped around the TI-83 calculator that you likely had to buy for a math class you hated. The TI-83 is DESIGNED to function off of conditional equations. Here's a good practice one for you folks at home -- it's a basic menu selection (I'll explain in a second):

:: ClrHome
:: Lbl X
:: Menu("How Awesome Am I?","Very",A,"Super",B)

#1. At this point in the program, you've only told the calculator to do two things. First, with the ClrHome command, you told it to clear the display. Pretty simple, right?
#2. Next, you assigned a label to this point in the program so that you can get back there with ease. In this case, the label is "X." If I ever want the program to revert to this point, I would command "Goto X," and the program would revert to this point.
#3. Finally, I told the program to create a menu. The menu will ask "How awesome am I?" and offer two choices: Very, and Super (yes, I'm conceited). At this point, the result of a selection has not yet been determined, so selecting either answer does nothing. But let's continue...

:: ClrHome
:: Lbl X
:: Menu("How Awesome Am I?","Very",A,"Super",B)
::
:: ClrHome
:: Lbl A
:: Disp "Good Answer!"
:: Pause
:: Goto X

So now things get a little trickier. As you can see, I cleared the screen again after you make your menu choice (no sense in that hogging up the screen!). Next, I established a label for A. The "Lbl A" signifies that this is where the code will start once the "A" answer, or "Very" is selected. Next, I have used the DISP command to display the text "Good Answer!" In order to keep that text visible, I have added the PAUSE command, which will keep the text visible until the user presses ENTER on the calculator. Finally, I added "Goto X" to send the program back to the menu after the selection is made.

So let's finish this sucker, shall we?

:: ClrHome
:: Lbl X
:: Menu("How Awesome Am I?","Very",A,"Super",B)
::
:: ClrHome
:: Lbl A
:: Disp "Good Answer!"
:: Pause
:: Goto X
::
:: Lbl B
:: ClrHome
:: Disp "Jeff Sure Is The","Shit, Right?"

As from before, I'm applying a label to the "B" answer, or "Super." I've added a ClrHome here just in case you DID select "A" earlier. Finally, I've displayed the message "Jeff Sure Is The Shit, Right?" but what's with that "," between The and Shit? Well, the answer is that the calculator can only hold so many characters horizontally. The "," tells it to move to the next line before continuing the text, so that everything is visible. By not adding a "Goto" command or Pause command at the end of this DISP command, the program is finished, and will display a little "Done" at the bottom right of the screen at this point.

Congrats! Your first program is done!

So what does this have to do with games? Well, let's imagine that my job is to write quests (and, for ease, let's say that the scripting language is the same as the TI-83 language...even though I know it isn't).

So, here you are in World of Warcraft or some MMORPG like it, and you encounter an NPC (non-player character) who offers you quest options. The encounter could read:

:: ClrHome
:: Menu("Please, mister! I need money","for drugs! Can you help me?","Absolutely!",A,"Forget it, Kid!"B)
::
:: Lbl A
:: Disp "In a fit of rage, the child","takes your wallet!"
:: Pause
:: Run prgm LoseCash
::
:: Lbl B
:: Disp "The child thanks you profusely","and gets high.","YOU GAIN 50 EXP!"
:: Pause
:: Run prgm GainExp

In these examples, all I do is provide the inbetween text for an unusual interaction. The "run prgm" sections are animations and other interaction programming that I simply link to for the interaction to occur. Neat, right?

And no, I don't condone the use of drugs :-)