SCI Kernel Documentation/Resource Functions

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 | Index

Resource Functions

Author: Jeff Stephenson

Revision by: David Slayback


Resource Functions

Resources are the various components of a game: views, pictures, scripts, etc. and, except for the MEMORY resource, reside on disk, waiting to be loaded when needed. Resources are handled automatically by the kernel, but several functions are provided to allow the programmer a bit more control over how the handling is done.

(Load resType resID)

Loads a resource of type resType and ID (number) resID into hunk space. While any attempt to use a resource which is not loaded will cause the resource to be loaded, it is not generally a good idea to rely on this as it may cause a disk-access delay in the midst of a crucial animation sequence. It is best to do an explicit Load of all resources during the initialization phase of a room to insure that everything is in memory. The resource types are:

MEMORY (used internally by the kernel)
VOCAB (used internally by the kernel)

Example: (Load SCRIPT forest) loads the script whose number is in the variable forest into memory.

(UnLoad resType resID)

Purges the resource of type resType and ID (number) resID from hunk space. This is not normally needed, as the kernel will automatically purge the least recently used resource when it doesn't have enough memory to load a new resource. This function is provided for a situation in which it is advantageous to override this automatic purging. Such a situation is unlikely.

Example: (UnLoad SOUND EXPLOSION) purges the sound whose number is EXPLOSION from memory.

(ScriptID script [entry])

Return the object ID for the object which at entry number entry in the publics table of script number script. This will load the script if it is not already in memory. If entry is not present, this returns the ID of entry number 0 of script.

(DisposeScript script)

While resources loaded into hunk space are automatically disposed of when no longer used, when a script is loaded it is loaded into the heap and remains there until disposed of by DisposeScript. This disposes of script number script and should be called when you no longer need the script. This is especially useful for discarding classes and regions that no longer need to be in memory.

(FlushResources roomNum)

If we are tracking resource usage (if run with 'sci -u'), set the internal room number of the room to roomNum, then flush all unlocked resources.




Table of Contents


< Previous: SCI OverviewNext: List Functions >