SL SCRIPTING RESOURCES

SL Scripting Resources

.PDF GUIDES
Beginners Scirpt Guide .pdf
SL Script Basics (short)

LINKS (other links on these sites)
Note:  you can copy scripts out of the tutorial site, LSL reference help, or script library)
Linden Scripting Language Portal:  http://wiki.secondlife.com/wiki/LSL_Portal
Linden Scripting Language Tutorial Site: 
http://wiki.secondlife.com/wiki/LSL_Tutorial
LSL Example Scripts: 
http://wiki.secondlife.com/wiki/Category:LSL_Examples
LSL Script Library: 
http://wiki.secondlife.com/wiki/LSL_Library
** Ann Enigma's EZ Autoscript site:
http://www.3greeneggs.com/autoscript/
*** MIT's Scratch For SL (Lego Approach to Scripting):
http://web.mit.edu/~eric_r/Public/S4SL/
*** Mice On A Beam visualscripting app (you draw a flow chart for script operation), PC ONLY, Free and Professional versions.  http://www.miceonabeam.com/introduction/  


LSL NOTES:
Built on Java and C programming languages
Scripts only attach to primitives, not avatars
Scripts run on the servers, not in the client software (note "compiled" message when save script edits)
Your Scripts can be saved in Inventory > Scripts folder and dragged to an object to make a copy
"//" at the beginning of a script line makes line a “comment”, i.e. not executable (just like Flash actionscript)
Emphasis on "States" (settings) and "Events" (triggers) and "Functions" (live inside events, require specific input and, if they get it, supply specified output)
Minimal state is "default"
Events trigger event handlers to run (thereby changing settings or triggering more events)
Errors are shouted on the DEBUG channel

Event examples:
touch_start (runs some other event, e.g. llPlaySound, when object is touched)

Function examples:
LIPlaySound - play a sound in the prim's inventory -
http://wiki.secondlife.com/wiki/LlPlaySound
LIWhisper (chat heard for 10 meter radius), and IIOwner
LICollisonSound (play sound when avatar enters proximity zone)
LIAttachToAvatar - http://wiki.secondlife.com/wiki/LlAttachToAvatar
EDITING SCRIPTS:
IN-WORLD SCRIPT EDITOR: http://wiki.secondlife.com/wiki/Video_Tutorial/Script_editor_featurettes
DClick a script in Inventory/Scripts folder to open it
Note the "Hover Tips" pop up over script for help info
Help menu > LSL Wiki Help (check follow cursor to link your current subject as you work)

Example:  SOUND-PLAYING OBJECT  - Customize this to play YOUR sound file.  I have highlighted the STATE and the EVENT in this script.  Notice how the entire script is enclosed in curly-brackets and the STATE and the EVENT, after they declare themselves, enclose their “body” in curly brackets also.  In this .pdf you might need to CTL+select to copy this script text.
Default
{
    state_entry()
   {
    llWhisper(0, "Wanna hear a birdcall?");
    }
touch_start(integer total_number)
   {
    llPlaySound("birdcall",1.0);
    }

}
ATTACHING THE PLAYSOUND SCRIPT TO AN OBJECT
Upload a sound file:  File > Upload > Sound (must be wav, must be 44100Khz, 10 secs maximum, stereo or mono).  The sound goes into your Inventory/Sounds folder.
Create an object: RClick on Sandbox or public ground > Create and Take (to copy to your Inventory)
Create a script:  In your Inventory/Scripts folder, RClick > New Script, copy+paste in the text above, save it, name it
Copy the script text above – starting with "default" through the last "}" - into your Inventory/Scripts folder, save it, name it (can copy scripts out of tutorial site or LSL reference help, etc)
Drag script onto the object (goes into the Object/Content folder; RClick > Edit > Contents to see it)
Drag sound file from your Inventory > Sounds folder onto the object or into the object's Content folder
NOTE:  You can edit the script in your Inventory and then simply copy that to the object as described above OR you can copy a script form your inventory to the object and THEN customize it for that object.

To edit the script in the Object/Contents folder: Select object > RClick > Edit > Content
Note the sources of scripts at the top of this document.  The two external script makers (Ann Enigma and MIT) are fun and you can learn from using them.

SOURCES OF FREE SOUND EFFECTS FILES
(generally at the required 44100 KHz sample rate, but you have to check the file after you download it.  If it only plays when you click on it, RClick > Save Link As to download the file.  For more sites, just Google “free wav”