SlideShare a Scribd company logo
1 of 22
THE DEFAULT SCRIPT
F/XUAL EDUCATION SERVICES
Investigating States, Events & Functions
Rez a prim and with it selected
display the Content tab.
Click on the New Script button to
create a new script.
Right click on the New Script icon
and select Rename from the menu.
Rename the script appropriately.
Right click on the script icon and
select Open from the menu OR
double click on the icon to open the
script.
The default script is displayed when the new script is opened.
Note that when the script was created the text Hello, Avatar! was displayed in main chat. Lines 2 to 5
show the EVENT that was triggered when the script was created (loaded into the prim). Line 4 is the
FUNCTION that generated the chat.
Scripts are comprised of STATES, the main state being the default state. This state is entered when a script
is compiled (saved), reset or loaded. More than one state may be defined, though one is the norm.
A script will react to EVENTS in the current state which are triggered by some occurrence or input, which
in turn run the FUNCTIONS defined in that event. Functions can be either the built-in functions of LSL or
user-defined functions. Curly brackets, i.e. { }, enclose the contents of a STATE or EVENT.
EVENTS may have built in parameters though the state_entry EVENT has none. This event is triggered when the
script is saved, when a STATE has been changed, when the script is reset or when the script is loaded into a prim.
The touch_start EVENT has one parameter, which is of the data type INTEGER (whole number). This event is
triggered when the prim is touched (clicked on by the down press of the left mouse button). The parameter
indicates the total number of avatars touching the prim during the last computing clock cycle.
Most FUNCTIONS also have built in parameters. The llSay FUNCTION has two, the first being the data type
INTEGER and the second the data type STRING. A string is text data and is contained between double quotes. Any
character can be used in a string.
All data types in LSL are immutable and built in parameters must be included in the EVENTS or FUNCTIONS.
The data types in LSL are; FLOAT, INTEGER, KEY, LIST, ROTATION, STRING and VECTOR.
To change the text generated by the llSay FUNCTION select the text between the double quotes in Line 4.
This parameter is the data type STRING and will be the text that is said when this function runs.
In the above example the text has been changed to Good morning Isa! To save the changes click on the
Save button (which is now highlighted due to some portion of the script being changed) OR press Ctrl S.
The script will be saved (compiled). This will trigger the state_entry EVENT which will run all the parts of
the script between the curly brackets { } from line 3 to 5. In this case it is the llSay FUNCTION that runs and
displays the text Good morning Isa! in main chat.
Every time a script is saved the state_entry EVENT is triggered. This will cause the llSay FUNCTION on line
4 to run. To prevent this happening it is possible to COMMENT out the function by placing two forward
slashes at the beginning of the line. This leaves the line visible in the script but does not compile this part
of the script when it is saved. Click on the Save button and you will see this function no longer runs.
Comments are a useful way of adding notes to remind you of the function of certain sections of code.
Help pop-ups can be accessed for all aspects of a script. For example holding the cursor over the
touch_start EVENT shows the pop-up above indicating that this event has one parameter, an INTEGER,
and that the event is triggered by the start (pressing the left mouse down) of agent (avatar) clicking on
task (the prim).
FUNCTIONS also have help pop-ups. In this example the llSay FUNCTION is shown to have two
parameters, an INTEGER and a STRING. When run the llSay FUNCTION will say the text of the STRING on
the chat channel indicated by the INTEGER. In this case the text Touched. will be said on channel 0, this
being the main public chat channel. A touch_start EVENT can only be tested with the prim deselected. A
script can be left open, altered and saved even when the prim is deselected. Test the touch_start EVENT.
LSL scripting syntax is very strict.
STATES and EVENTS must be enclosed in curly brackets { } and
lines of code within an EVENT must end with a semi-colon ;
All built in parameters must be included in EVENTS and
FUNCTIONS and must be enclosed in parentheses ( ), each of the
parameters must be delimited by a comma , and be in the correct
order and data types must be correct.
Code is also case sensitive so the correct case must be adhered
to, e.g. llSay not LLsay and touch_start not Touch_Start
If these rules are not met an error will occur when the script is
compiled (saved). The compiler will pause the cursor in the
vicinity of the error, usually the line after it occurs, so this is a
good indication of where the error is.
Linden Scripting Language SYNTAX
Continue with the script by adding a new FUNCTION into the touch_start EVENT.
Place the cursor at the end of line 9.
Press the Enter key to create a new line.
All EVENTS and FUNCTIONS can be accessed through the Insert button (though the newest additions to
LSL may take a little while becoming available in this menu). In this example the FUNCTION llOwnerSay
will be inserted. Click on the Insert button and scroll down the list till you see this function. Click on it to
insert it in the script.
As seen on line 10 the llOwnerSay FUNCTION has been inserted. Hold the cursor over the function to
display the help pop-up. This function has one parameter, a STRING. This string’s text will be said only to
the owner of the prim the script is in and the owner must be in the same sim as the prim to hear it.
The text will appear in the main chat window but will only be seen by the prim owner.
Complete the FUNCTION by adding parentheses ( ) and writing the STRING of text you wish to be seen
inside them. Ensure the text has double quotes around it, e.g. “Isa touched me”. Also ensure that the line
has been concluded with a semi-colon ; The line should look like: llOwnerSay(“Isa touched me”);
Comment out line 9 so that only the llOwnerSay function runs when the touch_start EVENT is triggered.
Click on the Save button to compile the script. Test the script by touching the prim.
It is also possible to add a FUNCTION within another FUNCTION. Currently the llOwnerSay FUNCTION in
the touch_start EVENT only says the text Isa touched me but doesn’t indicate who really touched the
prim. Anyone touching the prim will trigger this text to display. That can be changed.
Place the cursor after the first parenthesis in line 10 as shown above.
From the Insert button (which will currently display the name of the last item inserted, i.e. llOwnerSay)
find and insert the FUNCTION llDetectedName.
The FUNCTION llDetectedName has one parameter, an INTEGER, which accesses the list of avatars who
touched the prim. (This list is created by the touch_start EVENT.) Complete the script as shown in line 10.
The parameter 0 used in the llDetectedName FUNCTION accesses the first name in the list. It is extremely
unlikely that more than one avatar will touch a prim in one clock cycle so the first name suffices. Now save
the script and test the result. The text in chat will now say SomeAvatarName touched me
LSL Portal http://wiki.secondlife.com/wiki/LSL_Portal
States http://wiki.secondlife.com/wiki/State
Events http://wiki.secondlife.com/wiki/Category:LSL_Events
Functions http://wiki.secondlife.com/wiki/Category:LSL_Functions
Types http://wiki.secondlife.com/wiki/Category:LSL_Types
Comments
http://wiki.secondlife.com/wiki/LSL_101/Comments,_White-
space_and_Formatting
state_entry http://wiki.secondlife.com/wiki/State_entry
touch_start http://wiki.secondlife.com/wiki/Touch_start
llSay http://wiki.secondlife.com/wiki/LlSay
llOwnerSay http://wiki.secondlife.com/wiki/LlOwnerSay
llDetectedName http://wiki.secondlife.com/wiki/LlDetectedName
Resources

