Upload
maud-mcdonald
View
230
Download
3
Embed Size (px)
Citation preview
CS590VC - Tutorial 3
Linden Scripting Language (LSL)
Getting started …….
• Create a box on the ground
• Select the box by clicking it
• Select Content tab of Build window -> new script
• Save the code that you write in the editor.
• The code will try to get compiled and then saved.
• Scripting language that runs on server side
• The running platform is a piece of software called simulator.
• Compilation into LSL bytecode
• Two basic concepts – states and events
LSL types
• Common types such as integer, float, string
• Group types: vector, list (no array for LSL)
• Position types: rotation
• UUID type: key
Positioning type - rotation
• Quaternion rotation – x, y, z and s components
• Example: rotation rot = <0.0, 0.0, 0.0, 1.0>;
http://lslwiki.net/lslwiki/wakka.php?wakka=rotation
Some scripting basics
• We start with a default state (multiple states are common)
• Event-based programming – hence event handlers
• Default event handlers: state_entry & touch_start
• Lot of library functions are available (starts with “ll*****”)
http://lslwiki.net/lslwiki/wakka.php?wakka=HomePage
Lets do something…..
• We first build a door
• We then program it to make it open and close using LSL
• You can find the tutorial video at http://www.youtube.com/watch?v=5CuqWC-1w88
Step 1: Create a slab & make copy (click and press shift -> drag)
Step 2: Create another copy & rotate slab
Step 3: position the slab that was rotated at the center of the pillars &
increase the length as shown
Step 4: Make a copy of the left pillar (“the door”) and position that
at the center
Step 5:a) Make another copy of the left pillar (position that a little left as highlighted in the shot)b) shift + cntrl -> you get the red buttons
Step 6: click the button and drag left to create a thin hinge for your door
Step 7: Link the door and the hinge by clicking both of them using shift
& then cntrl + L
Step 8: bring the left pillar back & rotate the door -90 degree using the
profile editor
Our door is created!!
We will now automate the opening and closing of the door
Step 9: Open the script editor
Step 10: Use this code in the editordefault { touch_start(integer total_number) { rotation rot = llGetLocalRot();
// string z = (string)rot.z; // string s = (string)rot.s; // llsay(0, “z = ” + z + “s = ” + s); if (rot.z == 0) { rot.z = -0.707107; rot.s = 0.707107; } else { rot.z = 0; rot.s = 1; } llSetLocalRot(rot); }}
References
• http://www.slbuilding.com/ - some very good scripting videos and source-code
• Second Life – the official guide (2nd ed.)