LSL Scripts - Lesson One

SecondLife includes a facility for defining scripts within existing objects. To create an object, start SecondLife, log in, right-click on virtual ground or water and left-click "Create" on the circular menu that appears. When you do this, an "object manipulation menu" will open on the left side of your screen and your cursor will change to a "magic wand" when you hover over the ground again.
Left-click again on the ground. You will then hear a mysterious rumble and an object will appear. It will be some 3-dimensional geometric figure, such as a cube, cone or sphere. The colored lines emanating from that object are used for making certain positional changes in the object. (screen shot)
Return to the object manipulation menu, and if you see a "More>>" button, press it once, until the extended version of the menu opens.
Within the extended menu, left-click on the "Object" tab, and you will see options for changing the overall shape and dimensions of the currently selected object.
Left-click on the "Content" tab and you will see a list of scripts associated with the object. The "Contents" directory displayed within the "Content" tab will most likely be empty.
Left-click on the "New Script" button, and a "Script" editing window will open. The editing window has a "script editing area" where you can type or paste in a new script, and buttons for saving the script, undoing changes made, etc. It will look something like this:
The script editing area should contain the following script:
defaultLeft-click on the "Save" button. You should see the message "Compile successful, saving..." appear in the box below the script editing area. After a short pause you should see the message "Save complete." appear in that box as well.
{
state_entry()
{
llSay( 0, "Hello, Avatar!");
}
touch_start(integer total_number)
{
llSay( 0, "Touched.");
}
}
Once the script is saved, you will see the message "Hello, Avatar!" appear in the lower-left-hand corner of your screen. This message indicates that the script has started and waiting for touch events.
To test the object's responsiveness to "touch," close both the script editing and object manipulation windows, and right-click on the object. The circular object menu will appear from which you can select "Touch." You should then see "Object: Touched." appear in the lower-left-hand corner as well.
CPCC 3D Campus / SLC3

0 Comments:
Post a Comment
<< Home