Here are detailed descriptions of some of the editing conveniences we provide.
Cut, copy, and paste
All of the regular cut, copy, and paste tools work inside Scripts. When you use them, they act on the selected Operator and all its arguments. Thus, you can move big chunks of script around with cut and past. Here's an example. Suppose that you realize that you need to reverse the order of subtraction in this Script:
BDifference of:
Blend of:
Nasty_Nice of:
ThisSubject
Nasty_Nice of:
ThisDirObject
0.0
0.5
so that the 0.5 is on top and the Blend is on the bottom. To do this, simply select the Blend Operator, cut, select the 0.5 Operator, and paste. Lastly, enter the 0.5 value in the upper slot.
Outsertion
If you select an Operator in a Script and hold down the Control key (Ctrl key on Windows) while choosing a new Operator from a Menu, that new Operator will be "outserted"—placed above the selected Operator. Here's an example.
Existing Script:
BSum of:
Fearful_Angry of:
Joe
0.5
Select Operator "BSum," then click on "BSum of:" and hold down the Control key (Ctrl key on Windows) while opening the Arithmetic menu. Select menu item "BInverse" and get this result:
BInverse of:
BSum of:
Fearful_Angry of:
Joe
0.5
You'll use outsertion quite often in your daily scripting work.
Replacement:
You can replace one Operator with another by holding down the Option key (Alt key on Windows) before opening a menu. Example:
Existing Script:
BSum of:
Fearful_Angry of:
Joe
0.50
Select the Operator BSum, then hold down the Option key (Alt key on Windows) and open Arithmetic menu, selecting "BDifference." Get new Script:
BDifference of:
Fearful_Angry of:
Joe
0.50
What's especially nice about this trick is that it preservers the arguments of the original Operator. If you used the direct route, you'd have to erase those internal arguments. This way, you don't erase them. There is a catch, however. You can't just replace any Operator with any other Operator. The only Operators that will be available for you to select are those whose argument types match the argument types of the original Operator.
This capability extends even to Operators with fewer or more than the number of arguments of the original Operator. For example, if you replace AND3 with AND4, the new AND4 will contain the previous three boolean arguments and add a fourth, undefined boolean Operator at the end. If you go in the other direction, replacing AND4 with AND3, then the last boolean argument will be deleted.
Collapsing a Script
Suppose you have this Script:
AND
AreSameActor of:
ThisSubject
ReactingActor
NOT
AreSameActor of:
ThisDirObject
CandidateActor
And you want to get rid of the first "AreSameActor" term. Just click on the NOT Operator, Copy, click on AND, and Paste. Now it reads:
NOT
AreSameActor of:
ThisDirObject
CandidateActor
Commenting Script Nodes
As your scripts become more complex and deeply nested, it is possible to add comments to individual nodes of a script so when you revisit them weeks or months later you'll have an idea what they do without having to trace
Let's say you're working on an Acceptable script for the direct object (DirObject) of a verb Greet.

This Acceptable script for the Greet verb will populate the DirObject (3Actor) wordsocket with the CandidateActors who fulfill all following criteria:
1. The CandidateActor must not be the Subject.

2. The CandidateActor must be at the same location as the Subject of the Verb.

To comment a node, select the node you wish to comment and press the Enter key (this key might be marked "Return" on some computers). A text field will appear above the selected node where you can type a brief comment to remind you what that particular piece of script is designed to accomplish. When you have finished entering your comment, press the Enter or Return key again to complete your editing.

Once you've entered comments you can collapse the node on those comments to make scripts more readable.

Right-clicking
If you select an Operator and click on the right button on your mouse, then you'll see a long menu pop up next to the selected Operator, containing every single Operator that you could enter in its stead. Some of those Operators are placed inside submenus. (Mac users, you can reach the right-click/context-sensitive menu by holding down the Control key when clicking on the Operator. But the right-click is so heavily used by Swat that you really should buy a two-button mouse, such as the Apple Mighty Mouse.)
Note: You can also call up this popup menu by tapping the Spacebar.
Next Tutorial: Scriptalyzer
Previous Tutorial: Spying
This tutorial by Storytron, Inc. is licensed under a Creative Commons Attribution-Noncommercial-Share Alike 3.0 United States License.
Comments (0)
You don't have permission to comment on this page.