Re: Multiple objects running the same script
"R.D. Latimer" <[email protected]>
| Newsgroups | gmane.comp.lang.smalltalk.squeak.squeakland |
|---|---|
| Message-ID | <CAM8Wt+YJbTtSENaLXnpgp40fDDzxs83cygZ1SqCF5ZL4UnDjGA@mail.gmail.com> |
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-gQhbkF4bah9Wk0Htik3J/[email protected]>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 <[email protected]>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 >> [email protected] >> http://lists.squeakland.org/mailman/listinfo/squeakland >> >> > _______________________________________________ squeakland mailing list [email protected] http://lists.squeakland.org/mailman/listinfo/squeakland