More Related Content

Viewers also liked

Catálogo automotor versión 2016
Catálogo automotor versión 2016Catálogo automotor versión 2016
Catálogo automotor versión 2016Dissan10
 
Concept of strategy in ir
Concept of strategy in irConcept of strategy in ir
Concept of strategy in irjayanjali
 
woodward fieser rule
 woodward fieser rule woodward fieser rule
woodward fieser ruleKavitha Bitra
 
Ir meaning, nature and importance
Ir  meaning, nature and importanceIr  meaning, nature and importance
Ir meaning, nature and importanceAsad Ali
 
Delegated legislation
Delegated legislationDelegated legislation
Delegated legislationReshma Suresh
 
States Of Matter Power Point
States Of Matter Power PointStates Of Matter Power Point
States Of Matter Power Pointwolffer87
 
Planificador de proyecto claudia
Planificador de proyecto claudiaPlanificador de proyecto claudia
Planificador de proyecto claudiaclaudiagudelo0917
 

Viewers also liked (10)

김형섭
김형섭김형섭
김형섭
 
Catálogo automotor versión 2016
Catálogo automotor versión 2016Catálogo automotor versión 2016
Catálogo automotor versión 2016
 
Concept of strategy in ir
Concept of strategy in irConcept of strategy in ir
Concept of strategy in ir
 
