The Script Editor

Now that you have explored the beginnings of object creation and manipulation, the next step is programming. MAXScript is a programming language at heart, and two of the most important concepts necessary for mastering MAXScript are conditional statements and loops.

At this point, real script writing comes into play. From the Utilities command panel, click on the "New Script" button. This opens a new MAXScript editor window where you can create, save, and open scripts.

Thus far in this tutorial, you have been performing all of the script examples in the MAXScript Listener, however when you are writing or editing a script of your own, you will use the Script editor.

The main difference between the Script Editor and the Listener is that the Listener can only evaluate one set of information at a time. However, you can enter long, complex scripts in the Script Editor and evaluate them piece-by-piece or all at once.

Scripts are entered using the same syntax and rules, however they are not executed upon pressing ENTER. In order to execute the entire script, use "Evaluate All" from the File Menu, or press CTRL+E. You can also execute scripts several lines at a time by highlighting the lines you want to execute and pressing SHIFT+ENTER, or ENTER on the numeric keypad.

Navigating the Script Editor

The Script editor contains several useful tools for navigating and error-checking large scripts.

Tabs

You can use the TAB key to create blocks in your script. This makes it easier to read the script and to keep track of parentheses, which you use to create blocks of commands.

CTRL-Right Click Navigation

When you press CTRL+Right-click, a menu is displayed which allows you to jump to any specific event or UI item in the script.

Bracket Balance

In complex scripts, it is common to lose track of blocks of commands, causing you to add extra parentheses or leave them out. You can find these errors by pressing CTRL+B. MAXScript will highlight the block that your cursor is on, showing you the start and end parentheses.

Color Coding

You can tell MAXScript to display different elements of your script in different colors, making it easier for you to navigate your script at a glance. When you press CTRL+D, MAXScript will color-code your script in the following manner:

Comments û Green

Events (such as on, if, or while) û Blue

Text strings û Dark Red

The rest of the script remains black.

Note: Color-coding does not update automatically. As you add to or change a script, you will need to press CTRL+D again to update the color-coding.

Next Topic

Controlling Program Flow in Scripts