To get the most from these tutorials, follow the instructions on downloading SWAT and joining the Authors' Guild before you begin. 

You can think about Operators in terms of language. Consider this sentence:

"The farmer gave the dog that saved the life of his son a big slab of meat from the pig he had just slaughtered."

OK, it's a clumsy sentence with too many subsidiary components; a good writer would break it down into several sentences. But it breaks down into words in exactly the same way that a Script breaks down into Operators:

     who: The farmer
     to whom: the dog
          that saved
               what: the life
               of whom: his son
     what: the slab
          of meat
               from the pig
                       that slaughtered
                         who: he
                         when: had just

Granted, this is a rather odd way of breaking apart a sentence, but its utility arises from its defining the components of the sentence in a precise fashion. And when you're talking to computers, you have to be precise.

This nesting capability of language gives it the power to express any idea, no matter how complex. And the scripting language of Storytronics uses exactly the same nesting concept for its Operators.

Operator Types

An Operator produces a value: a number, a Prop, an Actor, etc. There are three types of Operators:
  • Getters
  • Setters
  • Crunchers

Getters are simple: they simply look up a stored value and return it. Here is an example of a Getter:

Owner of:

When you use the Operator Owner of in a script, SWAT gets the name of the Actor who owns the prop that has just been used in ThisEvent, and plugs it into that slot in the script.

Setters store a new value into a variable. They are represented by Script Buttons. The
Verb's Consequences, AssumeRoleIf, EmotionalReaction, WordSocket, and Inclination scripts are all Setters. The way you can recognize a Setter is by the bent corner on the button.

Crunchers perform some calculation using the values you feed them. Here is an example of a Cruncher:

BSum of:
     Quiet_Chatty of:
     Fear_Anger of:

The Operator BSum takes the number representing how talkative ReactingActor is (that is, her Quiet_Chatty value), and adds to it the value representing how fearful or angry she is. This Operator might be used to determine how likely an Actor is to speak her mind in a confrontation, for instance. The more angry she is, and/or the more outspoken she is, the more likely she will be to argue or confront.

Nesting of Operators

Many Operators have arguments. "Arguments" is just a fancy name for subsidiary Operators that provide further specifics on what the Operator is required to do. Some Operators have just one argument, like these:

Quiet_Chatty of:                           how loquacious ReactingActor is

(We indicate nesting by insetting the argument.)

Other Operators have two arguments, like these:

PQuiet_Chatty of:                   how loquacious ThisSubject perceives ThisDirObject to be

Here's an example of nesting arguments:

Quiet_Chatty of:
     Owner of:

Some Operators have no arguments at all; here are a few:

BNumberConstant  (a number like 0.0 or 0.5)
ThisSubject   (the Subject of the Event that just happened)
ReactingActor (the Actor reacting to the Event that just happened)

Previous tutorial (Group 2):  Lizards                                                                        Next tutorial:  Special Operators