woodward fieser rule
 woodward fieser rule woodward fieser rule
woodward fieser rule
 
Elements of State
Elements of StateElements of State
Elements of State
 
Ir meaning, nature and importance
Ir  meaning, nature and importanceIr  meaning, nature and importance
Ir meaning, nature and importance
 
Delegated legislation
Delegated legislationDelegated legislation
Delegated legislation
 
State and its elements
State and its elementsState and its elements
State and its elements
 
States Of Matter Power Point
States Of Matter Power PointStates Of Matter Power Point
States Of Matter Power Point
 
Planificador de proyecto claudia
Planificador de proyecto claudiaPlanificador de proyecto claudia
Planificador de proyecto claudia
 

Similar to The Default Script

Android tutorials7 calculator
Android tutorials7 calculatorAndroid tutorials7 calculator
Android tutorials7 calculatorVlad Kolesnyk
 
Getting started with the visual basic editor
Getting started with the visual basic editorGetting started with the visual basic editor
Getting started with the visual basic editorputiadetiara
 
Getting started with Microsoft Excel Macros
Getting started with Microsoft Excel MacrosGetting started with Microsoft Excel Macros
Getting started with Microsoft Excel MacrosNick Weisenberger
 
Engineering CS 5th Sem Python Module-1.pptx
Engineering CS 5th Sem Python Module-1.pptxEngineering CS 5th Sem Python Module-1.pptx
Engineering CS 5th Sem Python Module-1.pptxhardii0991
 
Gui programming a review - mixed content
Gui programming   a review - mixed contentGui programming   a review - mixed content
Gui programming a review - mixed contentYogesh Kumar
 
App Inventor : Getting Started Guide
App Inventor : Getting Started GuideApp Inventor : Getting Started Guide
App Inventor : Getting Started GuideVasilis Drimtzias
 
lec3forma.pptx
lec3forma.pptxlec3forma.pptx
lec3forma.pptxFaiz Zeya
 
Introduction to keyboard
Introduction to keyboardIntroduction to keyboard
Introduction to keyboardSanjuktaSahoo5
 
Intro to ios - init by SLOHacks
Intro to ios - init by SLOHacksIntro to ios - init by SLOHacks
Intro to ios - init by SLOHacksRandy Scovil
 
Chapter2pp
Chapter2ppChapter2pp
Chapter2ppJ. C.
 

Similar to The Default Script (20)

Working With Text
Working With TextWorking With Text
Working With Text
 
2010 02 Working With Text
2010 02 Working With Text2010 02 Working With Text
2010 02 Working With Text
 
Tugas testing
Tugas testingTugas testing
Tugas testing
 
Android tutorials7 calculator
Android tutorials7 calculatorAndroid tutorials7 calculator
Android tutorials7 calculator
 
Lecture6 oopj
Lecture6 oopjLecture6 oopj
Lecture6 oopj
 
Getting started with the visual basic editor
Getting started with the visual basic editorGetting started with the visual basic editor
Getting started with the visual basic editor
 
Getting started with Microsoft Excel Macros
Getting started with Microsoft Excel MacrosGetting started with Microsoft Excel Macros
Getting started with Microsoft Excel Macros
 
Engineering CS 5th Sem Python Module-1.pptx
Engineering CS 5th Sem Python Module-1.pptxEngineering CS 5th Sem Python Module-1.pptx
Engineering CS 5th Sem Python Module-1.pptx
 
Maxbox starter
Maxbox starterMaxbox starter
Maxbox starter
 
Notes netbeans
Notes netbeansNotes netbeans
Notes netbeans
 
Gui programming a review - mixed content
Gui programming   a review - mixed contentGui programming   a review - mixed content
Gui programming a review - mixed content
 
Chapter 04
Chapter 04Chapter 04
Chapter 04
 
