[eToy][Q] Adding scripts to eToys

Ned Konz ned at bike-nomad.com
Sun Jun 23 22:41:18 UTC 2002


On Sunday 23 June 2002 01:54 pm, Leo Burd wrote:
> Squeakers,
>
> Although I've seen this sort of question on the mailing list a
> million times, I couldn't find any comprehensive description of how
> to add new scripts to eToys.  For instance,
>
> * What are all the classes the need to be changed? Morph, Player,
> anything else?
> * What are the fundamental methods to be changed in those classes?
> * Do changes depend on any sort of initialization or global
> settings? * What are the possible values to be included in
> additionsToViewerCategories?
> * What if I want the new added methods to be translated to
> different languages?
>
> Is there any place where this information is described?  If not,
> would anybody help me out?

Leo, I figured this out for my RCXMorph; if you look at the change set 
at

http://minnow.cc.gatech.edu/squeak/uploads/2412/RCXMorph-nk.cs

you should get a quick view of what it took for me to do it.

Right now, the slot types are:
#Number #ListDirection #Color #ListCentering #Resizing #BorderStyle 
#ButtonPhase #String #Player #Point #Boolean #Graphic

The values to be returned from additionsToViewerCategories are 
collections comprised of one or more elements, each of which appears 
to be:

a 2-long array
* whose first element is a category symbol (currently used: #joystick 
#'drag & drop' #paintbox #basic #playfield #button #graphics 
#collections #fog #storyboard #'pen trails' #scripting #'pen use' 
#'book navigation' #motion #scripts #geometry #viewing #slider 
#'color & border' #observation #text #'stack navigation' #sampling 
#tests #speaker #miscellaneous #layout)

* whose second element is an array, either:

* a 3-element array that is:
	#command
	#<symbol of command method>
	'explanation'

or a 9-element array that is:
	#slot
	#<symbol for slot>
	'explanation'
	#<symbol for slot type, see above>
	#<type of slot, #readWrite or #readOnly>
	#<receiver for getter, either #player or #unused (ignored)>
	#<selector of getter>
	#<receiver for setter (#unused for readOnly) (ignored)>
	#<selector of setter (#unused for readOnly)>

In other words, the Player is the receiver for all of these methods.

However, the additionsToViewerCategories are referred to in the code 
as the "old EToy" form; this is presumably before the translation 
support was added.

see MethodInterface>>initializeFromEToySlotSpec: for what happens to 
the slot specs.

There is (presumably the new version) 
Vocabulary>>addFromTable:language: and friends (initializeFromTable:, 
etc.) that take a table of these specs:

		(1)	selector
		(2)	companion setter selector (#none or nil indicate none)
		(3)  argument specification array, each element being an array of 
the form
				<arg name>  <arg type>
		(4)  result type, (#none or nil indicate none)
		(5)  array of category symbols, i.e. the categories in which this 
element should appear.
		(6)  help message. (optional)
		(7)  wording (optional)
		(8)  auto update flag (optional) - if #updating, set readout to 
refetch automatically

This is apparently what you want.

I got the above information by browsing and using the following 
Workspace script:
----------------------
categories _ Set new.
kinds _ Set new.	"field 1, slot or command"
returnTypes _ Set new. "field 4"
slotTypes _ Set new. "field 5"
receivers _ Set new. "field6, 8"

EToyVocabulary basicNew morphClassesDeclaringViewerAdditions do: [ 
:cls |
	cls additionsToViewerCategories do: [ :cat |
		categories add: cat first.
		cat second do: [ :entry |
			kinds add: entry first.
			entry first == #slot ifTrue: [ returnTypes add: (entry at: 4).
				slotTypes add: (entry at: 5).
				receivers add: (entry at: 6).
				receivers add: (entry at: 8).
			 ]
		]
	]
].
----------------------------

At one point (and maybe still in the plugin) you had to go "Vocabulary 
initialize" to get your changes to be noticed. However, I don't see 
that I did it in the RCXMorph-nk.cs change set.

-- 
Ned Konz
http://bike-nomad.com
GPG key ID: BEEA7EFE




More information about the Squeak-dev mailing list