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