Game Development Reference
In-Depth Information
TABLE 14.4
Combining Two Functions in a Simple Script
Line No.
Script
What It Means in English
0
//This script was auto-generated by Ann Enigma's
script autogenerator
Comment: where the script came from.
1
//available at http://www.3greeneggs.com/autoscript/
Comment: how you can get one.
2
//Note: You will need to copy both this script and a
texture (named Texture_1) into your object
Comment: how to use this script.
3
default
“start here”
4
{
New block of code, start of new State.
5
Blank Line.
6
touch_start(integer total_number) {
Event = do something when touched
and start of next block of code.
7
Blank Line.
8
//change color!
Comment: what the next Function does.
9
llSetColor(<1.0,0,0>,ALL_SIDES);
Function = change color to red, all sides.
10
//set the texture
Comment: what the next Function does.
11
Function = change texture to the one
inside the object's contents, all sides.
llSetTexture(“Texture_1”,ALL_SIDES);
12
}
End of code block.
13
Blank Line.
14
}
End of script, return to default.
generates simple scripts that can be combined, and that also will broaden your LSL understanding. For example,
the llSetTexture () function from one could be combined with the llSetColor () function in our previ-
ous example to create a more dynamic script for your cube. All you need to do is generate another script that
changes the texture on the sides of the cube when touched. Copy and paste in the new lines of script from the
second script into the irst one, making sure that the new function is within the same brackets and state as the
irst one. To keep it simple in this example, both scripts begin with a touch _ start event handler. Table 14.4
analyzes the result of these two scripts combined. If you decide to test this inworld, note that the name of the
texture has an underscore in it, “Texture _ 1 , and is exactly how it needs to be named in the object's contents.
All that considered, nothing is better than working with a talented LSL scripter when you have a complex
project. The creative synergy that can develop when the team is trying to do new things with scripting and
building is well worth the fee that you may have to pay to obtain expert advice.
14.7 HOW TO TALK TO A SCRIPTER ABOUT LSL SCRIPTS YOU NEED
For most of this chapter, we have discussed the parts of some basic LSL scripts and how those parts work
together. This knowledge will come in handy when you sit down with a scripter to design a complex script.
Let's suppose you have a fancy apartment building in mind, and all the doors will be scripted to open at their
owners' verbal command. Also, you would like the apartment owners to have the option of adding a guest's
name to the door when the apartment is being lent. If you try to think about that like a scripter, what elements
of an LSL script do you begin to see? Try to ill in the plain English/right side of the script analysis table
(Table 14.5) irst so you will have a list from which the scripter can work.
 
Search WWH ::




Custom Search