Wednesday, June 6, 2007

Basic LSL

There's been ton of the various tutorials and such about LSL, so not sure if this would be of use for anyone... but since a couple of folks said that this might be fun, here it goes. I will take an assumption that the reader is not very well versed in coding, so it is also an opportunity for me to exercise my explanation skills - and to start really really basic. So if this is boring for you - I will try to put some more spicy stuff inbetween :)

Let's take a practical approach - pushing random buttons and seeing what happens :)

Create a cube, and hit the "New Script" within the "Content" tab.

As a result we get "New Script" which looks like this:

llSay(0, "Hello, Avatar!");

touch_start(integer total_number)
llSay(0, "Touched.");

Now, what what here, and why so many curly braces ?

if you look closer, you will see that all of this seems to be similar - a series of nested structures.

And at highlevel it looks like this:

some-name(maybe brackets and some more brackets)

This kind of logic is very frequently used in computer science - and not only.
When you have tons of garbage that you do not want to see spreading around the house, you take a bag, put all the garbage in - and put the label "garbage". And you know that it contains various garbage.

Same in the computer science - the concept of packing multiple things and then referring to them by a single name allows to abstract away "the garbage" so that you can operate at a higher level of abstraction.


Alex Burgess said...

Ah! Good start and that is loud and clear. I like the garbage/trash bag analogy.

Wrath said...

Yay - so far I'm keeping up with the rest of the class!

Although that garbage/trash bag analogy now has me totally thinking about my inventory organization, or lack thereof.

Can't wait until we get to the part where scripts start blowing stuff up! Umm, I mean, the scripts start working. :-)

Thank you for breaking it down for us, Dalien!!

Zoe Connolly said...

Cool, now I can focus on learning LSL while I obsessively read SL blogs. This is exactly what an obsessive compulsive girl with attention deficit disorder needs.

Thanks, Dalien!

vint said...

Where do I inscribe for class? Although it's a bit like layers and groups. *wonders if scripts have cropping masks* ;)

Dalien said...

@alex: thx :)

@wrath: "make love not war" - so probably we'll get to sexgen poseballs or something like that, but not guns, sorry :-)

@zoe: ok I will try to keep it short to ensure there's not too much extra effort :)

@vint: very much like that to some extent, yes. You group the layers to operate on them as a "single thing", so the analogy is quite close. :)