Difference between revisions of "Script Classes for Adventure Games/Script Class"

From SCI Wiki
Jump to navigationJump to search
Line 4: Line 4:
 
Chapter:  
 
Chapter:  
 
[[Script Classes for Adventure Games/Introduction|1]] |  
 
[[Script Classes for Adventure Games/Introduction|1]] |  
[[Script Classes for Adventure Games/RootObj|2]] |  
+
[[Script Classes for Adventure Games/RootObj Class|2]] |  
[[Script Classes for Adventure Games/Object|3]] |  
+
[[Script Classes for Adventure Games/Object Class|3]] |  
[[Script Classes for Adventure Games/Collection|4]] |  
+
[[Script Classes for Adventure Games/Collection Class|4]] |  
[[Script Classes for Adventure Games/List|5]] |  
+
[[Script Classes for Adventure Games/Script Class|5]] |  
[[Script Classes for Adventure Games/Set|6]] |  
+
[[Script Classes for Adventure Games/Timer Class|6]] |  
[[Script Classes for Adventure Games/EventHandler|7]] |  
+
[[Script Classes for Adventure Games/Feature Class|7]] |  
[[Script Classes for Adventure Games/Inventory|8]] |  
+
[[Script Classes for Adventure Games/View Class|8]] |  
[[Script Classes for Adventure Games/Script|9]] |  
+
[[Script Classes for Adventure Games/PicView Class|9]] |  
[[Script Classes for Adventure Games/Timer|10]] |  
+
[[Script Classes for Adventure Games/Cycling Classes|10]] |  
[[Script Classes for Adventure Games/Feature|11]] |  
+
[[Script Classes for Adventure Games/Motion Classes|11]] |  
[[Script Classes for Adventure Games/View|12]] |  
+
[[Script Classes for Adventure Games/Avoider Class|12]] |  
[[Script Classes for Adventure Games/Prop|13]] |  
+
[[Script Classes for Adventure Games/Event Class|13]] |  
[[Script Classes for Adventure Games/Actor|14]] |
+
[[Script Classes for Adventure Games/User Class|14]]<br />
[[Script Classes for Adventure Games/Ego|15]] |
+
[[Script Classes for Adventure Games/Game Class|15]] |  
[[Script Classes for Adventure Games/PicView|16]] |
+
[[Script Classes for Adventure Games/Locale Class|16]] |  
[[Script Classes for Adventure Games/Cycle|17]] |
+
[[Script Classes for Adventure Games/Region Class|17]] |  
[[Script Classes for Adventure Games/Forward|18]] |
+
[[Script Classes for Adventure Games/Room Class|18]] |  
[[Script Classes for Adventure Games/Walk|19]] |
+
[[Script Classes for Adventure Games/Timer2 Class|19]] |  
[[Script Classes for Adventure Games/Reverse|20]] |
+
[[Script Classes for Adventure Games/InvItem Class|20]] |  
[[Script Classes for Adventure Games/CycleTo|21]] |
+
[[Script Classes for Adventure Games/Block Class|21]] |  
[[Script Classes for Adventure Games/EndLoop|22]] |
+
[[Script Classes for Adventure Games/Cage Class|22]] |  
[[Script Classes for Adventure Games/BegLoop|23]] |
+
[[Script Classes for Adventure Games/Sound Class|23]] |  
[[Script Classes for Adventure Games/Motion|24]] |
+
[[Script Classes for Adventure Games/StatusLine Class|24]] |  
[[Script Classes for Adventure Games/MoveTo|25]] |
+
[[Script Classes for Adventure Games/File Class|25]] |  
[[Script Classes for Adventure Games/Wander|26]]<br />
+
[[Script Classes for Adventure Games/Code Class|26]] |  
[[Script Classes for Adventure Games/Follow|27]] |
+
[[Script Classes for Adventure Games/Global Variables|27]] |  
[[Script Classes for Adventure Games/Chase|28]] |
 
[[Script Classes for Adventure Games/Jump|29]] |
 
[[Script Classes for Adventure Games/JumpTo|30]] |
 
[[Script Classes for Adventure Games/Orbit|31]] |
 
