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

Offray Vladimir Luna Cárdenas offray.luna at javeriana.edu.co
Mon Nov 13 10:18:04 PST 2006


Hi Scott :),

Thanks for your help again. What you're providing me is pretty close to 
what me and my students are looking for. Because my lack of knowledge of 
the Smalltalk code I'm trying to understand the textual script. I see 
that in that script, there is not switch from tile mode to code/text 
mode, only the last one is enabled. There is some special way to add 
this scripts? If I try, for example to use the visor of a Star I always 
can switch from tile to code modes, but coming back to tile, always 
makes the changes in text mode to get loosed  (not saved).

Here is your script:

Script Editor

and here is my "literate" explanation (probably is wrong):

----

chooseMessageTarget "the name of the script"

  "Choose a player as target for a message" "<- comment with the 
explanation"
  | aMorph | "<- some kind of local variable"
  aMorph := self costume chooseClickTarget. "<- this part changes the 
mouse pointer of the world from arrow to cross-hair"

"The following part gives a message to self to set message target, if a 
not nil morph is chosen then the selected morph is assigned to aMorph 
variable, if is Nil, I'm not pretty sure what's happening"

    self setMessageTarget: (aMorph
        ifNil: [ActiveWorld presenter standardPlayer]
        ifNotNil: [aMorph assuredPlayer])

-----

I'm seeing that the world is "holding its breath" until a morph is 
chosen, and everything stops for a while until the target of the message 
has been choose. I image that this is related with the code "ifNil: 
[ActiveWorld presenter standardPlayer] ...". There is a way to keep the 
objects in the world moving, even with the message target still to be 
selected?

Cheers,

Offray

Scott Wallace escribió:
> Hi, again, Offray,
>
>> My students and me are working in a kind of basic pingus/lemmings
>> clone[1] using eToys. We would like to use the mouse pointer to select a
>> eToy and execute an script. The idea is to make click on a button, for
>> example the one with the message "Detener al otro" ("Stop the other")
>> and then select the eToy who would have this script enabled using the 
>> mouse.
>
> Perhaps you'll find the techniques illustrated in the attached project 
> useful for your purposes.
>
> In the project, all the star-lemmings (which are all siblings of one 
> another) understand the messages "makeRed", "makeBlue", 
> "startSpinning", and "stopSpinning", etc.
>
> When you click on any of the buttons at the bottom, the cursor changes 
> into a cross-hair, inviting you to choose a recipient for the button's 
> message.  After you click on one of the star-lemmings, the designated 
> message will be sent to the one you chose.
>
> Thus, click on "One Red", and when the cursor changes to a cross-hair, 
> click on a blue star-lemming, and it will be told to run its script 
> named "makeRed", which in turn will make it red.  And so on for all 
> four of the "One" buttons.
>
> The four buttons with "Others" in their names tell all of the 
> designated recipient's *siblings* to do the button's action, with the 
> result tht every lemming *except* the one you click on gets the 
> indicated message.  So the "One" buttons and the "Others" buttons are 
> kind of opposites of each other.
>
> Invoking the "cursor mode" for selecting the target is outside the 
> scope of etoy tiles, so this required a single tiny textual script, 
> named "chooseMessageTarget", which I wrote for the "world".  All the 
> other code in the project is strictly tile scripts.
>
> How close is this to what you're seeking?
>
> Cheers,
>
>  -- Scott
>
>


More information about the Squeakland mailing list