Modifying Objects
It is possible to modify objects using the Linden Scripting Language. Every aspect of an object can be modified using script. A large number of functions in the Linden Scripting Language allow the script to change the numerous properties available.
A number of these functions will be used by later recipes in this book. A script that changes the color of an object is shown here. This script will change the object to red, blue or green, depending on what the user says.
integer CHANNEL = 0;
default
{
state_entry()
{
llListen(CHANNEL, "", NULL_KEY, "");
}
listen(integer channel, string name, key id,
string message)
{
if( llToLower(message) == "red" )
{
llSetColor(<255,0,0>,ALL_SIDES);
}
else if( llToLower(message) == "green" )
{
llSetColor(<0,255,0>,ALL_SIDES);
}
else if( llToLower(message) == "blue" )
{
llSetColor(<0,0,255>,ALL_SIDES);
}
}
}To change the color of an object, the above code uses the llSetColor function. This function must be passed two parameters. The first is a vector specifying the desired color. The second parameter specifies to which side this color should be applied. For this example, the ALL_SIDES constant is used, which specifies that all of the sides should be set to the specified color.
The color value is specified as a vector. For example, <255,0,0> specifies the color red. The first number is red, the second green, and the third blue. Using red, green and blue values of nearly any color can be specified. The valid range for each color component is between zero and 255.












