[squeakland] Create siblings in a loop?

karl ramberg karlramberg at gmail.com
Mon Aug 29 08:26:20 EDT 2011


Also note that you can select several players by holding down shift and
dragging.
Useful to know when you must delete a bunch of players.

Karl

On Mon, Aug 29, 2011 at 2:22 PM, karl ramberg <karlramberg at gmail.com> wrote:

> Use the Player copy found in miscellaneous category.
> You must add the copy to the playfield you want it in.
> These copies get placed on top of each other. You could assign a random x
> and y by using a variable.
>
> [image: image.png]
> These copies get placed on top of each other. You could assign a random x
> and y by using a variable.
> [image: image.png]
>
> Karl
>
> On Mon, Aug 29, 2011 at 1:54 PM, R.D. Latimer <rdlatimer at gmail.com> wrote:
>
>> Can siblings be created in a loop in a script?
>> So I can create 100 siblings at once?
>>
>> On Mon, Aug 29, 2011 at 6:46 AM, R.D. Latimer <rdlatimer at gmail.com>wrote:
>>
>>> Also -
>>>  Recursion works - (I think)
>>> I made a drawsquare with 1 input for a counter,
>>> If number < 4
>>>   forward 100
>>>   rt 100
>>>   drawsquare (number + 1)    recursive call.
>>>
>>> That's nice that recursion looks like it's supported.
>>>
>>> When I make an input, using 'number' for example, can I change the name
>>> to 'counter'?  I think I have to use the default name provided by etoys -
>>> 'number'
>>>
>>> Randy
>>>
>>>
>>> On Mon, Aug 29, 2011 at 6:42 AM, R.D. Latimer <rdlatimer at gmail.com>wrote:
>>>
>>>> Thanks - I got #2 below to work.  I put all the turtle objects onto a
>>>> playfield and use "tell all contents".
>>>> For #1, I guess I have to specifically call each turtle object reset, so
>>>> if there are 10 turtles, I'll need 10 blocks, one for each turtle reset?
>>>> It'd be nice to somehow loop through a list of turtle objects, saying to
>>>> each one 'reset'.
>>>> I tried this with the "Holder" - put turtle tiles for each turtle in the
>>>> holder, then use "Holder send to all" or "Holder tell all contents" to
>>>> reset.  THat didn't seem to have any affect. 1
>>>>
>>>> In NetLogo, you write a procedure named 'reset', then use 'tell all' for
>>>> something like
>>>>   tell all turtles [ reset ]   (I forget the exact syntax)
>>>>
>>>> #3 locked up for my version.  Each turtle has a reset script. Each
>>>> turtle is a sibling of the first turtle. When I use tell all siblings
>>>> 'reset', the program locked up.  I may be doing something wrong on that.
>>>> Do I use turtle 1 to create all the siblings, turtle1 for sibling1,
>>>> sibling 1 for sibling2, sibling2 for sibling3, etc.
>>>>
>>>> Also, to set random pen color, I used an indirect way I found someone
>>>> suggested online. I don't think I can assign pencolor a random color.  I
>>>> made an object, assigned it random rgb amounts (1-100?), then assigned the
>>>> pen color to be the color of that object.
>>>>
>>>> Randy
>>>>
>>>>
>>>> On Sun, Aug 28, 2011 at 11:11 PM, Steve Thomas <sthomas1 at gosargon.com>wrote:
>>>>
>>>>> So from what I can tell about what you are trying to do the best way
>>>>> may be to create "sibling copies" or your turtles.  This is done by either
>>>>> holding down the shift key when you click on the copy icon in the halo or
>>>>> from the menu in the halo there is an option to create siblings
>>>>>
>>>>> That said there are a number of ways to reset things I can think of and
>>>>> hopefully this is not too much info:
>>>>>
>>>>>    1. You can create a script that executes the resets for all objects
>>>>>    you want to reset
>>>>>    2. Use the scripting tile "tell all contents" (found in the
>>>>>    scripting category for playfields) to execute all scripts named "reset" (or
>>>>>    whatever name you choose). Note, this will only go "one level deep" in a
>>>>>    playfield. This will work if all objects you want to reset are in the
>>>>>    playfield (but will not work for any objects embedded in a playfield in that
>>>>>    playfield)
>>>>>    3. Use the scripting tile "tell all siblings" Siblings are really
>>>>>    neat. When you change a script in one sibling all siblings get the same
>>>>>    script changes. So in effect they share a common set of scripts and
>>>>>    variables, but can have different values for each siblings copy of a
>>>>>    variable and different script states as well.
>>>>>    4. If you are using a Book, you can make a page (and the entire
>>>>>    book "revertible. In the book's menu is an option "save this page for later
>>>>>    revert" which allows you to set the page (or book) as "revertible"  Which
>>>>>    will save the current state of the page.  Then from the Book's menu you can
>>>>>    choose "revert this page" or "revert this book".  You can also use the menu
>>>>>    item in a script, by getting the halo for that menu item (ie: "revert this
>>>>>    page") and drag the "fire" tile into a script.
>>>>>
>>>>> Note: you can either create a button to reset the page (from a script
>>>>> editors menu, there is an option: "button to fire this script" or you can
>>>>> set a scripts status to "opening" which can be used to reset a page or a
>>>>> book when that page or book is opened.
>>>>>
>>>>> Stephen
>>>>>
>>>>> On Sun, Aug 28, 2011 at 10:41 PM, R.D. Latimer <rdlatimer at gmail.com>wrote:
>>>>>
>>>>>> Etoys-
>>>>>>   I have a 'turtle' with a reset button (clears screen, sets position
>>>>>> to random xy) and a drawpattern script with random colors.
>>>>>>
>>>>>> Can I create many copies of this turtle and run all the resets at once
>>>>>> - re-positions all 'turtles' and clears the screen, and then run drawpattern
>>>>>> all at once for all turtles?  Note that drawpattern needs to run only once,
>>>>>> not constantly as with a timer.
>>>>>>
>>>>>> Thanks,
>>>>>> Randy Latimer
>>>>>>
>>>>>> _______________________________________________
>>>>>> squeakland mailing list
>>>>>> squeakland at squeakland.org
>>>>>> http://lists.squeakland.org/mailman/listinfo/squeakland
>>>>>>
>>>>>>
>>>>>
>>>>
>>>
>>
>> _______________________________________________
>> squeakland mailing list
>> squeakland at squeakland.org
>> http://lists.squeakland.org/mailman/listinfo/squeakland
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakland.org/pipermail/squeakland/attachments/20110829/faa6999a/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 10171 bytes
Desc: not available
URL: <http://lists.squeakland.org/pipermail/squeakland/attachments/20110829/faa6999a/attachment-0002.png>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 19355 bytes
Desc: not available
URL: <http://lists.squeakland.org/pipermail/squeakland/attachments/20110829/faa6999a/attachment-0003.png>


More information about the squeakland mailing list