Game Development Reference
In-Depth Information
TABLE 14.2
A Basic Script in Second Life
Line No.
Script
What It Means in English
0
default
“Start here.”
1
{
Start of the script.
2
state_entry()
Event: transition to a new State and wait for instructions.
3
{
This is a new block of code.
4
llSay(0, “Hello, Avatar!”);
Function: say in local chat “Hello, Avatar!”
5
}
End of the block of code.
6
Blank Line.
7
touch_start(integer total_number) Event: do something when you are touched, activate the Function.
8
{
Next block of code starts.
9
Function: say in local chat “Touched.”
llSay(0, “Touched.”);
10
}
End of previous block of code.
11
All Events and Functions end here, and it is the end of the script.
Return to default State.
}
Line 10 closes that script block with the curly bracket }.
Line 11 closes the entire script and sends the script back to the default or standby, where it will wait
for another avatar's touch to activate the touch _ start event and its llSay() function again.
14.5.3 C reaTing a s CripT u sing a uTosCripT
Now, let's try making a script of your own with a little help from an online script generator. This process and
the script it generates can be used in either OpenSim or Second Life.
Here are the steps:
Step 1. Repeat the same procedure as previously and generate a new cube prim or object with a new
script in it. Click on the New Script in the contents and open the Script Editor again. It should have
the same new script in it that the previous one did.
Step 2. Open your web browser and go to http://www.3greeneggs.com/autoscript/. Autoscript is the
brilliant creation of Hilary Mason, a data scientist in her irst life; she goes by the name of Ann
Enigma in Second Life. As she describes in the introduction, the site “tries to map the way you think
into the way the LSL interpreter thinks.” Using this website will show you new ways to learn about
scripting and how to think like a scripter. Autoscript gives you two sections of options. The top one
covers some basic tasks that you would want the script to do, and the bottom one concerns itself with
the activation and timing of that action.
For our irst use of this, let's keep it simple.
Step 3. In the Script Editor window, select all of the old script in the text window and delete it out; you
will be pasting in the new autoscript script and need a clean slate.
Step 4. Go back over to the autoscript window. Pick the radio button that says “change the object's
color” in the top list and select “red” on the color drop-down text box that appears. Then, pick
“when an avatar touches your object” in the bottom list. Click on the Make My Script button to
generate the script. Select all of the new script that appears and copy/paste it into the empty script
window. The new script should look like the code on the left side of Table 14.3.
 
Search WWH ::




Custom Search