Squeak
  links to this page:    
View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide
Getting Started with E-Toys / User Scripting
Last updated at 12:23 pm UTC on 17 January 2006
User Scripting or "E-Toys" is a powerful and simple visual scripting system built into Squeak. Scripts can be created using drag and drop for any Morphic object.

There are two ways to create a new Morph: it can be drawn or created directly from code. Lets start with a drawing.

Drawing a Morph


An even easier way to create a painting area is to click on the "Widgets" flap (bottom of screen) and drag out the painting icon.

When you are painting your morph, keep in mind that you have the entire painting canvas to make your morph on. Whatever is on the canvas will become your morph even if there are painted areas that don't touch!!

If your morph is not quite the way you want it after you clicked "Keep", you can edit it with the "repaint" option. To edit your morph:

You will now have an active paint tool to edit your morph with.

You may have also noticed several other options in the "painting" menu such as "rotational center". With "rotational center" you can set the center of rotation for your morph. The interesting part about this is that the "center" does not have to be on the area that you painted. It can be placed anywhere in the painting area !!!

Now that you have created the Morph object, we will need to open a viewer to start scripting it.

Opening a Viewer for your Morph Object


The viewer will now appear on the right side of the screen. On the top left corner of the viewer you will notice a small square with a picture of your morph in it. This is the Viewer tab. Clicking this tab will hide and unhide the viewer.

The top of the viewer has three icons and the name of the Morph. The top, left most icon, the "O", will close the viewer. The other "O"s will close their respective category. the next icon over that looks like miniature lines of text, will add another category pane to the viewer. The menu icon will display a menu with several options. The most important of which is "add a new instance variable". This menu option is the fastest way to add a new variable to your morph script. We will add an instance variable later on. Finally, the name of the morph object is displayed. The name of the Object can be changed simply by clicking the name twice to place a cursor and then typing the new name. You can confirm this by right clicking the object to get its halo. At the botoom of the halo will be the object's new name. You will also notice every line in the viewer now reflects the name change.

Missing File (/squeak/uploads/viewer.jpg)

The first pane from the top is the "search" pane. It allows you to find any word in any of the category panes whether the pane is visible or not (more on that later). Let's give it a try.
Two new lines will appear which are from the Geometry category.
 
The remainder of the viewer consists of category panes. These panes can be closed by clicking it's "O" icon. It's category can be changed by clicking the up/down triangles or by clicking the category name and choosing a new one from the list. The remainder of the category panes are filled with commands.

Let's create a new script and start using some commands !

There are two ways to create a new script.

OR


Click and drag any command from any category to the desktop. Commands need to be dragged from the middle (eg. click on "make sound" or "forward by") to pick them up.

A "scripts" category pane will appear in the viewer and your script window will appear on the desktop. 

More to come !!!