View this PageEdit this PageUploads to this PageVersions of this PageHomeRecent ChangesSearchHelp Guide

Tile Composition

Need to augment this exposition with nice pictures.

Need to reorganize, re-explain, in an easier way.

Scripts are just sequences of programming statements, each giving some basic instruction. (Statements can also be the name of other scripts, but we'll get to that more advanced concept later.) Many statements are there for the taking - right out of one of the panes in the viewer for an object. These are the statements with the exclamation mark. Also, assignment statements to variables (obtained by dragging the green/purple arrow) are readily available by dragging them out of viewer.

Sometimes though, we want to create an action that relates two different objects, and there is no pre-existing tile. For example, instead of "car turn by 5", we want "car turn by joystick's leftRight". In that case, we dragged the tile for "joystick's leftRight" and replaced the "5" in the statement "car turn by 5".

A lot of squeak programming is done this way... by replacing parts of statements with other parts. It will be helpful to understand the anatomy of a typical programming statement:

"object - action - value "

This tells the object ot take an action, and (optionally) the given value modifies the action in some way, or gives further instruction (like how much, etc.) Think of object as the noun, or subject, of the sentence. action is the verb, and value, if present, is the adverb.

"car turn by 5" has "car" as the object, "turn by" as the action, and "5" as the value.

Of these pieces (object, action, value) the object and value can be replaced with any other corresponding tiles of the same type. Thus, if we have "car turn by 5", we can replace "car" with "boat" if we had a boat object. We get the tile "boat" from the orange icon in the halo of the boat. Or, we could create "car turn by random 180" by obtaining a random number tile from the small menu icon in any script-header for a car script. The "random 180" is a value tile, and can drop in place of the "5". Similarly, "car's x" is a value tile, and if we wanted to, for some reason, we could create "car turn by car's x". Or "car turn by wheel's heading", which is part of the drive a car tutorial. We can't easily change "car turn by 5" to "car forward by 5". It is useful to think of the verb, or action tile, as being identified with the statment. If we want something to go forward, we should go fetch a foward statement.

In assignment statements, the "object" is really a variable owned by the object, or property of the object, such as "car's x - 57". Here, the object is actually "car's x", and is a compound tile, made up of two pieces: the owner of the object (the car), and the object itself (the "x" coordinate). In such cases

For now, it will be helpful when composing tiles to think of the three roles for the tile pieces:

  • object what is the object in the statement? This is the thing that will have some behavior.
  • action what is the action to be taken? forward, turn, or an assignment statement
  • value what is the amount to move, turn, or sound to make, or color to change to.

When you script, first choose an statment, then modify the object if necessary, and the amount, if necessary. Often it is easiest to go to the object that you want to perform the action, find the action tile for it, and then modify the value as appropriate.


Link to this Page