Building Tutorial – Scripting

Scripting is a function used in building, that allows users to receive or give information to objects. These are usually used in items that can be bought on the marketplace, from moving clothes, the shoe walk sound, re-sizing scripts, and others.

We will today create a simple floating text that will show a message in a color on the helmet we built last week. Put on your helmet and right-click it, select Edit and go to the Contents tab. Click New Script and a new object should appear that’s named New Script. Right-click it and select Rename. You name it whatever you want, but a name that says what the script does is the most effective, so for now, name it “Floating Text”.

Double-click on it and the LSL Script Editor should appear. This is actually a program within SL that is made for programming in LSL, the Linden Scripting Language. All objects you see in SL that you can interact with, from the dance balls, to the HUDs, to the vendors, are programmed in LSL, just like you’re about to do.

If you notice in the Local Chat, it should say that your helmet just said “Hello Avatar”. This is the first part of the script you see. You can delete that line for now, so it doesn’t say that every time you rez your helmet. Further down you should see a method named touch_start. You can delete everything from that line down to the last squiggly-bracket (}).  We’re only interested in state-entry here, so within those squigglybrackets, where it said llSay(0,… before (should be line 4), just click to put the pointer there. You could type, but since you don’t know what to type yet, there’s an easier way.

At the bottom you should see a drop-down menu with the text Insert…, click this and you should see a lot of commands starting with two lower-case L’s. Look for llSetText and click it. It will type out llSetText for you, and this might seem a bit redundant, but when you start out, this menu will show you all commands you can write, so it’s great for experimenting.

If you hover your mouse over the text, it will show a box with information about the command, how you write it, what it does and what you need to know. This one will say “llSetText(string text, vector color, float alpha)”. The things within parenthesis are called named variables, what it tells you to do is to write a text within quotation marks (also known as a string text), a comma, a three-number-sequence (known as a vector) that will state the color (in red, green and blue) and a decimal number (known as a float) that will give the alpha, or transparancy of the text.

After llSetText, type the following: (“This is a text that will float”, <1.0, 1.0, 1.0>, 1.0);

If you hit save now, you will see a white text over your head that says the text we put in. Now within the angle brackets (<) , instead put other numbers, starting with 0., like 0.5, 0.2, 0.9, to create other colors. Experiment to see what colors you can get.

You can type any text you want, up to (I think) 64 letters, but more than a few words will look crowded. There’s a fix for this, and that’s the line break. Where ever you want the text to split to a new row, just type n, like “This isna text”, that will come out as:

This is

a text

That’s all for now, write what you feel or what you want others to know, and wear that helmet with pride, you’ve made it yoursef!

Oh, one last thing, the text will remain, even after you’ve removed the script. To fix this, just edit the script and remove the text within the quotation marks and save the script.

Do you like what you've just read? Please share us with your friends!

0 thoughts on “Building Tutorial – Scripting

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload the CAPTCHA.