F/XUAL EDUCATION SERVICES

Slides:



Advertisements
Similar presentations
Getting started with MPLAB Launch MPLAB Set Toolbar as in the next slide by clicking the leftmost icon Open a new Source file by choosing [FILE][NEW] Type.
Advertisements

Why care about debugging? How many of you have written a program that worked perfectly the first time? No one (including me!) writes a program that works.
LSL: Linden Scripting Language Andrew Orr 12/17/07.
Macros Tutorial Week 20. Objectives By the end of this tutorial you should understand how to: Create macros Assign macros to events Associate macros with.
Introduction to scripting
Chapter 9 Introduction to ActionScript 3.0. Chapter 9 Lessons 1.Understand ActionScript Work with instances of movie clip symbols 3.Use code snippets.
A.I. in Second Life Akihiro Eguchi. Why Second Life? Real world like environment where we can visually show the demo of our work E.g. ◦ Workflow ◦ Ontology.
® Microsoft Access 2010 Tutorial 11 Using and Writing Visual Basic for Applications Code.
Connecting to the Island Ensure you are in the UA CSCE Artificial Intelligence group Ensure you are in the UA CSCE Artificial Intelligence group Open the.
INTRODUCTION TO JAVASCRIPT AND DOM Internet Engineering Spring 2012.
Microsoft Visual Basic 2012 CHAPTER THREE Program Design and Coding.
T U T O R I A L  2009 Pearson Education, Inc. All rights reserved. 1 5 Completing the Inventory Application Introducing Programming.
Working with the VB IDE. Running a Program u Clicking the”start” tool begins the program u The “break” tool pauses a program in mid-execution u The “end”
CS590VC - Tutorial 3 Linden Scripting Language (LSL)
Dr. Qusai Abuein1 Internet & WWW How to program Chap.(6) JavaScript:Introduction to Scripting.
JAVA Practical Creating our first program 2. Source code file 3. Class file 4. Understanding the different parts of our program 5. Escape characters.
CSC 230 (Blum)1 Visual Basic 2005 Hello World Fall 2005 T. Blum.
© Copyright by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. 1 Outline 5.1 Test-Driving the Inventory Application.
CSC 230 (Blum)1 Visual Basic 2005 Hello World Fall 2005 T. Blum.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
Visual Basic 2010 How to Program © by Pearson Education, Inc. All Rights Reserved.
Lecture 3: Getting Started & Input / Output (I/O)
LINGO TUTORIAL.
Excel Tutorial 8 Developing an Excel Application
Unit 2 Technology Systems
Visual Basic.NET Windows Programming
Chapter 2: The Visual Studio .NET Development Environment
Topics Designing a Program Input, Processing, and Output
Chapter 6 JavaScript: Introduction to Scripting
ME 142 Engineering Computation I
International Computer Driving Licence Syllabus version 5.0
Data Types Variables are used in programs to store items of data e.g a name, a high score, an exam mark. The data stored in a variable is entered from.
The Smarter Balanced Assessment Consortium
Chapter 2: Introduction to Visual Basic Programming
Project 9 Creating Pop-up Windows, Adding Scrolling Messages, and Validating Forms.
Introduction to Scripting
Visual studio 2010 SENG 403, Tutorial 2 SENG Winter 2011.
The Smarter Balanced Assessment Consortium
Using Procedures and Exception Handling
Intro to Java.
Intro to PHP & Variables
MS PowerPoint 2010 Week 2.
Learning Java with Alice 3.0 Game Design Kathy Bierscheid
Objectives Learn about Function procedures (functions), Sub procedures (subroutines), and modules Review and modify an existing subroutine in an event.
CHAPTER FIVE Decision Structures.
Variables and Arithmetic Operations
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
The Smarter Balanced Assessment Consortium
NORMA Lab. 2 Revision: Unary and Binary Fact Types Ternary Fact Types
Introduction to C++ Programming
CIS16 Application Development Programming with Visual Basic
WEB PROGRAMMING JavaScript.
The Smarter Balanced Assessment Consortium
Visual Basic Programming Chapter Four Notes Working with Variables, Constants, Data Types, and Expressions GROUPBOX CONTROL The _____________________________________.
Key Applications Module Lesson 12 — Word Essentials
Using Functions
Visual Studio.
Topics Designing a Program Input, Processing, and Output
Chapter 2: Introduction to C++.
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
Introducing JavaScript
Lesson 4: Managing Events in Case Tracking
The Smarter Balanced Assessment Consortium
Running a Java Program using Blue Jay.
Key Applications Module Lesson 12 — Word Essentials
The Smarter Balanced Assessment Consortium
Tutorial 11 Using and Writing Visual Basic for Applications Code
Executive Reports, Instructions and Documentation
Presentation transcript:

F/XUAL EDUCATION SERVICES THE DEFAULT SCRIPT Investigating States, Events & Functions F/XUAL EDUCATION SERVICES

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 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 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 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 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). 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 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 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 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.

Linden Scripting Language SYNTAX 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.

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 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 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

Resources 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