Difference between revisions of "SCI Studio Tutorial Chapter 9 - Elements of a Script"
(One intermediate revision by the same user not shown) | |||
Line 8: | Line 8: | ||
<blockquote> | <blockquote> | ||
<div class="CodeBlockHeader">Example:</div> | <div class="CodeBlockHeader">Example:</div> | ||
− | <syntaxhighlight lang="sci">(local | + | <syntaxhighlight lang="sci" class="cs">(local |
score // no value set, will set later | score // no value set, will set later | ||
maxScore = 100 // value of 100 set | maxScore = 100 // value of 100 set | ||
Line 22: | Line 22: | ||
<blockquote> | <blockquote> | ||
<div class="CodeBlockHeader">Example:</div> | <div class="CodeBlockHeader">Example:</div> | ||
− | <syntaxhighlight lang="sci">(string | + | <syntaxhighlight lang="sci" class="cs">(string |
// A simple string. | // A simple string. | ||
SomeString ="This is a string" | SomeString ="This is a string" | ||
Line 40: | Line 40: | ||
<blockquote> | <blockquote> | ||
<div class="CodeBlockHeader">Example:</div> | <div class="CodeBlockHeader">Example:</div> | ||
− | <syntaxhighlight lang="sci">(synonyms | + | <syntaxhighlight lang="sci" class="cs">(synonyms |
'grab' = 'get' | 'grab' = 'get' | ||
)</syntaxhighlight> | )</syntaxhighlight> | ||
Line 56: | Line 56: | ||
<blockquote> | <blockquote> | ||
<div class="CodeBlockHeader">Example:</div> | <div class="CodeBlockHeader">Example:</div> | ||
− | <syntaxhighlight lang="sci">(class SomeClass of AnotherClass | + | <syntaxhighlight lang="sci" class="cs">(class SomeClass of AnotherClass |
(properties | (properties | ||
aProperty 1 | aProperty 1 | ||
Line 73: | Line 73: | ||
<blockquote> | <blockquote> | ||
<div class="CodeBlockHeader">Example:</div> | <div class="CodeBlockHeader">Example:</div> | ||
− | <syntaxhighlight lang="sci">(instance SomeInstance of SomeClass | + | <syntaxhighlight lang="sci" class="cs">(instance SomeInstance of SomeClass |
(properties | (properties | ||
aProperty 1 | aProperty 1 | ||
Line 90: | Line 90: | ||
<blockquote> | <blockquote> | ||
<div class="CodeBlockHeader">Example:</div> | <div class="CodeBlockHeader">Example:</div> | ||
− | ><syntaxhighlight lang="sci">(procedure ( someProc aParam anotherParam) | + | ><syntaxhighlight lang="sci" class="cs">(procedure ( someProc aParam anotherParam) |
= aParam 10 | = aParam 10 | ||
)</syntaxhighlight> | )</syntaxhighlight> | ||
Line 107: | Line 107: | ||
<blockquote> | <blockquote> | ||
<div class="CodeBlockHeader">Example:</div> | <div class="CodeBlockHeader">Example:</div> | ||
− | <syntaxhighlight lang="sci">(script 123)</syntaxhighlight> | + | <syntaxhighlight lang="sci" class="cs">(script 123)</syntaxhighlight> |
</blockquote> | </blockquote> | ||
|- | |- | ||
Line 114: | Line 114: | ||
<blockquote> | <blockquote> | ||
<div class="CodeBlockHeader">Example:</div> | <div class="CodeBlockHeader">Example:</div> | ||
− | <syntaxhighlight lang="sci">(define A_NUMBER 123)</syntaxhighlight> | + | <syntaxhighlight lang="sci" class="cs">(define A_NUMBER 123)</syntaxhighlight> |
For more information on defines, refer to the section in the <html><a href="javascript:void(0)" onclick="window.open('http://sierrahelp.com/SCI/Definitions/Define.html', 'Define','width=750,height=250','scrollbars=yes')">Define section</a></html> from the SCI Studio Help File. | For more information on defines, refer to the section in the <html><a href="javascript:void(0)" onclick="window.open('http://sierrahelp.com/SCI/Definitions/Define.html', 'Define','width=750,height=250','scrollbars=yes')">Define section</a></html> from the SCI Studio Help File. | ||
Line 123: | Line 123: | ||
<blockquote> | <blockquote> | ||
<div class="CodeBlockHeader">Example:</div> | <div class="CodeBlockHeader">Example:</div> | ||
− | <syntaxhighlight lang="sci">(include "sci.sh")</syntaxhighlight> | + | <syntaxhighlight lang="sci" class="cs">(include "sci.sh")</syntaxhighlight> |
For more information on the include statement and header files, refer to the section in the <html><a href="javascript:void(0)" onclick="window.open('../Definitions/Include.html', 'Include','width=750,height=500,scrollbars=yes,location=no')">Include section</a></html> from the SCI Studio Help File. | For more information on the include statement and header files, refer to the section in the <html><a href="javascript:void(0)" onclick="window.open('../Definitions/Include.html', 'Include','width=750,height=500,scrollbars=yes,location=no')">Include section</a></html> from the SCI Studio Help File. | ||
Line 132: | Line 132: | ||
<blockquote> | <blockquote> | ||
<div class="CodeBlockHeader">Example:</div> | <div class="CodeBlockHeader">Example:</div> | ||
− | <syntaxhighlight lang="sci">(use "obj")</syntaxhighlight> | + | <syntaxhighlight lang="sci" class="cs">(use "obj")</syntaxhighlight> |
For more information on use statements, refer to the section in the <html><a href="javascript:void(0)" onclick="window.open('http://sierrahelp.com/SCI/Definitions/Use.html', 'Use','width=750,height=375,scrollbars=yes')">Use section</a></html> from the SCI Studio Help File. | For more information on use statements, refer to the section in the <html><a href="javascript:void(0)" onclick="window.open('http://sierrahelp.com/SCI/Definitions/Use.html', 'Use','width=750,height=375,scrollbars=yes')">Use section</a></html> from the SCI Studio Help File. | ||
Line 141: | Line 141: | ||
<blockquote> | <blockquote> | ||
<div class="CodeBlockHeader">Example:</div> | <div class="CodeBlockHeader">Example:</div> | ||
− | <syntaxhighlight lang="sci">(preload text)</syntaxhighlight> | + | <syntaxhighlight lang="sci" class="cs">(preload text)</syntaxhighlight> |
</blockquote> | </blockquote> | ||
|} | |} |
Latest revision as of 17:58, 5 August 2013
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 >