App Inventor : Getting Started Guide
App Inventor : Getting Started GuideApp Inventor : Getting Started Guide
App Inventor : Getting Started Guide
 
lec3forma.pptx
lec3forma.pptxlec3forma.pptx
lec3forma.pptx
 
Tm 1st quarter - 2nd meeting
Tm   1st quarter - 2nd meetingTm   1st quarter - 2nd meeting
Tm 1st quarter - 2nd meeting
 
Introduction to keyboard
Introduction to keyboardIntroduction to keyboard
Introduction to keyboard
 
GUI programming
GUI programmingGUI programming
GUI programming
 
Intro to ios - init by SLOHacks
Intro to ios - init by SLOHacksIntro to ios - init by SLOHacks
Intro to ios - init by SLOHacks
 
Ingles 2do parcial
Ingles   2do parcialIngles   2do parcial
Ingles 2do parcial
 
Chapter2pp
Chapter2ppChapter2pp
Chapter2pp
 

Recently uploaded

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 

Recently uploaded (20)

FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 ✓Call Girls In Kalyan ( Mumbai ) secure service
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 

The Default Script

  • 1. THE DEFAULT SCRIPT F/XUAL EDUCATION SERVICES Investigating States, Events & Functions
  • 2. Rez a prim and with it selected display the Content tab. Click on the New Script button to create a new script.
  • 3. Right click on the New Script icon and select Rename from the menu. Rename the script appropriately. Right click on the script icon and select Open from the menu OR double click on the icon to open the script.
  • 4. The default script is displayed when the new script is opened. Note that when the script was created the text Hello, Avatar! was displayed in main chat. Lines 2 to 5 show the EVENT that was triggered when the script was created (loaded into the prim). Line 4 is the FUNCTION that generated the chat.
  • 5. Scripts are comprised of STATES, the main state being the default state. This state is entered when a script is compiled (saved), reset or loaded. More than one state may be defined, though one is the norm. A script will react to EVENTS in the current state which are triggered by some occurrence or input, which in turn run the FUNCTIONS defined in that event. Functions can be either the built-in functions of LSL or user-defined functions. Curly brackets, i.e. { }, enclose the contents of a STATE or EVENT.
  • 6. EVENTS may have built in parameters though the state_entry EVENT has none. This event is triggered when the script is saved, when a STATE has been changed, when the script is reset or when the script is loaded into a prim. The touch_start EVENT has one parameter, which is of the data type INTEGER (whole number). This event is triggered when the prim is touched (clicked on by the down press of the left mouse button). The parameter indicates the total number of avatars touching the prim during the last computing clock cycle.
  • 7. Most FUNCTIONS also have built in parameters. The llSay FUNCTION has two, the first being the data type INTEGER and the second the data type STRING. A string is text data and is contained between double quotes. Any character can be used in a string. All data types in LSL are immutable and built in parameters must be included in the EVENTS or FUNCTIONS. The data types in LSL are; FLOAT, INTEGER, KEY, LIST, ROTATION, STRING and VECTOR.
  • 8. To change the text generated by the llSay FUNCTION select the text between the double quotes in Line 4. This parameter is the data type STRING and will be the text that is said when this function runs.
  • 9. In the above example the text has been changed to Good morning Isa! To save the changes click on the Save button (which is now highlighted due to some portion of the script being changed) OR press Ctrl S. The script will be saved (compiled). This will trigger the state_entry EVENT which will run all the parts of the script between the curly brackets { } from line 3 to 5. In this case it is the llSay FUNCTION that runs and displays the text Good morning Isa! in main chat.
  • 10. Every time a script is saved the state_entry EVENT is triggered. This will cause the llSay FUNCTION on line 4 to run. To prevent this happening it is possible to COMMENT out the function by placing two forward slashes at the beginning of the line. This leaves the line visible in the script but does not compile this part of the script when it is saved. Click on the Save button and you will see this function no longer runs. Comments are a useful way of adding notes to remind you of the function of certain sections of code.
  • 11. Help pop-ups can be accessed for all aspects of a script. For example holding the cursor over the touch_start EVENT shows the pop-up above indicating that this event has one parameter, an INTEGER, and that the event is triggered by the start (pressing the left mouse down) of agent (avatar) clicking on task (the prim).
  • 12. FUNCTIONS also have help pop-ups. In this example the llSay FUNCTION is shown to have two parameters, an INTEGER and a STRING. When run the llSay FUNCTION will say the text of the STRING on the chat channel indicated by the INTEGER. In this case the text Touched. will be said on channel 0, this being the main public chat channel. A touch_start EVENT can only be tested with the prim deselected. A script can be left open, altered and saved even when the prim is deselected. Test the touch_start EVENT.
  • 13. LSL scripting syntax is very strict. STATES and EVENTS must be enclosed in curly brackets { } and lines of code within an EVENT must end with a semi-colon ; All built in parameters must be included in EVENTS and FUNCTIONS and must be enclosed in parentheses ( ), each of the parameters must be delimited by a comma , and be in the correct order and data types must be correct. Code is also case sensitive so the correct case must be adhered to, e.g. llSay not LLsay and touch_start not Touch_Start If these rules are not met an error will occur when the script is compiled (saved). The compiler will pause the cursor in the vicinity of the error, usually the line after it occurs, so this is a good indication of where the error is. Linden Scripting Language SYNTAX
  • 14. Continue with the script by adding a new FUNCTION into the touch_start EVENT. Place the cursor at the end of line 9.
  • 15. Press the Enter key to create a new line.
  • 16. All EVENTS and FUNCTIONS can be accessed through the Insert button (though the newest additions to LSL may take a little while becoming available in this menu). In this example the FUNCTION llOwnerSay will be inserted. Click on the Insert button and scroll down the list till you see this function. Click on it to insert it in the script.
  • 17. As seen on line 10 the llOwnerSay FUNCTION has been inserted. Hold the cursor over the function to display the help pop-up. This function has one parameter, a STRING. This string’s text will be said only to the owner of the prim the script is in and the owner must be in the same sim as the prim to hear it. The text will appear in the main chat window but will only be seen by the prim owner.
  • 18. Complete the FUNCTION by adding parentheses ( ) and writing the STRING of text you wish to be seen inside them. Ensure the text has double quotes around it, e.g. “Isa touched me”. Also ensure that the line has been concluded with a semi-colon ; The line should look like: llOwnerSay(“Isa touched me”); Comment out line 9 so that only the llOwnerSay function runs when the touch_start EVENT is triggered. Click on the Save button to compile the script. Test the script by touching the prim.
  • 19. It is also possible to add a FUNCTION within another FUNCTION. Currently the llOwnerSay FUNCTION in the touch_start EVENT only says the text Isa touched me but doesn’t indicate who really touched the prim. Anyone touching the prim will trigger this text to display. That can be changed. Place the cursor after the first parenthesis in line 10 as shown above.
  • 20. From the Insert button (which will currently display the name of the last item inserted, i.e. llOwnerSay) find and insert the FUNCTION llDetectedName.
  • 21. The FUNCTION llDetectedName has one parameter, an INTEGER, which accesses the list of avatars who touched the prim. (This list is created by the touch_start EVENT.) Complete the script as shown in line 10. The parameter 0 used in the llDetectedName FUNCTION accesses the first name in the list. It is extremely unlikely that more than one avatar will touch a prim in one clock cycle so the first name suffices. Now save the script and test the result. The text in chat will now say SomeAvatarName touched me
  • 22. LSL Portal http://wiki.secondlife.com/wiki/LSL_Portal States http://wiki.secondlife.com/wiki/State Events http://wiki.secondlife.com/wiki/Category:LSL_Events Functions http://wiki.secondlife.com/wiki/Category:LSL_Functions Types http://wiki.secondlife.com/wiki/Category:LSL_Types Comments http://wiki.secondlife.com/wiki/LSL_101/Comments,_White- space_and_Formatting state_entry http://wiki.secondlife.com/wiki/State_entry touch_start http://wiki.secondlife.com/wiki/Touch_start llSay http://wiki.secondlife.com/wiki/LlSay llOwnerSay http://wiki.secondlife.com/wiki/LlOwnerSay llDetectedName http://wiki.secondlife.com/wiki/LlDetectedName Resources