Etoys - create duplicate (not sibling) from a script?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Etoys - create duplicate (not sibling) from a script?

Mark Nelson-7
Hi,

>From an Etoys SCRIPT, how can I create a 'duplicate' of a player
(equivalent to clicking on the green halo icon), rather than creating
a 'sibling/clone' of a player (equivalent to SHIFT-clicking on the
green halo icon)?  The 'copy' tile available under the miscellaneous
category seems to create a clone; the textual equivalent of
''Playfield include Ellipse's copy' is 'self include: Ellipse
getNewClone'.   What I need is the textual equivalent that would
create a 'duplicate' rather than a 'clone'.

[Why do I care?  In the course that I'm currently teaching, we've
created a 'robot' with embedded 'sensors'  (the 'robots' and 'sensors'
are created from individual Ellipse morphs; the sensors then get
embedded in the robot). The robot's actions depend on differences
between left and right sensor values. If I now make a 'duplicate' of
the robot using the green halo icon, the new robot works as expected.
However, if I make a 'clone' of the robot (either by SHIFT-clicking
the green halo icon, or by using the 'copy' tile in a script, the new
robot seems to pick up the sensor values from the original robot,
rather than from its own sensors.]

Thanks in advance,
--Mark Nelson

_______________________________________________
Squeakland mailing list
[hidden email]
http://squeakland.org/mailman/listinfo/squeakland
Reply | Threaded
Open this post in threaded view
|

RE : Etoys - create duplicate (not sibling) from a script?

Dreyfuss Pierre-André (EDUM)
Hi,
you have to use do menu item tile in the category miscellanous and choose duplicate as item.

This seems create a copy in the hand.


If you want just create a new robot this will work. But there is no handle on the new created object this way.

however once dropped it can be designated as the first element of the morph containing it.




Regards


-------- Message d'origine--------
De: [hidden email] de la part de Mark Nelson
Date: mer. 30/01/2008 15:35
À: [hidden email]
Objet : [Squeakland] Etoys - create duplicate (not sibling) from a script?
 
Hi,

>From an Etoys SCRIPT, how can I create a 'duplicate' of a player
(equivalent to clicking on the green halo icon), rather than creating
a 'sibling/clone' of a player (equivalent to SHIFT-clicking on the
green halo icon)?  The 'copy' tile available under the miscellaneous
category seems to create a clone; the textual equivalent of
''Playfield include Ellipse's copy' is 'self include: Ellipse
getNewClone'.   What I need is the textual equivalent that would
create a 'duplicate' rather than a 'clone'.

[Why do I care?  In the course that I'm currently teaching, we've
created a 'robot' with embedded 'sensors'  (the 'robots' and 'sensors'
are created from individual Ellipse morphs; the sensors then get
embedded in the robot). The robot's actions depend on differences
between left and right sensor values. If I now make a 'duplicate' of
the robot using the green halo icon, the new robot works as expected.
However, if I make a 'clone' of the robot (either by SHIFT-clicking
the green halo icon, or by using the 'copy' tile in a script, the new
robot seems to pick up the sensor values from the original robot,
rather than from its own sensors.]

Thanks in advance,
--Mark Nelson

_______________________________________________
Squeakland mailing list
[hidden email]
http://squeakland.org/mailman/listinfo/squeakland


_______________________________________________
Squeakland mailing list
[hidden email]
http://squeakland.org/mailman/listinfo/squeakland
Reply | Threaded
Open this post in threaded view
|

Re: RE : Etoys - create duplicate (not sibling) from a script?

Mark Nelson-7
Thanks for the tip.  That's getting closer to what I need, but in my
application the robots need to be able to 'reproduce' without any user
interaction.  Having a robot 'in hand' isn't going to work for this
purpose.

The robots autonomously explore their environment collecting
food/energy and once they have acquired enough energy, they reproduce
(generate a copy of themselves).  I have the reproduction algorithm
working fine with the 'copy' tile, but I have the problem that the
embedded sensors of the child robot seem to be linked back to the
parent's sensors, rather than the child's own sensors.

If you have any other ideas along these lines, please let me know.
Thanks,
--Mark

On Jan 30, 2008 12:13 PM, Dreyfuss Pierre-André (EDU)
<[hidden email]> wrote:

> Hi,
> you have to use do menu item tile in the category miscellanous and choose duplicate as item.
>
> This seems create a copy in the hand.
>
>
> If you want just create a new robot this will work. But there is no handle on the new created object this way.
>
> however once dropped it can be designated as the first element of the morph containing it.
>
>
>
>
> Regards
>
>
> -------- Message d'origine--------
> De: [hidden email] de la part de Mark Nelson
> Date: mer. 30/01/2008 15:35
> À: [hidden email]
> Objet : [Squeakland] Etoys - create duplicate (not sibling) from a script?
>
>
> Hi,
>
> >From an Etoys SCRIPT, how can I create a 'duplicate' of a player
> (equivalent to clicking on the green halo icon), rather than creating
> a 'sibling/clone' of a player (equivalent to SHIFT-clicking on the
> green halo icon)?  The 'copy' tile available under the miscellaneous
> category seems to create a clone; the textual equivalent of
> ''Playfield include Ellipse's copy' is 'self include: Ellipse
> getNewClone'.   What I need is the textual equivalent that would
> create a 'duplicate' rather than a 'clone'.
>
> [Why do I care?  In the course that I'm currently teaching, we've
> created a 'robot' with embedded 'sensors'  (the 'robots' and 'sensors'
> are created from individual Ellipse morphs; the sensors then get
> embedded in the robot). The robot's actions depend on differences
> between left and right sensor values. If I now make a 'duplicate' of
> the robot using the green halo icon, the new robot works as expected.
> However, if I make a 'clone' of the robot (either by SHIFT-clicking
> the green halo icon, or by using the 'copy' tile in a script, the new
> robot seems to pick up the sensor values from the original robot,
> rather than from its own sensors.]
>
> Thanks in advance,
> --Mark Nelson
>
>
> _______________________________________________
> Squeakland mailing list
> [hidden email]
> http://squeakland.org/mailman/listinfo/squeakland
>
>

_______________________________________________
Squeakland mailing list
[hidden email]
http://squeakland.org/mailman/listinfo/squeakland
Reply | Threaded
Open this post in threaded view
|

Re: RE : Etoys - create duplicate (not sibling) from a script?

Scott Wallace
Hi, Mark,

You're right that there's no direct programatic way using tiles alone  
to obtain a proper "duplicate" (as opposed to a "sibling,") except (as  
Pierre-André suggests) by using "do menu item - duplicate," which,  
unsatisfactorily, leaves the clone in the "hand" rather than allowing  
you programatically to place it where you wish.

However, by using a one-line textual script, you can get the desired  
effect.

The trick is to devote a "Player-valued" variable to "remember" the  
newly-created thing, so that you can send messages to it to set it up  
the way you want.

In the example below, Robot has been given a player-valued variable  
named "theDuplicate."  The one-line textual script creates a duplicate  
of the Robot and places it into the "theDuplicate" variable.  Each  
time this script is run, a new copy of the robot is made, and placed  
into the originating robot's "theDuplicate" variable.





In order for the newborn to be seen on the screen, it needs to be put  
somewhere visible, and this is done by "including" it in the desired  
container, and positioning it appropriately; all of this can be done  
with normal tiles.

Thus, for example, the following script first invokes the textual one-
liner to create a copy, then adds the copy to the container, and,  
finally, positions the copy at an offset to the upper-right of the  
original robot.





Hope this helps!

Cheers,

   -- Scott



On Jan 30, 2008, at 7:55 PM, Mark Nelson wrote:

> Thanks for the tip.  That's getting closer to what I need, but in my
> application the robots need to be able to 'reproduce' without any user
> interaction.  Having a robot 'in hand' isn't going to work for this
> purpose.
>
> The robots autonomously explore their environment collecting
> food/energy and once they have acquired enough energy, they reproduce
> (generate a copy of themselves).  I have the reproduction algorithm
> working fine with the 'copy' tile, but I have the problem that the
> embedded sensors of the child robot seem to be linked back to the
> parent's sensors, rather than the child's own sensors.
>
> If you have any other ideas along these lines, please let me know.
> Thanks,
> --Mark
>
> On Jan 30, 2008 12:13 PM, Dreyfuss Pierre-André (EDU)
> <[hidden email]> wrote:
>> Hi,
>> you have to use do menu item tile in the category miscellanous and  
>> choose duplicate as item.
>>
>> This seems create a copy in the hand.
>>
>>
>> If you want just create a new robot this will work. But there is no  
>> handle on the new created object this way.
>>
>> however once dropped it can be designated as the first element of  
>> the morph containing it.
>>
>>
>>
>>
>> Regards
>>
>>
>> -------- Message d'origine--------
>> De: [hidden email] de la part de Mark Nelson
>> Date: mer. 30/01/2008 15:35
>> À: [hidden email]
>> Objet : [Squeakland] Etoys - create duplicate (not sibling) from a  
>> script?
>>
>>
>> Hi,
>>
>>> From an Etoys SCRIPT, how can I create a 'duplicate' of a player
>> (equivalent to clicking on the green halo icon), rather than creating
>> a 'sibling/clone' of a player (equivalent to SHIFT-clicking on the
>> green halo icon)?  The 'copy' tile available under the miscellaneous
>> category seems to create a clone; the textual equivalent of
>> ''Playfield include Ellipse's copy' is 'self include: Ellipse
>> getNewClone'.   What I need is the textual equivalent that would
>> create a 'duplicate' rather than a 'clone'.
>>
>> [Why do I care?  In the course that I'm currently teaching, we've
>> created a 'robot' with embedded 'sensors'  (the 'robots' and  
>> 'sensors'
>> are created from individual Ellipse morphs; the sensors then get
>> embedded in the robot). The robot's actions depend on differences
>> between left and right sensor values. If I now make a 'duplicate' of
>> the robot using the green halo icon, the new robot works as expected.
>> However, if I make a 'clone' of the robot (either by SHIFT-clicking
>> the green halo icon, or by using the 'copy' tile in a script, the new
>> robot seems to pick up the sensor values from the original robot,
>> rather than from its own sensors.]
>>
>> Thanks in advance,
>> --Mark Nelson
>>
>>
>> _______________________________________________
>> Squeakland mailing list
>> [hidden email]
>> http://squeakland.org/mailman/listinfo/squeakland
>>
>>
>
> _______________________________________________
> Squeakland mailing list
> [hidden email]
> http://squeakland.org/mailman/listinfo/squeakland

_______________________________________________
Squeakland mailing list
[hidden email]
http://squeakland.org/mailman/listinfo/squeakland

pastedGraphic.jpg (36K) Download Attachment
pastedGraphic.jpg (78K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Etoys - create duplicate (not sibling) from a script?

K. K. Subramaniam
On Thursday 31 Jan 2008 3:34:07 pm Scott Wallace wrote:
> Hi, Mark,
>
> You're right that there's no direct programatic way using tiles alone
> to obtain a proper "duplicate" (as opposed to a "sibling,") except (as
> Pierre-André suggests) by using "do menu item - duplicate,"

I dont see 'duplicate' entry in my version of etoys (2.3#1885). Is this
controlled by any Preference setting?

Subbu

_______________________________________________
Squeakland mailing list
[hidden email]
http://squeakland.org/mailman/listinfo/squeakland
Reply | Threaded
Open this post in threaded view
|

Re: Etoys - create duplicate (not sibling) from a script?

Scott Wallace
Hi, Subbu,

You'll see it in the menu only if the eToyFriendly preference is  
false, in which case it can be found in the "halo actions..." submenu.

But even if eToyFriendly is *true*, making "halo actions..." not  
visible via the UI, you can still invoke it via do-menu-item.

Cheers,

   -- Scott


On Feb 1, 2008, at 5:02 AM, subbukk wrote:

> On Thursday 31 Jan 2008 3:34:07 pm Scott Wallace wrote:
>> Hi, Mark,
>>
>> You're right that there's no direct programatic way using tiles alone
>> to obtain a proper "duplicate" (as opposed to a "sibling,") except  
>> (as
>> Pierre-André suggests) by using "do menu item - duplicate,"
>
> I dont see 'duplicate' entry in my version of etoys (2.3#1885). Is  
> this
> controlled by any Preference setting?
>
> Subbu
>
> _______________________________________________
> Squeakland mailing list
> [hidden email]
> http://squeakland.org/mailman/listinfo/squeakland


_______________________________________________
Squeakland mailing list
[hidden email]
http://squeakland.org/mailman/listinfo/squeakland
Reply | Threaded
Open this post in threaded view
|

Re: RE : Etoys - create duplicate (not sibling) from a script?

Alan Kay-4
In reply to this post by Scott Wallace
Hi Mark --

We should have done this better.

Here is how I handle things that are "like this"
this may or may not work for your case.

If you build a bunch of components on a Playfield
it is smart enough to act as a little name-space,
so when it is copied all the links between the
components will be preserved in the new composite
object. (Again, we should do this better.)

So e.g. if you have an object that is controlled
by a joystick morph, you can put both of these in
a Playfield, copy the Playfield, and the new
object and the new joystick will be linked.

Cheers,

Alan

At 02:04 AM 1/31/2008, Scott Wallace wrote:

>Hi, Mark,
>
>You're right that there's no direct programatic way using tiles alone
>to obtain a proper "duplicate" (as opposed to a "sibling,") except (as
>Pierre-André suggests) by using "do menu item - duplicate," which,
>unsatisfactorily, leaves the clone in the "hand" rather than allowing
>you programatically to place it where you wish.
>
>However, by using a one-line textual script, you can get the desired
>effect.
>
>The trick is to devote a "Player-valued" variable to "remember" the
>newly-created thing, so that you can send messages to it to set it up
>the way you want.
>
>In the example below, Robot has been given a player-valued variable
>named "theDuplicate."  The one-line textual script creates a duplicate
>of the Robot and places it into the "theDuplicate" variable.  Each
>time this script is run, a new copy of the robot is made, and placed
>into the originating robot's "theDuplicate" variable.
>
>
>
>
>
>
>
>In order for the newborn to be seen on the screen, it needs to be put
>somewhere visible, and this is done by "including" it in the desired
>container, and positioning it appropriately; all of this can be done
>with normal tiles.
>
>Thus, for example, the following script first
>invokes the textual one- liner to create a copy,
>then adds the copy to the container, and,
>finally, positions the copy at an offset to the upper-right of the
>original robot.
>
>
>
>
>
>
>
>Hope this helps!
>
>Cheers,
>
>   -- Scott
>
>
>
>On Jan 30, 2008, at 7:55 PM, Mark Nelson wrote:
>
>>Thanks for the tip.  That's getting closer to what I need, but in my
>>application the robots need to be able to 'reproduce' without any user
>>interaction.  Having a robot 'in hand' isn't going to work for this
>>purpose.
>>
>>The robots autonomously explore their environment collecting
>>food/energy and once they have acquired enough energy, they reproduce
>>(generate a copy of themselves).  I have the reproduction algorithm
>>working fine with the 'copy' tile, but I have the problem that the
>>embedded sensors of the child robot seem to be linked back to the
>>parent's sensors, rather than the child's own sensors.
>>
>>If you have any other ideas along these lines, please let me know.
>>Thanks,
>>--Mark
>>
>>On Jan 30, 2008 12:13 PM, Dreyfuss Pierre-André (EDU)
>><[hidden email]> wrote:
>>>Hi,
>>>you have to use do menu item tile in the category miscellanous and
>>>choose duplicate as item.
>>>
>>>This seems create a copy in the hand.
>>>
>>>
>>>If you want just create a new robot this will work. But there is no
>>>handle on the new created object this way.
>>>
>>>however once dropped it can be designated as the first element of
>>>the morph containing it.
>>>
>>>
>>>
>>>
>>>Regards
>>>
>>>
>>>-------- Message d'origine--------
>>>De: [hidden email] de la part de Mark Nelson
>>>Date: mer. 30/01/2008 15:35
>>>À: [hidden email]
>>>Objet : [Squeakland] Etoys - create duplicate (not sibling) from a
>>>script?
>>>
>>>
>>>Hi,
>>>
>>>> From an Etoys SCRIPT, how can I create a 'duplicate' of a player
>>>(equivalent to clicking on the green halo icon), rather than creating
>>>a 'sibling/clone' of a player (equivalent to SHIFT-clicking on the
>>>green halo icon)?  The 'copy' tile available under the miscellaneous
>>>category seems to create a clone; the textual equivalent of
>>>''Playfield include Ellipse's copy' is 'self include: Ellipse
>>>getNewClone'.   What I need is the textual equivalent that would
>>>create a 'duplicate' rather than a 'clone'.
>>>
>>>[Why do I care?  In the course that I'm currently teaching, we've
>>>created a 'robot' with embedded 'sensors'  (the 'robots' and
>>>'sensors'
>>>are created from individual Ellipse morphs; the sensors then get
>>>embedded in the robot). The robot's actions depend on differences
>>>between left and right sensor values. If I now make a 'duplicate' of
>>>the robot using the green halo icon, the new robot works as expected.
>>>However, if I make a 'clone' of the robot (either by SHIFT-clicking
>>>the green halo icon, or by using the 'copy' tile in a script, the new
>>>robot seems to pick up the sensor values from the original robot,
>>>rather than from its own sensors.]
>>>
>>>Thanks in advance,
>>>--Mark Nelson
>>>
>>>
>>>_______________________________________________
>>>Squeakland mailing list
>>>[hidden email]
>>>http://squeakland.org/mailman/listinfo/squeakland
>>>
>>
>>_______________________________________________
>>Squeakland mailing list
>>[hidden email]
>>http://squeakland.org/mailman/listinfo/squeakland
>
>
>
>_______________________________________________
>Squeakland mailing list
>[hidden email]
>http://squeakland.org/mailman/listinfo/squeakland


_______________________________________________
Squeakland mailing list
[hidden email]
http://squeakland.org/mailman/listinfo/squeakland
Reply | Threaded
Open this post in threaded view
|

Re: Etoys - create duplicate (not sibling) from a script?

K. K. Subramaniam
In reply to this post by Scott Wallace
On Saturday 02 Feb 2008 12:24:30 am Scott Wallace wrote:
> Hi, Subbu,
>
> You'll see it in the menu only if the eToyFriendly preference is
> false, in which case it can be found in the "halo actions..." submenu.
Thank you, Scott and Andre. This option totally slipped my mind.

Scott's solution using a textual script is really neat. The playfield already
keeps track of collections of Robots, so we could use it to track duplicates.
The duplicate's position can be computed based on the cursor or count.

E.g. Playfield>>makeDuplicate
        self includeAtCursor: self getValueAtCursor costume duplicate player.
        self getValueAtCursor turn: 45; forward: 10; turn: 45

Regards .. Subbu

_______________________________________________
Squeakland mailing list
[hidden email]
http://squeakland.org/mailman/listinfo/squeakland