19
CS590VC - Tutorial 3 Linden Scripting Language (LSL)

CS590VC - Tutorial 3 Linden Scripting Language (LSL)

Embed Size (px)

Citation preview

Page 1: CS590VC - Tutorial 3 Linden Scripting Language (LSL)

CS590VC - Tutorial 3

Linden Scripting Language (LSL)

Page 2: 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.

Page 3: CS590VC - Tutorial 3 Linden Scripting Language (LSL)

• 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

Page 4: CS590VC - Tutorial 3 Linden Scripting Language (LSL)

LSL types

• Common types such as integer, float, string

• Group types: vector, list (no array for LSL)

• Position types: rotation

• UUID type: key

Page 5: CS590VC - Tutorial 3 Linden Scripting Language (LSL)

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

Page 6: CS590VC - Tutorial 3 Linden Scripting Language (LSL)

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

Page 7: CS590VC - Tutorial 3 Linden Scripting Language (LSL)

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

Page 8: CS590VC - Tutorial 3 Linden Scripting Language (LSL)

Step 1: Create a slab & make copy (click and press shift -> drag)

Page 9: CS590VC - Tutorial 3 Linden Scripting Language (LSL)

Step 2: Create another copy & rotate slab

Page 10: CS590VC - Tutorial 3 Linden Scripting Language (LSL)

Step 3: position the slab that was rotated at the center of the pillars &

increase the length as shown

Page 11: CS590VC - Tutorial 3 Linden Scripting Language (LSL)

Step 4: Make a copy of the left pillar (“the door”) and position that

at the center

Page 12: CS590VC - Tutorial 3 Linden Scripting Language (LSL)

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

Page 13: CS590VC - Tutorial 3 Linden Scripting Language (LSL)

Step 6: click the button and drag left to create a thin hinge for your door

Page 14: CS590VC - Tutorial 3 Linden Scripting Language (LSL)

Step 7: Link the door and the hinge by clicking both of them using shift

& then cntrl + L

Page 15: CS590VC - Tutorial 3 Linden Scripting Language (LSL)

Step 8: bring the left pillar back & rotate the door -90 degree using the

profile editor

Page 16: CS590VC - Tutorial 3 Linden Scripting Language (LSL)

Our door is created!!

We will now automate the opening and closing of the door

Page 17: CS590VC - Tutorial 3 Linden Scripting Language (LSL)

Step 9: Open the script editor

Page 18: CS590VC - Tutorial 3 Linden Scripting Language (LSL)

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); }}

Page 19: CS590VC - Tutorial 3 Linden Scripting Language (LSL)

References

• http://www.slbuilding.com/ - some very good scripting videos and source-code

• Second Life – the official guide (2nd ed.)