How do I have 1 script get applied to multiple objects in E-toys?
Thanks, Randy
On Saturday 19 February 2005 2:06 pm, Randy Heiland wrote:
How do I have 1 script get applied to multiple objects in E-toys?
What do you mean "applied"?
If they're the same kind of objects, then you can share a script between multiple 'siblings'.
This should work more or less automatically in the current version of the Squeakland image.
If you take an object, then add a script or instance variable, then duplicate it using the green halo handle, you will make a sibling instance that will share all the scripts of (and will have the same instance variables as) the original.
Additionally, there is a (little-known) way that you can "impart", i.e. copy, all the scripts of a scripted Sketch over to a different Sketch.
To do this, open up a viewer on the first Sketch, the one that has scripts you want to copy. In the main Viewer menu, choose "impart scripts to..." from the "more..." branch. Now you'll be given a cross-hair cursor, which invites you to click on the object to which you wish to impart the first object's scripts.
After you've clicked on the second Sketch, open up a Viewer on it, and you should find that that it now has its own copies of all the scripts of the first Sketch.
Cheers,
-- Scott
At 4:02 PM -0800 2/21/05, Ned Konz wrote:
On Saturday 19 February 2005 2:06 pm, Randy Heiland wrote:
How do I have 1 script get applied to multiple objects in E-toys?
What do you mean "applied"?
If they're the same kind of objects, then you can share a script between multiple 'siblings'.
This should work more or less automatically in the current version of the Squeakland image.
If you take an object, then add a script or instance variable, then duplicate it using the green halo handle, you will make a sibling instance that will share all the scripts of (and will have the same instance variables as) the original.
Thanks for both your replies. I failed to communicate exactly what I wanted to do. I see that both your techniques do indeed impart a given script to another object. However, what I'm looking for is a simple way to execute a single script and have it act on N (sibling) objects (where N can be large). Basically, I want to reproduce the behavior of the StarSqueak objects (e.g. slimemold). Related, is the "proper" way to easily generate N sibling objects to create a script with misc: Sketch look like Sketch's copy ?
--Randy
-----Original Message----- From: squeakland-bounces@squeakland.org [mailto:squeakland- bounces@squeakland.org] On Behalf Of Scott Wallace Sent: Monday, February 21, 2005 9:36 PM To: squeakland@squeakland.org Subject: Re: [Squeakland] 1 script -> N objs
Additionally, there is a (little-known) way that you can "impart", i.e. copy, all the scripts of a scripted Sketch over to a different Sketch.
To do this, open up a viewer on the first Sketch, the one that has scripts you want to copy. In the main Viewer menu, choose "impart scripts to..." from the "more..." branch. Now you'll be given a cross-hair cursor, which invites you to click on the object to which you wish to impart the first object's scripts.
After you've clicked on the second Sketch, open up a Viewer on it, and you should find that that it now has its own copies of all the scripts of the first Sketch.
Cheers,
-- Scott
At 4:02 PM -0800 2/21/05, Ned Konz wrote:
On Saturday 19 February 2005 2:06 pm, Randy Heiland wrote:
How do I have 1 script get applied to multiple objects in E-toys?
What do you mean "applied"?
If they're the same kind of objects, then you can share a script between multiple 'siblings'.
This should work more or less automatically in the current version of the Squeakland image.
If you take an object, then add a script or instance variable, then
duplicate
it using the green halo handle, you will make a sibling instance that
will
share all the scripts of (and will have the same instance variables as)
the
original.
Squeakland mailing list Squeakland@squeakland.org http://squeakland.org/mailman/listinfo/squeakland
On Tuesday 22 February 2005 6:54 pm, you wrote:
However, what I'm looking for is a simple way to execute a single script and have it act on N (sibling) objects (where N can be large).
There are several methods that communicate with all the siblings of a given object.
scripting command 'pause all' scriptName(ScriptName) make the given script be "paused" in the object and all of its siblings command 'start all' scriptName(ScriptName) start the given script ticking in the object and all of its siblings. command 'stop all' scriptName(ScriptName) make the given script be "normal" in the object and all of its siblings command 'tell all siblings' aMessageSelector(ScriptName) send a message to all siblings command 'send to all' aMessageSelector(ScriptName) run the given script in the object and in all of its siblings
Related, is the "proper" way to easily generate N sibling objects to create a script with misc: Sketch look like Sketch's copy ?
the 'copy' property will return a sibling if the object was scripted or had an instance variable.
So you could do something like
MasterObject's holder addAtEnd: MasterObject's copy
to add a single object.
Am 23.02.2005 um 03:54 schrieb Randy Heiland:
Thanks for both your replies. I failed to communicate exactly what I wanted to do. I see that both your techniques do indeed impart a given script to another object. However, what I'm looking for is a simple way to execute a single script and have it act on N (sibling) objects (where N can be large). Basically, I want to reproduce the behavior of the StarSqueak objects (e.g. slimemold).
Not sure if this helps in your specific case, but often changing the point of view solves such problems quite easily.
For example, we were doing a PacMan game in etoys. In this game you steer a figure (PacMan) through a maze, eating all peas that are scattered along the way.
In each step, the PacMan needs to test if it touches a pea and then eat (remove) that pea. Normally you would try to write a script for the PacMan object to do this. However, in etoys it's much easier to implement if you reverse the logic - let each pea decide if it is eaten. We made a script for the pea that looks if this pea is touching the PacMan and if so, remove it.
Of course, all peas share this behaviour as they are siblings. Essentially, iterating over N objects in a script is the same as calling that script in N objects ...
- Bert -
squeakland@lists.squeakfoundation.org