Script Classes for Adventure Games/Object Class

From SCI Wiki
Jump to: navigation, search

Official SCI Documentation

Chapter: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14
15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | Index

The Object Class

Author: Jeff Stephenson

Date: 5 April 1988


The Object Class

Class Object is the super-class of the majority of the classes in Script. It defines the default behavior for these classes, ensuring that all objects will respond to a certain basic set of messages.

In file
Inherits from RootObj
Inherited by All classes



This is a string representation of the name of the object or class. It is used by showSelf: to display the object. The compiler will use the symbol for an instance or class as its name unless name is explicitly set.



Returns the ID of a new instance of the class or object. This new instance has the same methods and property values as the parent. The property values can be changed, the methods cannot.


Initializes the object. If the object is to show up on the screen (Views, Props, Actors and Egos), this is the message which will make the it show itself. The default does nothing.


Do your thing, whatever that may be. Sometimes this is sent when the object is selected, sometimes (as for Actors) it is sent for each animation cycle. The default does nothing.


Dispose of the object. If the object was created using new:, this reclaims the memory occupied by that object. In this case it is an error to refer to the object ID being disposed of once the dispose: message has been sent. Subclasses of Object should make sure that they dispose of any objects which they created before doing a (super dispose:).

showStr: where

Format a string describing the object at the storage pointed to by where. The default string is the object name.


Display this object in a meaningful way. This is primarily used for debugging, in order to find out which objects are present. The default is to print the string produced by showStr:.

perform: code [args...]

Execute code. Code must be an object of class Code with a doit: method whose first argument will refer to the object which is to perform the code. Thus, one way to implement showSelf: would be to create the Code object
(instance showMe of Code 
     (method (doit theObj) 
          (Print (theObj name?)) 

You could then make the object foo show itself even if it did not have a showSelf: method by writing

(foo perform: showMe)
Up to four arguments (besides the Code object ID) may be passed to perform:.


Returns the object ID of the receiver. This is useful as the last in a series of messages to an object to force the entire send to return the ID of the object. For example, if you wish to add a newly created and initialized Actor to a List, you could write
(list add:
     ((Actor new:)
          posn:100 100
          setCycle: EndLoop

understands: selector

Returns TRUE if the object has a method corresponding to selector, FALSE otherwise.




Table of Contents


< Previous: The RootObj Class Next: The Collection Class >