[etoys-dev] Re: Fwd: How can I tell if a Scripting Tile is moved into a script?

Yoshiki Ohshima yoshiki at vpri.org
Tue Jan 19 22:08:31 EST 2010

At Tue, 19 Jan 2010 15:11:19 -0500,
Steve Thomas wrote:
> Stephen wrote: 
> >>
> >> Folks,
> >>
> >> I am working on a Etoys Tutorial similar to Etoys Challange and I want to be able to detect if certain tiles were
> used
> >>(or not used), so that I can provide "pop up" hints to users.
> >>
> >> I tried creating a script on a "Scripting Tile Holder", but as soon as I move the "Scripting Tile Holder" the script
> >> disappears (literally, off the screen and it is removed from the object).
> >>
> >> To recreate: Open Etoys Challenge, then create a script for one the Scripting Tiles (ex:Car forward by 10), then move
> >> the Scripting Tile with you mouse and the script disappears.
> >>
> >> Another possible solution would be to somehow use reflection to see what is in a particular script, but I would need
> >> help in figuring out how to do that.
> Yoshiki responded:
> > I think this is a tricky one. As you found out, Scripting Tile
> >Holder is transient. As soon as you pick it up, the green fringe
> >around the tile goes away; it means that the Scripting Tile Holder for
> >that tile goes away along with the scripts and tiles. One may think
> >that the Phrase Tile (inside the Scripting Tile Holder) may retain the
> >identity, but once it is dropped into a scriptor, it results in a copy
> >of original and also loses scripts.
> >
> > - One approach is to look at the scriptor and visit recursively the
> > tree structure of tiles in there and found out what kind of
> > commands (and Test) are used. If you want to go this way, I or
> > somebody should be able to provide a short code snippet that does
> > it.
> >
> > - Another approach would be to make the playfield that contains these
> > phrases intelligent, and whenever a phrase is taken out from it, it
> > assumes that it is "used". (Not perfect because it may be just moved
> > to the world). Again, if you want to go this way, I or somebody should
> > be able to provide a short code snippet that looks at the elements
> > in the playfield and tells you what kind of tiles inside.
> >
> >I would guess that the first approach would be more "faithful" in
> >guiding the user, but still there is a mechanism to compare the
> >current situation and the goal and decide what kind of information to
> >provide to the user...
> >
> >-- Yoshiki
> Yes I would definitely prefer the more "faithful" solution.
> If you would be kind enough to provide the code snippet (preferably inside an Etoys Challenge project so I can see how
> it works) I will work on learning squeak enough to modify it for my needs and work on the mechanism's to compare current
> to goal and provide the information based on results and timing.

  I created a "proof of concept" version and uploaded it to:


and also squeakland.org showcase.

What I did was:

   - Wrote a little bit of code so that readable text representation
     of phrases in a script can be obtained.  (This only handles
     phrases with no complex expression as the argument, and Test
     tile).  Add variables called currentScriptor and result to the
     world.  "forward by: 10" is rendered as "forward:10" and "turn by
     -10" is rendered as "turn:-10".

   - Add a couple of Etoys scripts that take the text representation
     and see if the specified condition is met.  One of such scripts
     is "includesInCurrentScriptor:", which checks if the tile given
     as its argument is in the currentScriptor.  The other one is
     "includesInCurrentScriptorTrueClause:", which checks if the tile
     specified by the argument is in the Yes part of Test.  (You can
     think of more variations but this is a start.)

   - Attach some scripts to the page objects for "step 1" and "step
     2".  The "step1Setup" script for example sets up the
     currentScriptor variable of the world, and start ticking
     "checkstep1" script.

   - The checkstep1 script for example checks if "forward:10" is in
     the Yes part of a test tile.  The result is stored in the
     "result" variable of world so you can see it.

   - When you flip the page to "step 2", proper test script will be

You probably need a bit more elaborated checks for giving meaningful
feedback to the user...  You would want to have a script that checks
the condition part of a test and yes part for example (I'm happy to
write it if you need).  But I hope this illustrates the concept.

-- Yoshiki

More information about the etoys-dev mailing list