| 
  • If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Whenever you search in PBworks, Dokkio Sidebar (from the makers of PBworks) will run the same search in your Drive, Dropbox, OneDrive, Gmail, and Slack. Now you can find what you're looking for wherever it lives. Try Dokkio Sidebar for free.

View
 

Script Editing Tips

This version was saved 13 years, 8 months ago View current version     Page history
Saved by Bill Maya
on March 7, 2009 at 7:58:10 am
 

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 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 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 before opening a menu. Example:

 

Existing Script:

    BSum of:

        Fearful_Angry of:

             Joe

        0.50

 

Select the Operator BSum, then hold down Option 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

 

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.)

 

Next Tutorial: Scriptalyzer

Previous Tutorial: Spying

 


Creative Commons License  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.