[[Script Classes for Adventure Games/Path|32]] |
 
[[Script Classes for Adventure Games/RelPath|33]] |
 
[[Script Classes for Adventure Games/Avoider|34]] |
 
[[Script Classes for Adventure Games/Event|35]] |
 
[[Script Classes for Adventure Games/User|36]] |
 
[[Script Classes for Adventure Games/Game|37]] |  
 
[[Script Classes for Adventure Games/Locale|38]] |  
 
[[Script Classes for Adventure Games/Region|39]] |  
 
[[Script Classes for Adventure Games/Room|40]] |  
 
[[Script Classes for Adventure Games/Timer2|41]] |
 
[[Script Classes for Adventure Games/TimeOut|42]] |  
 
[[Script Classes for Adventure Games/InvItem|43]] |  
 
[[Script Classes for Adventure Games/Block|44]] |  
 
[[Script Classes for Adventure Games/Cage|45]] |  
 
[[Script Classes for Adventure Games/Sound|46]] |  
 
[[Script Classes for Adventure Games/StatusLine|47]] |  
 
[[Script Classes for Adventure Games/File|48]] |  
 
[[Script Classes for Adventure Games/Code|49]] |  
 
[[Script Classes for Adventure Games/Global Variables|50]] |  
 
[[Script Classes for Adventure Games/Index|Index]]
 
 
</div><br />
 
</div><br />
  

Revision as of 03:08, 9 December 2015

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 |


The Script Class

Author: Jeff Stephenson

Date: 5 April 1988

 


The Script Class

A Script is a kind of Object which has a state, methods to change that state, and code to execute when the state changes. It is used to model a sequence of actions which should be executed by an object, such as an Actor walking to the base of some stairs, walking up the stairs, and opening a door.

In file: system.sc
Inherits from: Object
Inherited by: none


Properties


client

The object (a Prop, Actor, Ego, Room, etc.) whose Script this is. Used to communicate with the Script's client.


state

The state of the Script.


start

The desired initial state of the Script.


timer

The ID of a timer which has been set to cue: the Script after a certain interval.


register

A property that allows you to store what ever you want. This is very useful in a Script since a temporary variable will not hold its value longer that the life of one method, thus without this property the only way to keep a value fro. state to state through a Script would have been a local o. global variable. If more than one value needs to be stored the register property could be used as a pointer to a Collection, List or Set.


caller

The is where the Script keeps the ID of the object to cue: upon completion.


seconds

This contains the number of seconds until a state change wil. occur. This is generally set in one of the scripts states to signal the number of seconds until a state change should occur.


cycles

This contains the number of animation cycles until a stat. change will occur. This is generally set in one of the script. states to signal the number of animation cycles until a stat. change should occur.


script

The ID of this script's script if it has one. This property is filled by the setScript method and should not be set directly.


Methods


init: [client]

Initialize the Script entering the initial state by doing a (self changeState:start). Set the Script's client to client if present.


changeState: newState

Change the Script's state to newState. This method is where to put the code to be executed on state transitions. It should store the new state in the state property, then switch to the appropriate code based on the new state:

Code:
(method (changeState newState)
     (switch (= state newState)
          transition code...
      )
)


cue

Do a changeState: to the next state. Default is to invoke (self changeState:(+ state 1))


handleEvent: event

This method of an active script is called whenever there is an input event (see class Event). If (event claimed:) is TRUE, someone else has already responded to the event. Whether or not someone else has responded, if the Script responds to the event it should claim it by doing an (event claimed:TRUE). This method ca. be used to add additional responses to an Actor ,Prop etc.


setScript: newScript whoCares register

A Script can also have a script. This adds subroutine style capability to scripts. If the optional parameter whoCares is present the newScript will cue: whoCares and pass on the content. its register when it is disposed (i.e. (client cue:register)). In this case, the last state of the newScript should dispose o. itself i.e. (self dispose:) or (client setScript:0). The third parameter (if present) sets the newScript's register property. If a Script has a newScript the newScript will receive all the events the the parenet script receives.

 

Notes


 

Table of Contents

 

< Previous: The Inventory Class Next: The Timer Class >