[squeakland] Multiple objects running the same script
karl ramberg
karlramberg at gmail.com
Mon Aug 29 08:08:09 EDT 2011
On Mon, Aug 29, 2011 at 12:42 PM, 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.
>
Siblings can be made from other siblings in no specific order.
Could you post the project that locks up so I can see if I find whats going
wrong ?
>
> 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.
>
Yes, this is the only way to set the pen color from scripts.
Karl
>
> 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/59e86f7b/attachment.html>
More information about the squeakland
mailing list