Game Development Reference
In-Depth Information
Line 11 has a new function to tell the object to do. This function, like the llSay() function, also needs
some information, put inside its parentheses, called parameters. The typical syntax for the function
and all that it expects to have on its line is this:
llSetColor(vector color, integer face);
What this means is that you must deine the color in terms of red, green, and blue percentages, and you
have to specify which faces on the object should change color. Note: you can ind out the number of a par-
ticular face by selecting with the Build/Edit menu/Select Face and looking at the notation just above the tabs
line on the menu interface.
As we discussed in Chapter 7, color is indicated by percentages (0% or 0 to 100% or 1) in a virtual
world. Within this function, to obtain the color primary bright red, we ask for R = 1.0, G = 0, and Blue = 0,
which is indicated between < and > or the pointy brackets, and would look like this <1.0,0,0> or this
<1.0,0.0,0.0> . Leave the extra spaces out between the numbers; the commas will do the separation for
the compiler.
To make sure all the sides of the cube change, we are going to use a constant, which is indicated in
CAPS at the end of the function. ALL _ SIDES indicates that all the sides are chosen. It is important to use
ALL _ SIDES in this little script because various primitives (or objects) will have varying numbers of sides.
This will cover all possibilities from the one-sided sphere to the seven-sided hollow cube that numbers its
faces from 0-6.
Line 12 is blank for clarity purposes.
Line 13 closes the script block that has the llSetColor () function in it with the curly bracket or }.
Line 14 is blank for clarity purposes.
Line 15 closes the irst script block and sends our cube back to the default state.
14.5.4 r eVieW of B asiC s CripT e lemenTs
Now, to recap what we have seen so far. We have looked at three very basic scripts in LSL. All of these
scripts had a default state and other states enclosed by  {  and  }. These states contained events such as
touch _ start . We also had some LSL functions, such as llSay() and llSetColor() , and these func-
tions asked for integers as well as constants. All of these terms and more are deined in much greater detail
in the Second Life LSL Wiki (http://wiki.secondlife.com/wiki/LSL_Portal).
14.5.5 s ome n eW s CripT e lemenTs : C onsTanTs and V ariaBles
Let's introduce a few more new terms that are common to many LSL scripts and how they might have an
impact on your design decisions.
Two of the most common elements in scripts are called Constant and Variable. Constants are values
that never change, and are expressed in ALL CAPS. For example, ALL_SIDES contained in the function
llSetColor(<1.0,0,0>,ALL_SIDES), is a constant.
Variables give you places to store data in the script for use as the server runs it. There are seven kinds of
data that can be contained in a variable: string, integer, loat, list, vector, rotation, and key. A string is a line
of text enclosed in quotes, like “Hello Avatar,” and an integer is a number, only a whole one, not fractions or
decimals. A loat is a number that has decimal places, like 1.0 or 2.5. Lists are special kinds of data enclosed
Search WWH ::




Custom Search