LSL Scripting

3,908 views

Published on

Second Life uses Linden Scripting Language to create interactive settings. This basics lesson covers about 60 minutes of overview and highlights a few interesting examples.

Published in: Technology, Education
0 Comments
4 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,908
On SlideShare
0
From Embeds
0
Number of Embeds
47
Actions
Shares
0
Downloads
49
Comments
0
Likes
4
Embeds 0
No embeds

No notes for slide

LSL Scripting

  1. 1. Beginning Scripting LIB 287 - Jeremy Kemp
  2. 2. Second Life <ul><li>Avatar customization </li></ul><ul><li>Community Building </li></ul><ul><li>3D Modeling </li></ul><ul><li>Economy </li></ul><ul><li>Object Interactions </li></ul>
  3. 3. Linden Scripting Language <ul><li>“ LSL” makes objects interactive </li></ul><ul><li>Allows commerce, serious gaming, interfaces, web connectivity </li></ul><ul><li>“ event execution model” (unique in this way) </li></ul><ul><li>Awkward use of data </li></ul><ul><li>Linked objects may perform independent actions </li></ul>
  4. 4. Variables hold data <ul><li>They come in flavors (types) </li></ul><ul><li>Have meaning to the ENTIRE script or only a portion of it </li></ul><ul><li>Using them properly is one of the hardest jobs in scripting </li></ul>
  5. 5. Variable Types <ul><li>Float = floating point or real number </li></ul><ul><li>Integer = positive whole number </li></ul><ul><li>String = a text word or phrase </li></ul><ul><li>Vector = a set of three floats </li></ul><ul><ul><li>rgb color, xyz pos, xyz vel, xyz accel </li></ul></ul><ul><li>Key = uuid - object identity </li></ul><ul><li>Rotation = x,y,z,s - hard! </li></ul><ul><li>List = rough database </li></ul>
  6. 6. Global vs Local Variables <ul><li>Declare global variables at top of the script - they are usable throughout </li></ul><ul><li>Declare local variables inside the block it will be used in </li></ul>
  7. 7. Typecasting <ul><li>a=(string)b </li></ul>
  8. 8. Rotate script <ul><li>default </li></ul><ul><li>{ </li></ul><ul><li>state_entry() </li></ul><ul><li>{ </li></ul><ul><li>llTargetOmega( < 0, 0, 1 >, .01, 1.0 ); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  9. 9. URL Loader script <ul><li>default </li></ul><ul><li>{ touch_start(integer total_number) </li></ul><ul><li>{ </li></ul><ul><li>llLoadURL(llDetectedKey(0), &quot;Name&quot;, “site.com&quot;); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  10. 10. Giver script <ul><li>default </li></ul><ul><li>{ touch_start(integer total_number) </li></ul><ul><li>{ </li></ul><ul><li>llGiveInventory(llDetectedKey(0), “item”); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  11. 11. Hello World <ul><li>default </li></ul><ul><li>{ </li></ul><ul><li>state_entry() </li></ul><ul><li>{ </li></ul><ul><li>llSay(0, &quot;Hello, Avatar!&quot;); </li></ul><ul><li>} </li></ul><ul><li>touch_start(integer total_number) </li></ul><ul><li>{ </li></ul><ul><li>llSay(0, &quot;Touched.&quot;); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  12. 12. Floating text <ul><li>default </li></ul><ul><li>{ </li></ul><ul><li>state_entry() </li></ul><ul><li>{ </li></ul><ul><li>llSetText(&quot;Text&quot;, <1,1,1>, 2.0); </li></ul><ul><li>} </li></ul><ul><li>} </li></ul>
  13. 13. Color by Numbers
  14. 14. Other Possible Events <ul><li>collision(integer total_number) </li></ul><ul><li>sensor(integer total_number) </li></ul><ul><li>money(key giver, integer amount) </li></ul><ul><li>changed(integer changed) </li></ul>
  15. 15. Loops <ul><li>for (j = 0; j < count; j++) </li></ul><ul><li>{ // do stuff here } </li></ul><ul><li>do </li></ul><ul><li>{ </li></ul><ul><li>// do stuff here and increment j </li></ul><ul><li>} while (j < count); </li></ul><ul><li>while (j < count) </li></ul><ul><li>{ // do stuff here and increment j } </li></ul>
  16. 16. More info <ul><li>http: //lslwiki .net </li></ul><ul><ul><li>LSL 101: The Complete Newbie's Guide to Scripting in Second Life </li></ul></ul><ul><li>http://slurl.com/secondlife/Daydream%20SE%20Islands/206/40 </li></ul><ul><ul><li>Bromley College walkthrough </li></ul></ul>

×