Posted on

LSL Tutorial Class Note 101

Basic Scripting 101 (Beginners with no programming experience)

Welcome to my basic scripting class.
~============== Introduction ======================
This class is for beginners who don’t have any experience at all in programming.

If you already have scripting experience in any other language, please consider to take one of the intermediate classes instead. You are welcome to stay but it may be boring 😉

We’re hiring teachers here at the Academy of Second Learning, so if you’d like to help us bring great classes to Second Life, please pick up an application from the blue square sign outside.

Today I will tell you why we need scripts and where you will find more information about scripting,

This will be very basic and I will explain you some theory about scripting and show you some examples.

I will stop from time to time and give you a chance to ask questions.

~========= Chat Issues =============

Make sure to open your chat history (you can use CTRL-H to do this). You can catch up with chat lines that you may have missed.

Later on, after the class, you will be able to select all the chat lines with your mouse, or just click into it and press CTRL-A to select all.

You can then copy the chat history into the clipboard by pressing CTRL-C and pasting it later in any text editor of your choice or in a new note card by pressing CTRL-V.

~================ Presenter issues ==============

I hope you can see the presenter screen with the screenshots. If it is blurry, please wait a while until the images are loaded. It should become clear after a minute.

You can speed it up if you zoom in your camera to make it full screen. You can also right-click on it and choose “Edit”.

Even if you are not allowed to edit the object, it will put the image first into the loading-queue, which means, the presenter image will load next on your computer.

~===================== Default Script ========================

Why do we use Scripting in SL?

It’s because our objects should do things that a normal chair or table would not do.

Imagine these things in Real Life. You would not expect a chair or a table to interact with you or with the environment.

On the other hand, look at your TV, your radio, your toaster. You expect them to “do” something for you.

For example showing your favorite TV-show, or heating up your toast.

It’s the same in SL. If you see a radio somewhere, it just could be a “dead” item that just looks nice.

But if it contains a script, it would be able to play music for example.

To do this, the object need to “know” when it should start playing the music, and maybe it should be able to play different music of your choice.

That’s why we need scripts in objects.

For example, an object can give you things when you touch it. Or you can open a door when you touch it. Or the object sells you something if you pay it.

All the games in the casinos are heavily scripted objects. But also some of your jewelry may contain a script.

For example a bling script to produce these glitter effects for shiny shoes or earrings.

Let’s have some examples:

Click on this box, it contains the class notes for this class and some sample scripts that we need for an exercise that we will do later.

~============== Show a notecard giver ================

This is a simple notecard giver. You can touch it and it will give you a notecard.

~============= Show diamond ring =============

This is a simple diamond ring that I build in class. It contains a script that produces something that is called “particles”.

The particles look like bright sparks that come out of the object. This is called “bling”.

Bling looks very nice but sim owners don’t like it very much, because it will add some lag to the sim.

So if you are asked to turn it off, be kind and detach the object if possible. If you don’t want to detach it, make sure you can turn the bling off. Most scripts have a special command to do that.

Anyway, it is always better to detach a scripted object than to just turn off the script. Even a script that is turned off can cause lag. So make sure you dress up only with non-scripted objects if you plan to attend a meeting where you expect many people.

~~~~~~~~~~~~~~ Show teleporter ~~~~~~~~~~~~~~~~~~~

This is a simple telporter. It just contains a simple sit and unsit script that will place me about 3 meters above the prim when I am sitting on it.

After that, it will unseat me and I can walk around again.

~============ apply a script to an object ===========

Our first exercise will be, to apply a script to an object.

Rez a prim, a normal box will do fine. You can change color and texture to what you like just to make it easier to find your own object later 😉

It’s always a good idea to rename everything after creation.

So go to the GENERAL tab and name your object “My scripted Object”

Now change to the content tab. Drag my script “example script” from your inventory to the content tab.

It will now appear in the content folder.

Now you can close the edit window for your object. That’s all you need to put a script into a simple object.

~============ Try out the example script ============

Now, try the example script.

If you touch the box, it will jump 1 meter high and stay there.

If you touch it again, it will go down again.

The Scripting is done in a special scripting language that’s called LSL.

LSL is short for Linden Scripting Language.

The LSL-Wiki is the best reference for scripting at the moment.

http://rpgstats.com/wiki/index.php

A Wiki is a special Website, where knowledgeable people can build some kind of documentation that can be changed easily.

If you have a chance to open the URL in a browser, you can do this now. If not, you can explore the LSL-Wiki later.

It’s not complete, that means some explanations are still missing. But it will be completed over time.

You may also notice, that every Function starts with ll which is short for Linden-Language and must be two lower case letter L

You will be able to create your own basic script in the next class “basic scripting 102” where we will create a default script and change a few lines in there.

Any questions so far, before I finish this class for today?

~========== Conclusion ==============

This concludes this class.

Now you now know why we use scripting in SL

You are able to apply a given script to any of your own objects. And you know that there exists a special website with more information about LSL

At last, maybe you can do me a favor:

These classes are free of charge, because ASL has sponsors.

These sponsors would like to know how the classes are accepted by the students.

So please fill out the feedback form that I gave you with the class notes and drop it back in the ASL Survey Box (the blue scroll near the landing point)

Thanks for your time 😉

Advertisements

About Kemo

I am just an ordinary person in the garden.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s