[etoys-dev] programming etoys itself
bert at freudenbergs.de
Fri Apr 23 13:30:29 EDT 2010
On 22.04.2010, at 17:59, Ricardo Moran wrote:
> Someone more experienced may give you a better help, but I'll give it a try.
> AFAIK there is no good documentation of how to make tiles and stuff (at least I couldn't find anything really useful). I learned most of this stuff by watching examples... the image is full of them ;).
> Making an object scriptable is not as easy as it should be because Etoys has a lot of quirks that need some special attention.
> The tiles are created as slots/commands in the #additionsToViewerCategories method in the class side of the Morph (IMO you can see some simple examples by watching the source code of BookMorph or JoystickMorph). To implement that method correctly you have to be very careful and obey the rules. Below is a simple example:
> (#slot #slotName 'comment' #SlotType #readWrite #Player #getterMethod #Player #setterMethod:)
> (#command #commandName 'comment')
> (#command #commandWithOneParameter: 'comment' #ParameterType)
> The #category must be lowercase (this is one of Etoys quirks I tell you before), otherwise it will not appear... don't ask me why...
> The #SlotType and #ParameterType are usually Number but they can be Boolean, Color, Point, String, among others...
> The #readWrite part can also be #readOnly or #writeOnly (I don't know the purpose of the latter, though).
> The #getterMethod and #setterMethods: are the names of the methods you'll have to implement in order to access the value of the slot. This methods must be implemented in a Player subclass (or Player itself but I don't like to touch the Player class, it's already bloated and messy). If you make a subclass of Player you must implement a method called #newPlayerInstance in your Morph. This method should look like this:
> ^ MySubclassOfPlayer newUserInstance.
> Well, if you have any question don't be afraid to ask. Also it could be a good example to watch the stuff I'm doing as part of the GSoC program. More info here: http://www.pcs.cnu.edu/~rcaton/ESUG/ESUG.html
> Best regards
I also just found this old comment:
Date: 12 October 2003
Author: Ned Konz
This makes it possible for packages to extend Morph class vocabularies.
Previously, you'd have to edit #additionsToViewerCategories, which would result in potential conflicts between different packages that all wanted to (for instance) extend Morph's vocabulary.
Subclasses that have additions can do one or both of:
- override #additionsToViewerCategories (as before)
- define one or more additionToViewerCategory* methods.
The advantage of the latter technique is that class extensions may be added
by external packages without having to re-define additionsToViewerCategories.
So, for instance, package A could add a method named #additionsToViewerCategoryPackageABasic
and its methods would be added to the vocabulary automatically.
- Bert -
-------------- nächster Teil --------------
Ein Dateianhang mit HTML-Daten wurde abgetrennt...
More information about the etoys-dev