Welcome to Scripting
Welcome to Blackthorn University's LSL Scripting course. By the end of these eight classes you will be able to write working scripts that bring objects in Second Life and OpenSimulator to life.
What is a script? A script is a set of instructions you give to an in-world object. Without a script, an object just sits there. With a script, it can greet visitors, open doors, count points, move, play sounds, send messages, and much more.
Here are just a few things people build with LSL scripts:
- Doors & gates
- Open and close on touch or when an avatar approaches
- Greet visitors
- Say hello to anyone who enters a parcel or region
- Vehicles
- Control movement physics for boats, cars, and aircraft
- HUDs
- Heads-Up Displays that attach to your screen and show information
- Vendors
- Sell items from a prim when a customer pays
- Games
- Track scores, spawn objects, run timers
All of this is possible once you understand the foundations. Let's start at the very beginning.
Where Scripts Live
Unlike other programming languages where you save code as files on your computer, LSL scripts live inside objects in-world. Every prim (primitive object) in Second Life and OpenSim can hold one or more scripts.
You can also find scripts in your inventory — the panel that lists everything you own. But a script sitting in your inventory doesn't do anything. It only runs when it's inside an object in the world.
Think of the object as the computer and the script as the program running on it. The object must be rezzed (placed in-world) for the script to run.
Scripts are passed around just like any other inventory item — you can copy them, give them to friends, or sell them. The only restriction is whether the creator has set the script as no-copy or no-modify.
The Script Editor
To write or edit a script, you open the Script Editor. Here's how to get to it:
- Right-click on any object you own
- Select Edit from the pie menu
- In the Edit window, click the Content tab
- Click New Script
The Script Editor opens, and you'll see a default script already written for you. Every new script starts with this exact code:
default
{
state_entry()
{
llSay(0, "Hello, Avatar!");
}
}
Don't worry about what this means yet — we'll dissect every word in Class 2. For now, just know that when you click Save, the object says "Hello, Avatar!" in nearby chat.
In OpenSimulator the Script Editor works the same way, though some viewers may show it slightly differently. The code itself is identical.
How LSL Works — The Event-Driven Model
LSL is an event-driven language. This is the most important concept in all of scripting, so read this carefully.
Your script does not run constantly from top to bottom the way you might imagine. Instead, it sleeps — using no CPU resources — and wakes up only when something happens. That "something" is called an event.
- state_entry
- Fires once when the script starts or resets
- touch_start
- Fires when an avatar clicks the object
- timer
- Fires repeatedly on a schedule you set
- listen
- Fires when a message is heard on a chat channel
- collision_start
- Fires when a physics object hits this object
Here's a script with two events. Notice how the code only runs when that specific event occurs — nothing happens in between:
default
{
state_entry()
{
// This runs once when the script starts
llOwnerSay("Script is ready.");
}
touch_start(integer num_detected)
{
// This runs every time someone clicks the object
llOwnerSay("Someone touched me!");
}
}
The script wakes up for state_entry, runs that block of code, then goes back to sleep. Later, when an avatar clicks the object, it wakes up for touch_start and runs that block.
LSL vs Other Languages
If you've ever heard of JavaScript or Python, you might be wondering how LSL compares. The good news: LSL looks a lot like C and JavaScript — curly braces, semicolons, if/else, loops. If you've seen any of those languages, LSL will feel familiar.
The differences matter because of where LSL runs — inside a simulated virtual world:
- No file I/O
- LSL cannot read or write files on disk — everything lives in variables or object state
- Script memory limit
- Each script gets a small fixed amount of memory (~64 KB in SL). Large lists and strings eat it fast
- No blocking loops
- A loop that runs forever will freeze your script — and lag the sim. Use the timer event for repeating actions
- LSL-specific functions
- All the interesting stuff (moving objects, playing sounds, detecting avatars) is done through built-in ll functions — hundreds of them
- Single-threaded per script
- Each script runs one thing at a time. Multiple scripts in one object run in parallel
LSL is deliberately simple and sandboxed. That's by design — it keeps the virtual world stable and secure. Once you understand its constraints, you'll work with them naturally.
Your Learning Roadmap
Here's what the rest of the course covers. Each class builds on the last, so working through them in order will give you the strongest foundation.
- Class 1 — What is LSL?
- You're here. The big picture of scripting in Second Life and OpenSim.
- Class 2 — Your First Script
- Write, save, and test a working script from scratch. Learn
llSayandllOwnerSay. - Class 3 — Variables & Data Types
- Store information in variables: integers, floats, strings, vectors, and more.
- Class 4 — Events
- Touch, listen, timer, collision — the events that power all scripts.
- Class 5 — Conditionals
- Make decisions with if/else. Build owner-only access controls.
- Class 6 — Loops
- Repeat actions with while, for, and do-while loops.
- Class 7 — Lists & Strings
- Store collections of data and manipulate text.
- Class 8 — Practical Project
- Build a complete door, greeter, or HUD using everything you've learned.
You're ready. Click Mark Complete below to log your progress, then head to Class 2.