/
t-a-05-scripting-basics.html
110 lines (100 loc) · 15.3 KB
/
t-a-05-scripting-basics.html
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Storytron Tutorials - Scripting Basics</title>
<meta name="GENERATOR" content="Virtual Mechanics SiteSpinner V2 270f ">
<meta http-equiv="imagetoolbar" content="false">
<style type="text/css"><!--
.fsx01 {font-size: 11px;}
.fsx02 {font-size: 12px;}
.fsx03 {font-size: 13px;}
.fsx04 {font-size: 15px;}
.fsx05 {font-size: 16px;}
.fsx06 {font-size: 19px;}
.fsx07 {font-size: 21px;}
.fsx08 {font-size: 24px;}
.fsx09 {font-size: 27px;}
.fsx10 {font-size: 29px;}
.fsx11 {font-size: 32px;}
.fsx12 {font-size: 35px;}
.fsx13 {font-size: 37px;}
.fsx14 {font-size: 48px;}
.fsx15 {font-size: 64px;}
.fsx16 {font-size: 96px;}
.txdec {text-decoration: none;}
#centered{position:relative;width:984px;height:100%;margin:0px auto 0 auto;text-align:left;padding-left:1px;cursor:default}
#Oobj13 {position:absolute;z-index:1;visibility:visible;text-align:left;left:395px;top:70px;width:400px;height:71px;}
#Oobj15 {position:absolute;z-index:2;visibility:visible;text-align:left;left:208px;top:123px;width:765px;height:2048px;background-color:#ffffff;border-width:5px;border-style:solid;border-color:#ffffff;}
#Oobj446 {position:absolute;z-index:3;visibility:visible;left:0px;top:2px;width:200px;height:147px;}
#Oobj456 {position:absolute;z-index:4;visibility:visible;left:208px;top:-1px;width:775px;height:28px;}
#Oobj457 {position:absolute;z-index:5;visibility:visible;text-align:left;left:220px;top:0px;width:741px;height:27px;}
#Oobj459 {position:absolute;z-index:6;visibility:visible;left:208px;top:27px;width:775px;height:28px;}
#Oobj45 {position:absolute;z-index:7;visibility:visible;text-align:left;left:222px;top:2070px;width:740px;height:185px;}
input,textarea,select {color:#000000;font-family:'Times New Roman';font-size:16px;font-weight:normal;font-style:normal;text-decoration:none;}
.dfltt {font-family:'Times New Roman';font-size:16px;font-weight:normal;font-style:normal;text-decoration:none;text-align:left;color:#000000;}
.dfltc {font-family:'Times New Roman';font-size:16px;font-weight:normal;font-style:normal;text-decoration:none;text-align:left;color:#000000;}
body {margin:0px;text-align:center;height:100%;width:100%;}
-->
</style>
</head>
<body bgcolor="#dec4a6" alink="#ff0000" link="#8c6756" vlink="#747474" >
<div id="centered">
<div id="Oobj13">
<div id="Ggeo58" class="dfltt">
<div align="center"><font face="Bookman Old Style" class="fsx06"><B>SWAT TUTORIAL<br>
Scripting Basics<br></B></font></div>
</div>
</div>
<div id="Oobj15">
<div id="Ggeo60" class="dfltt">
<font face="Bookman Old Style" class="fsx04"><img src="images/t05-a.jpg" align="right" width="300" height="267"></font><font face="Bookman Old Style" class="fsx04">A Script is a tiny program that tells the Engine how to make things happen in your storyworld. Every Script starts with an Operator. Some Operators take no arguments, others take one or two arguments, and some even have three, four, five, six, or more arguments. <br>
<br>
Furthermore, Operators can take other Operators for arguments. So a Script is really just a bunch of Operators nested inside each other, just like a set of nested Russian Matroshka dolls.<br>
<br>
Sappho is the Storytronics scripting language, and it includes about 1,000 Operators for you to choose from. It has many special features to make scripting easier for the author. (See <a href="t27-odds-ends.html#about-sappho">About Sappho</a>.)<br>
<br>
A typical Script might read something like this: "Store (this answer) into the value for the Inclination." Of course, "this answer" could be a complicated group of Operators, but the basic structure is always the same: one Operator does one thing, but it can have several Operators inside it that it uses to do that one thing. And of course those subsidiary Operators can have subsidiary operators of their own, and on and on. For a detailed discussion of how fast an Operator can get complicated, see </font><font face="Bookman Old Style" class="fsx04" color="#0000ff"><a href="t-c-01-operators.html">Operators</a></font><font face="Bookman Old Style" class="fsx04">. <br>
<br>
Right now we're just going to make a very simple script for each of our </font><font face="Bookman Old Style" class="fsx04" color="#008000">Verbs</font><font face="Bookman Old Style" class="fsx04">. We'll start with an </font><font face="Bookman Old Style" class="fsx04" color="#ff0000">Inclination</font><font face="Bookman Old Style" class="fsx04"> Script. <br>
<br>
Select the </font><font face="Bookman Old Style" class="fsx04" color="#008000">Verb</font><font face="Bookman Old Style" class="fsx04"> "</font><font face="Bookman Old Style" class="fsx04" color="#008000">punch</font><font face="Bookman Old Style" class="fsx04">" and it will appear with its single </font><font face="Bookman Old Style" class="fsx04" color="#0000ff">Role</font><font face="Bookman Old Style" class="fsx04"> "</font><font face="Bookman Old Style" class="fsx04" color="#0000ff">punchee</font><font face="Bookman Old Style" class="fsx04">." The first </font><font face="Bookman Old Style" class="fsx04" color="#008000">Option</font><font face="Bookman Old Style" class="fsx04"> for "</font><font face="Bookman Old Style" class="fsx04" color="#0000ff">punchee</font><font face="Bookman Old Style" class="fsx04">" is "</font><font face="Bookman Old Style" class="fsx04" color="#008000">punch</font><font face="Bookman Old Style" class="fsx04">" (if your screen shows "</font><font face="Bookman Old Style" class="fsx04" color="#008000">run away from</font><font face="Bookman Old Style" class="fsx04">," use the </font><font face="Bookman Old Style" class="fsx04" color="#008000">Options</font><font face="Bookman Old Style" class="fsx04"> menu to choose "</font><font face="Bookman Old Style" class="fsx04" color="#008000">punch</font><font face="Bookman Old Style" class="fsx04">." This </font><font face="Bookman Old Style" class="fsx04" color="#008000">Option</font><font face="Bookman Old Style" class="fsx04">, like every other, has an </font><font face="Bookman Old Style" class="fsx04" color="#ff0000">Inclination</font><font face="Bookman Old Style" class="fsx04"> button. Click once on that </font><font face="Bookman Old Style" class="fsx04" color="#ff0000">Inclination</font><font face="Bookman Old Style" class="fsx04"> button, and you'll see the default </font><font face="Bookman Old Style" class="fsx04" color="#ff0000">Inclination</font><font face="Bookman Old Style" class="fsx04"> Script appear in the third (white) column to the right of the blue column. It's not much of a Script:</font><br>
<br>
<font face="Bookman Old Style" class="fsx04"><center><img src="images/t06-a.jpg" width="240" height="60"></center><br>
<br>
The title "Inclination" tells you that this is the </font><font face="Bookman Old Style" class="fsx04" color="#ff0000">Inclination</font><font face="Bookman Old Style" class="fsx04"> Script. Ignore the little "Script" button on the right edge for now. <br>
<br>
The default </font><font face="Bookman Old Style" class="fsx04" color="#ff0000">Inclination</font><font face="Bookman Old Style" class="fsx04"> Script has a value of </font><font face="Bookman Old Style" class="fsx04" color="#ff0000">0.0</font><font face="Bookman Old Style" class="fsx04">. Click on that number. Some new buttons appear above it, and some of the buttons along the right edge of the window activate. Those buttons along the right edge are actually menus. Click on one of those active menu buttons and a menu will pop up. Don't select anything from the menu just yet; to dismiss the menu, just click anywhere else. <br>
<br>
Above the word "Inclination" is an octagonal button labeled "</font><font face="Bookman Old Style" class="fsx04" color="#ff0000">BNumberConstant</font><font face="Bookman Old Style" class="fsx04">." Select that item and a dialog box appears:<br>
<br>
<center><img src="images/t6-b.jpg" width="254" height="151"></center><br>
<br>
This handsome fellow is our Fearless Leader, Chris Crawford, who is widely admired for his elegance and savoir faire. You can type in a number, so just type in .5 and click on the "OK" button. Ta-da! The value you typed in appears now in the Script. Your </font><font face="Bookman Old Style" class="fsx04" color="#ff0000">Inclination</font><font face="Bookman Old Style" class="fsx04"> Script asserts that the </font><font face="Bookman Old Style" class="fsx04" color="#ff0000">Inclination</font><font face="Bookman Old Style" class="fsx04"> to choose this </font><font face="Bookman Old Style" class="fsx04" color="#008000">Option</font><font face="Bookman Old Style" class="fsx04"> is </font><font face="Bookman Old Style" class="fsx04" color="#ff0000">0.5</font><font face="Bookman Old Style" class="fsx04">.</font><br>
<br>
<font face="Bookman Old Style" class="fsx04">That's a boring </font><font face="Bookman Old Style" class="fsx04" color="#ff0000">Inclination</font><font face="Bookman Old Style" class="fsx04"> Script. It means that anybody and everybody will always have an </font><font face="Bookman Old Style" class="fsx04" color="#ff0000">Inclination</font><font face="Bookman Old Style" class="fsx04"> of </font><font face="Bookman Old Style" class="fsx04" color="#ff0000">0.5</font><font face="Bookman Old Style" class="fsx04"> to take the "</font><font face="Bookman Old Style" class="fsx04" color="#008000">punch</font><font face="Bookman Old Style" class="fsx04">" </font><font face="Bookman Old Style" class="fsx04" color="#008000">Option</font><font face="Bookman Old Style" class="fsx04">. It doesn't care who they are, how they feel, or anything else. </font><font face="Bookman Old Style" class="fsx04">Let's improve on it. </font><br>
<br>
<font face="Bookman Old Style" class="fsx04">The red </font><font face="Bookman Old Style" class="fsx04" color="#ff0000">0.5 </font><font face="Bookman Old Style" class="fsx04">should still be highlighted; if it isn't, click once on it to select it. From the menus along the right edge of the window, click on the "Mood" menu and you'll see five Operators. The middle one is "</font><font face="Bookman Old Style" class="fsx04" color="#ff0000">Fearful_Angry</font><font face="Bookman Old Style" class="fsx04">." That sounds pretty good for a situation like this; if an </font><font face="Bookman Old Style" class="fsx04" color="#0000ff">Actor</font><font face="Bookman Old Style" class="fsx04"> is angry, he'll be more likely to "</font><font face="Bookman Old Style" class="fsx04" color="#008000">punch.</font><font face="Bookman Old Style" class="fsx04">" Select the "</font><font face="Bookman Old Style" class="fsx04" color="#ff0000">Fearful_Angry</font><font face="Bookman Old Style" class="fsx04">" Operator and it replaces the </font><font face="Bookman Old Style" class="fsx04" color="#ff0000">0.5</font><font face="Bookman Old Style" class="fsx04"> in the Script. But now there's a new element as well:<br>
<br>
<center><img src="images/t6-c.jpg" width="223" height="63"></center><br>
<br>
Where'd that </font><font face="Bookman Old Style" class="fsx04" color="#0000ff">ReactingActor</font><font face="Bookman Old Style" class="fsx04"> Operator come from? It's what's called a <I>default value</I>. SWAT automatically inserts the most likely Operator in certain cases. In the great majority of Scripts, we have found that authors almost always enter </font><font face="Bookman Old Style" class="fsx04" color="#0000ff">ReactingActor</font><font face="Bookman Old Style" class="fsx04"> in a spot like this. So we automatically put it there for you, saving you a little time. Isn't that sweet?<br>
<br>
Of course, you don't have to accept our default value; if you want to put something else in there, you're welcome to do so. However, in this case, it's the correct value, because </font><font face="Bookman Old Style" class="fsx04" color="#0000ff">ReactingActor</font><font face="Bookman Old Style" class="fsx04"> always means "the </font><font face="Bookman Old Style" class="fsx04" color="#0000ff">Actor</font><font face="Bookman Old Style" class="fsx04"> who has assumed this </font><font face="Bookman Old Style" class="fsx04" color="#0000ff">Role</font><font face="Bookman Old Style" class="fsx04">." Hence, this Script means that the </font><font face="Bookman Old Style" class="fsx04" color="#0000ff">punchee's</font><font face="Bookman Old Style" class="fsx04"> </font><font face="Bookman Old Style" class="fsx04" color="#ff0000">Inclination</font><font face="Bookman Old Style" class="fsx04"> to punch back is equal to how angry the </font><font face="Bookman Old Style" class="fsx04" color="#0000ff">punchee</font><font face="Bookman Old Style" class="fsx04"> is. <br>
<br>
Next we'll tackle a more complex Script, and one you'll probably be using a lot: the AssumeRoleIf Script.<br>
<br>
<hr><br></font><div align="center"><font face="Bookman Old Style" class="fsx03">Previous tutorial: <a href="t-a-04-verbs.html">Verbs</a> Next tutorial: <a href="t-a-06-scripting-exercise.html">Scripting Exercise: AssumeRoleIf</a><br><br></div></font><div align="left"><font face="Bookman Old Style"><hr></font><font face="Bookman Old Style" class="fsx01"><U>Copyright notice</U><br>
The </font><font face="Bookman Old Style" class="fsx01" color="#0000ff"><a href="http://commons.wikimedia.org/wiki/Image:Gzhel_russiandolls.jpg">Russian Matroshka Dolls image</a></font><font face="Bookman Old Style" class="fsx01"> by Khmelev Ltd. was taken from Wikimedia Commons, and is in the public domain. <br></font></div>
</div>
</div>
<div id="Oobj456">
<img name="Ggeo288" src="http://www.storytron.com/Tutorial/geometry/obj456geo288shd7p407.jpg" alt="" border = "0" width="775" height="28"></div>
<div id="Oobj457">
<div id="Ggeo289" class="dfltt">
<div align="center"><font face="Bookman Old Style" color="#ffffff"><a href="index.html" class="txdec"><font class="txdec" color="#f9f3ee">Home</font></a> <a href="http://www.storytron.com/Tutorial/sitemap.html" class="txdec"><font class="txdec" color="#f9f3ee">SiteMap</font></a> <a href="http://www.storytron.com/Tutorial/feedback.html" class="txdec"><font class="txdec" color="#f9f3ee">Feedback</font></a> <a href="http://www.storytron.com/Tutorial/faq.html" class="txdec"><font class="txdec" color="#f9f3ee">FAQ</font></a> <a href="http://www.storytron.com/Tutorial/pressroom.html" class="txdec"><font class="txdec" color="#ffffff">Press Room</font></a> <a href="http://www.storytron.com/Tutorial/privacy-policy.html" class="txdec"><font class="txdec" color="#ffffff">Privacy Policy</font></a> <a href="http://www.storytron.com/Tutorial/ipb/index-54403.html" target="_blank" class="txdec"><font class="txdec" color="#ffffff">Login</font></a><br></font></div>
</div>
</div>
</body>
</html>
<!-- Localized -->