For example, I want to some buttons to transform a costume or set an objects color and I want to click on the button and then be able to click on an object (or set of objects) and run a particular script on the objects I click on.
I could program each object to perform a particular action on Mouse Down, but I would rather write the script once and then have that script execute on the object I click. I was able to achieve this by using a Player variable watcher and then having a constantly running script that tests if the myPlayer != dot and if so, run the script on the Player variable value, then reset to dot. But besides looking ugly (the dot always shows) I can only run on one object at a time then have to click on the Player variable's watcher.
Thanks, Stephen
_______________________________________________ etoys-dev mailing list [hidden email] http://lists.squeakland.org/mailman/listinfo/etoys-dev |
On 29.03.2011, at 12:49, Steve Thomas wrote:
Well, Etoys is really object-centric. So adding the mouseDown script to each object is the Right Thing to do. But if you want to "centralize" what actually happens when clicked, you could call a "dispatching" script and pass the object itself as argument. Give that script a parameter of type "Player" so it can execute to the current command. I'm attaching an example project. To make a new command, just duplicate an existing one and change its "actOn:" script. - Bert - _______________________________________________ etoys-dev mailing list [hidden email] http://lists.squeakland.org/mailman/listinfo/etoys-dev MouseActions.003.pr (88K) Download Attachment |
Thanks, this helps and gives me some other ideas.
I hesitate to mention this (as one should not "bite the hand that feeds") but if you open the viewer for any of the color Player's in the pallette, then get its viewer and pull out the "actOn" script, the scripting tile show "Player | turn by | 45" even though it does set the color properly. If you then "show code textually" and switch back to "tile version" it turns the player on mouse down.
When I addeded a new tile (with the actOn script being "forward by | 20") the scripts tiles changed to show "forward by | 20" although the behavior did not change until I switched from tile->text->tile. I opened a ticket in Tracker.
Stephen On Tue, Mar 29, 2011 at 7:43 AM, Bert Freudenberg <[hidden email]> wrote:
_______________________________________________ etoys-dev mailing list [hidden email] http://lists.squeakland.org/mailman/listinfo/etoys-dev |
On 29.03.2011, at 15:44, Steve Thomas wrote: Thanks, this helps and gives me some other ideas. Interesting. I may have made Turn a sibling instead of copying. When I then changed the actOn: script, all the other siblings should have changed too (so I would have noticed my error). But it seems it actually is no sibling. Mysterious ... - Bert - _______________________________________________ etoys-dev mailing list [hidden email] http://lists.squeakland.org/mailman/listinfo/etoys-dev |
Free forum by Nabble | Edit this page |