[Squeakland] Making a Copy of an eToy from a script and using the mouse pointer to activate an eToy script

Scott Wallace scott.wallace at squeakland.org
Fri Nov 10 02:42:07 PST 2006

Hi, Offray,

> We are also stuck on how to make copies on an eToy, so we work only on
> one, defining scripts, and animations and the we put the amount we  
> want
> in the game. We know about the green halo button for copy, but we  
> would
> like to use not graphically but from inside of a script. We have tried
> to use the message eToyName's copy but it can't be dragged on a  
> script.
> The animations defined for the first eToy are not copied when we  
> copy it.

When you execute "Car's copy", the result will be the creation of a  
copy of Car (strictly speaking a "sibling", viz. a fellow instance of  
the same class as Car.)

However, if you don't *place* that copy somewhere, you won't see it.   
The standard idiom for placing an object somewhere via script is to  
tell the *container* in which you place it to "include" it.

Here's a typical usage pattern:

-------------- next part --------------
A non-text attachment was scrubbed...
Name: unknown.png
Type: image/png
Size: 27055 bytes
Desc: not available
Url : http://squeakland.org/pipermail/squeakland/attachments/20061110/b0812a88/unknown-0001.png
-------------- next part --------------


> Pdt: It seems that we're reaching some kind of stress point of the
> eToys. Would be nice to have the possibility to go from them to their
> code, but the scripts of the eToys seem to have only a code view,  
> but is
> not usable for writing new code.

Hmm, well, etoy objects are first-class Smalltalk objects, and etoy  
scripts are real, first-class Smalltalk methods, belonging to real,  
first-class Smalltalk classes, and if you switch any script's  
Scriptor to textual mode (by clicking on the checkbox in the  
Scriptor's header,) you can enter any Smalltalk code you wish there.

A plausible practice is to use tile scripting for everything in a  
project that *can* be readily done using tile scripts, then to  
supplement this with conventional Smalltalk code in one or two places  
where necessary.

Textual coding can actually be done using two kinds of scripts:

First, as mentioned above, you can write textual code for any  
existing "etoy script" that you see in a Viewer by switching its  
Scriptor to textual mode via the checkbox.

Secondly [and this is not so well known] you can open a conventional  
Smalltalk browser on the class of an etoy "object", and using that  
Browser you can not only see and edit the etoy scripts, you can also  
add any other methods you wish, including methods with multiple  
arguments (whereas etoy scripts are limited to 0 or 1 argument,) mid- 
method returns, and many other things that you can't directly obtain  
using tiles alone.  To get such a Browser, in the Viewer's menu  
choose "more..." and from the auxiliary menu that pops up, choose  
"browse class."

I'm not claiming that this is the ideal way to transition from e-toy  
tile-scripting to full-scale Smalltalk, if that's what your goal is  
-- indeed, it may lead to false expectations; I just wanted to make  
sure you're aware of the availability of these two ways of blending  
tile-scripting with writing unrestricted Smalltalk code.  It would be  
interesting to hear of experiences people have had with this kind of  
hybrid approach.


  -- Scott

More information about the Squeakland mailing list