SlideShare uma empresa Scribd logo
1 de 26
Pauli Pinelli scripting in Second Life
Getting started in scripting in Second Life LSL stands for "Linden Scripting Language"  LSL is used to script the objects you will make in Second Life. This tutorial is intended for those who have never programmed before in Second Life or elsewhere.  Scripting is harder to learn than basic object manipulation, but is very rewarding once you make progress. You will begin by running the standard “Hello Avatar " script and eventually move towards making your own.
What is LSL? Linden Scripting Language’s structure is based on Java and C. Scripts in Second Life are a set of instructions that can be placed inside any object in the world, or any object worn by an avatar, but not inside an avatar.  They are written with a built-in editor/compiler.  LSL  has heavy emphasis on "States" and "Events". Many real life objects have "states" A door can be "open" or "closed" and a light can be "on" or "off".  A person can be "hyper", "calm", or "bored".  a script will have at least one state, the default state.  An event can be thought of as a "Trigger". Events are predefined in LSL. Touch_start(), will trigger the code in it when the object having the script is touched.
WHAT CAN I DO WITH SCRIPTS?  Scripts can make an object: Move Listen Talk Operate as a car or gun Change color, size or shape  Talk to you Talk to another.
WHAT CAN I DO WITH SCRIPTS?  "Prim" or primitive, the basic building block can have a script. When several prims are linked, they can each contain a script which speaks to the rest of the object via Link Messages.  Here we focus on single scripts in a single prim.  If you've built in Second Life, everything you can define in the edit window can be defined in a script.  All interaction you see between objects or between avatars and objects is via scripts.  Learning more about the world and building model is vital to some aspects of scripting
Running Your First Script Traditionally one starts by writing the smallest program to print "hello world“. Since LSL only runs inside objects, you must know how to make an object and put a script inside it. You must be on land which allows building. In the edit window you may five tabs marked general, object, features, content, and texture.  Click "content".
Running Your First Script Press "new script" to add a new script.  This will open the LSL editor with a default script.  This editor will color code your syntax and provide some info about keywords when you hold your mouse over them. It will also do basic syntax checking.  Hit "save" and close your edit window (not the LSL editor window) You should see the words "Hello Avatar" from "object“  If you touch the object, it will say "Touched.“  (make sure the "edit" building window is closed for touching to work.  GOOD! You have compiled and run your first LSL script!
The script: When I am in the default state, and I am touched, say "Hello World" on channel zero".
Write, run, RE-write Most scripts you make won't run the first time you run them.  When you hit "save" on a script, the LSL editor "compiles" the code to form LSL can understand. It stops if it finds an error.  Brackets, parenthesis, and semicolons must all be perfectly in place  If you are new to programming this can be  frustrating Part of a programming in ANY language is learning how to precisely define steps and correctly type them into the language you are working in.  Thus you will find yourself writing, running, then RE-writing your code several times.  The script you made runs the instant you hit save. If you take it into inventory, it will "suspend" what it was doing but go right back to it when rezzedagain Each time you re-write your code you must save the script.
A Closer Look
STATES  A "State" in LSL is a section that is running, and waiting for events. Only one state can be active at any one time per script.  Every script must have a default state with at least one event in it. Except for the default state, each state is define by the word STATE followed by the name of the state.  The contents of the state are enclosed in two curly brackets.
EVENTS  Events are inside of states. When a state is active, those events wait to be triggered and run the code inside them.  "state entry" which is trigged by the a state being entered "touch start" which is triggered when you, or anyone, touches an object. Lets take a look at the default code. default // state{ touch_start(integer total_number) // this is an event 	{ 		// this is the content of the event 	} 	// end of event } // end of state
FUNCTIONS  Functions lay inside of events and are either defined by you or built-in.  Those built in to LSL all start with two lower case L's. ex. llSay()  Functions take "arguments" or values in the parentheses that follow it If you hover over the function in the editor, a popup will show that tell you what the function is expecting. In the case of llSay it expects a number and a string.  llSay(0, "Touched.");
Putting it all together
After saving your script occurs following: The instant you save your script, it enters default state, which in turns runs the "state_entry" event which in turn runs the function llSay() which makes the object talk.  After this the program waits idle in the default state until a new event is called.  Touching the box triggers the even "touch_start" which also makes the object speak.
Introducing States and Events LSL scripts will not run beginning to end . Instead they will look for a default state and wait for an event. Within those events, there can be a call to go to a new state. Lets look at a script with two states with two events in each.
A simplification of this would be default  {//set color to light and, if touched, enter the "off" state. } state off {//set color to dark and, if touched, enter the "default" state. } Note that after "default" all new states begin with the word "state".
A closer look llSay(0, "turning on!"); Channel zero is the channel you see all public chat on. A semicolon ends the line.  llSetColor(<0,0,0>, ALL_SIDES); This turns the prim to it's brightest tint. You see it as bright white . The three 0's stand for the black and the three 1's stand for the white.
Program creates a loop 1. Enters default state 2. Runs code in "state entry" 3. Waits to be touched. 4. When touched enters "state off" 5. Enters "state off". 6. Runs code in "state entry" in the "off" state's body 7. Waits to be touched in the "off" state's body 8. When touched enters "default" state. Where the whole thing starts over.
Objects speaking is a great way to know what a script is doing  As you get into more complex scripts this can get pretty noisy to the surrounding people!  llWhisper( ) is just like llSay( ) but only broadcasts at half the distance. llWhisper(0,"turnign on!"); //might work a bit to save the sanity of your neighbors.  Using llShout( ) doubles the distance heard, but can cut the amount of friends you have in SL.  llOwnerSay( ) uses no channel and is heard only by you.llOwnerSay("turnign on!");
Totally silent message via llSetText( ) You can make a totally silent message via llSetText( ) like this. llSetText("I am on", <1,1,1>,1.0); <1,1,1>, means "white" and <0,0,0> means "black". Replace the llSay(0,"turnign off!"); with... The 1.0 is the alpha setting. 1.0 means fully opaque, and 0.0 would be completely transparent (invisible).  Read about programming in SL wiki. http://wiki.secondlife.com/wiki/SL_Cert_-_Basic_Scripting
http://wiki.secondlife.com/wiki/Category:LSL_Functions
http://wiki.secondlife.com/wiki/Category:LSL_Events
Do the scripting!

Mais conteúdo relacionado

Semelhante a Getting Started Scripting in Second Life (LSL

Debugging NET Applications With WinDBG
Debugging  NET Applications With WinDBGDebugging  NET Applications With WinDBG
Debugging NET Applications With WinDBGCory Foy
 
Behavior Driven Development with Rails
Behavior Driven Development with RailsBehavior Driven Development with Rails
Behavior Driven Development with RailsMark Menard
 
Introducing small basic
Introducing small basicIntroducing small basic
Introducing small basicSara Samol
 
1.2 statements, properties, and operations
1.2   statements, properties, and operations1.2   statements, properties, and operations
1.2 statements, properties, and operationsallenbailey
 
Synthesis Examples
Synthesis ExamplesSynthesis Examples
Synthesis ExamplesMohamed Samy
 
Introducing small basic
Introducing small basicIntroducing small basic
Introducing small basicAn I
 
Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As CompDavid Halliday
 
Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As CompDavid Halliday
 
C++ Course - Lesson 1
C++ Course - Lesson 1C++ Course - Lesson 1
C++ Course - Lesson 1Mohamed Ahmed
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!olracoatalub
 
2javascript web programming with JAVA script
2javascript web programming with JAVA script2javascript web programming with JAVA script
2javascript web programming with JAVA scriptumardanjumamaiwada
 
Switch case and looping new
Switch case and looping newSwitch case and looping new
Switch case and looping newaprilyyy
 
Introduction to Erlang Programming Language
Introduction to Erlang Programming LanguageIntroduction to Erlang Programming Language
Introduction to Erlang Programming LanguageYasas Gunarathne
 

Semelhante a Getting Started Scripting in Second Life (LSL (20)

Debugging NET Applications With WinDBG
Debugging  NET Applications With WinDBGDebugging  NET Applications With WinDBG
Debugging NET Applications With WinDBG
 
Behavior Driven Development with Rails
Behavior Driven Development with RailsBehavior Driven Development with Rails
Behavior Driven Development with Rails
 
Lsl scripts
Lsl scriptsLsl scripts
Lsl scripts
 
Introducing Small Basic.pdf
Introducing Small Basic.pdfIntroducing Small Basic.pdf
Introducing Small Basic.pdf
 
Introducing small basic
Introducing small basicIntroducing small basic
Introducing small basic
 
1.2 statements, properties, and operations
1.2   statements, properties, and operations1.2   statements, properties, and operations
1.2 statements, properties, and operations
 
Synthesis Examples
Synthesis ExamplesSynthesis Examples
Synthesis Examples
 
Introducing small basic
Introducing small basicIntroducing small basic
Introducing small basic
 
Intro To Scratch
Intro To ScratchIntro To Scratch
Intro To Scratch
 
Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As Comp
 
Programming For As Comp
Programming For As CompProgramming For As Comp
Programming For As Comp
 
C++ Course - Lesson 1
C++ Course - Lesson 1C++ Course - Lesson 1
C++ Course - Lesson 1
 
Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!Yeahhhh the final requirement!!!
Yeahhhh the final requirement!!!
 
My final requirement
My final requirementMy final requirement
My final requirement
 
C#/.NET Little Pitfalls
C#/.NET Little PitfallsC#/.NET Little Pitfalls
C#/.NET Little Pitfalls
 
2javascript web programming with JAVA script
2javascript web programming with JAVA script2javascript web programming with JAVA script
2javascript web programming with JAVA script
 
Scripting The Dom
Scripting The DomScripting The Dom
Scripting The Dom
 
Switch case and looping new
Switch case and looping newSwitch case and looping new
Switch case and looping new
 
Words in Code
Words in CodeWords in Code
Words in Code
 
Introduction to Erlang Programming Language
Introduction to Erlang Programming LanguageIntroduction to Erlang Programming Language
Introduction to Erlang Programming Language
 

Último

Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 

Último (20)

Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 

Getting Started Scripting in Second Life (LSL

  • 1. Pauli Pinelli scripting in Second Life
  • 2. Getting started in scripting in Second Life LSL stands for "Linden Scripting Language" LSL is used to script the objects you will make in Second Life. This tutorial is intended for those who have never programmed before in Second Life or elsewhere. Scripting is harder to learn than basic object manipulation, but is very rewarding once you make progress. You will begin by running the standard “Hello Avatar " script and eventually move towards making your own.
  • 3. What is LSL? Linden Scripting Language’s structure is based on Java and C. Scripts in Second Life are a set of instructions that can be placed inside any object in the world, or any object worn by an avatar, but not inside an avatar. They are written with a built-in editor/compiler. LSL has heavy emphasis on "States" and "Events". Many real life objects have "states" A door can be "open" or "closed" and a light can be "on" or "off". A person can be "hyper", "calm", or "bored". a script will have at least one state, the default state. An event can be thought of as a "Trigger". Events are predefined in LSL. Touch_start(), will trigger the code in it when the object having the script is touched.
  • 4. WHAT CAN I DO WITH SCRIPTS? Scripts can make an object: Move Listen Talk Operate as a car or gun Change color, size or shape Talk to you Talk to another.
  • 5. WHAT CAN I DO WITH SCRIPTS? "Prim" or primitive, the basic building block can have a script. When several prims are linked, they can each contain a script which speaks to the rest of the object via Link Messages. Here we focus on single scripts in a single prim. If you've built in Second Life, everything you can define in the edit window can be defined in a script. All interaction you see between objects or between avatars and objects is via scripts. Learning more about the world and building model is vital to some aspects of scripting
  • 6. Running Your First Script Traditionally one starts by writing the smallest program to print "hello world“. Since LSL only runs inside objects, you must know how to make an object and put a script inside it. You must be on land which allows building. In the edit window you may five tabs marked general, object, features, content, and texture. Click "content".
  • 7. Running Your First Script Press "new script" to add a new script. This will open the LSL editor with a default script. This editor will color code your syntax and provide some info about keywords when you hold your mouse over them. It will also do basic syntax checking. Hit "save" and close your edit window (not the LSL editor window) You should see the words "Hello Avatar" from "object“ If you touch the object, it will say "Touched.“ (make sure the "edit" building window is closed for touching to work. GOOD! You have compiled and run your first LSL script!
  • 8. The script: When I am in the default state, and I am touched, say "Hello World" on channel zero".
  • 9. Write, run, RE-write Most scripts you make won't run the first time you run them. When you hit "save" on a script, the LSL editor "compiles" the code to form LSL can understand. It stops if it finds an error. Brackets, parenthesis, and semicolons must all be perfectly in place If you are new to programming this can be frustrating Part of a programming in ANY language is learning how to precisely define steps and correctly type them into the language you are working in. Thus you will find yourself writing, running, then RE-writing your code several times. The script you made runs the instant you hit save. If you take it into inventory, it will "suspend" what it was doing but go right back to it when rezzedagain Each time you re-write your code you must save the script.
  • 11. STATES A "State" in LSL is a section that is running, and waiting for events. Only one state can be active at any one time per script. Every script must have a default state with at least one event in it. Except for the default state, each state is define by the word STATE followed by the name of the state. The contents of the state are enclosed in two curly brackets.
  • 12. EVENTS Events are inside of states. When a state is active, those events wait to be triggered and run the code inside them. "state entry" which is trigged by the a state being entered "touch start" which is triggered when you, or anyone, touches an object. Lets take a look at the default code. default // state{ touch_start(integer total_number) // this is an event { // this is the content of the event } // end of event } // end of state
  • 13. FUNCTIONS Functions lay inside of events and are either defined by you or built-in. Those built in to LSL all start with two lower case L's. ex. llSay() Functions take "arguments" or values in the parentheses that follow it If you hover over the function in the editor, a popup will show that tell you what the function is expecting. In the case of llSay it expects a number and a string. llSay(0, "Touched.");
  • 14. Putting it all together
  • 15. After saving your script occurs following: The instant you save your script, it enters default state, which in turns runs the "state_entry" event which in turn runs the function llSay() which makes the object talk. After this the program waits idle in the default state until a new event is called. Touching the box triggers the even "touch_start" which also makes the object speak.
  • 16. Introducing States and Events LSL scripts will not run beginning to end . Instead they will look for a default state and wait for an event. Within those events, there can be a call to go to a new state. Lets look at a script with two states with two events in each.
  • 17.
  • 18. A simplification of this would be default {//set color to light and, if touched, enter the "off" state. } state off {//set color to dark and, if touched, enter the "default" state. } Note that after "default" all new states begin with the word "state".
  • 19. A closer look llSay(0, "turning on!"); Channel zero is the channel you see all public chat on. A semicolon ends the line. llSetColor(<0,0,0>, ALL_SIDES); This turns the prim to it's brightest tint. You see it as bright white . The three 0's stand for the black and the three 1's stand for the white.
  • 20. Program creates a loop 1. Enters default state 2. Runs code in "state entry" 3. Waits to be touched. 4. When touched enters "state off" 5. Enters "state off". 6. Runs code in "state entry" in the "off" state's body 7. Waits to be touched in the "off" state's body 8. When touched enters "default" state. Where the whole thing starts over.
  • 21. Objects speaking is a great way to know what a script is doing As you get into more complex scripts this can get pretty noisy to the surrounding people! llWhisper( ) is just like llSay( ) but only broadcasts at half the distance. llWhisper(0,"turnign on!"); //might work a bit to save the sanity of your neighbors. Using llShout( ) doubles the distance heard, but can cut the amount of friends you have in SL. llOwnerSay( ) uses no channel and is heard only by you.llOwnerSay("turnign on!");
  • 22. Totally silent message via llSetText( ) You can make a totally silent message via llSetText( ) like this. llSetText("I am on", <1,1,1>,1.0); <1,1,1>, means "white" and <0,0,0> means "black". Replace the llSay(0,"turnign off!"); with... The 1.0 is the alpha setting. 1.0 means fully opaque, and 0.0 would be completely transparent (invisible). Read about programming in SL wiki. http://wiki.secondlife.com/wiki/SL_Cert_-_Basic_Scripting
  • 25.