SCI Studio Tutorial Chapter 9 - Elements of a Script
Scripts are made up of what are called segments. There are eleven different segments which you can use in your scripts. They all fit into three different categories: Data, Code and Compiler Directives.
Data Segments
local | The local variables of the script are declared in the local segment. Each variable is 16 bit, meaning it can have a value from -32,768 to 32,767. Variable arrays are also supported.
|
string | The strings in your script can be declared in the string segment. Each string begins with a label identifying it, followed by either the size, a string of text, or both.
|
synonyms | The synonyms in your script can be declared in the synonyms segment. Each synonym consists of two vocab words. This is one of the least used segments, and you will probably never use it in your game.
|
Code Segments
class | SCI, being object orientated, is structured completely around objects. Each class segment defines a class object. Class objects are the most powerful types of objects.
|
instance | Instances are objects derived from classes. They have slightly more limited functionality, but are very well suited for general purpose objects.
|
procedure | Procedures are blocks of code. They operate identical to methods, but are not tied to objects. This being the case, they can be used by any object or other procedure, and accomplish any task.
|
Compiler Directives
script | Every script must have it's script number specified. The script segment tells the compiler which number the current script is (from 0-999). In the following example, it tells the compiler that it's compiling the file script.123.
|
define | Define is a very frequently used segment. It allows you to label immediate values. The script header (.sh) files are built of these statements.
|
include | The include statement tells the compiler to use the specified header with the current script.
|
use | The use statement tells the compiler that the current script uses other script's classes (and in the case of main.sc, variables as well). Each script which is compiled generates a .sco file. The following example means that the script uses the obj.sc script, and reads the obj.sco file.
|
preload text | Some scripts use text resource to print all/some of it's text. In this case, it will access the text resource corresponding to the script resource (i.e. script.123 would use text.123). If you are constantly accessing the text from text resources, you should use the preload text statement. It loads the text into memory for quicker access.
|
That sums up the segments of a script. If you don't fully understand them yet, don't worry. Continue on with the tutorial, doing the step by step examples. When done, you should have a good grasp on them. If you still do not, come back to this chapter and read it again, and look at the links to the help file.
< Previous: Chapter 8 - An Introduction To ScriptsNext: Chapter 10 - Getting Familiar With Objects >