Thursday, June 7, 2007

What's in those bags with garbage ?

Ok, apparently the first post caused very unexpected (by me that is :) positive reaction, so let's continue.

Again, I set the pace rather slow, so that noone would stress too much.

Let's return to our small example and study those "trash bags" with curly brackets.


default
{

state_entry()
{

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

touch_start(integer total_number)
{

llSay(0, "Touched.");
}
}


So, first - the outermost layer. The green thing. In LSL it is called state.
Those impatient can read up about it on wiki, for the rest - just consider this construct a part of reality for now. we'll deal with it later on sometime.


Now, the blue and red things.. those are more interesting. They describe how your script should react on certain events. There're a couple of dozen of events or so which can happen - and in the above code, inside those blocks you define what to do for each of the events.

Question: why is there a brown-coloured thing for the red-coloured event ? It is a way to say "when this happens, there will be some other information arriving". For this particular case, it will be the integer, which says how many agents are just starting to touch the object.

Some homework for those interested:


  1. find out what is "state_entry()" used for
  2. what does "0" in llSay mean and do you think it is the best way to have have it used in this way ?
  3. for the daring ones: find out how to do such that only you (the owner) could hear what the script is saying.

3 comments:

Anonymous said...

Ooh,ooh, *raises hand*

Not really sure how to put in my own words what state_entry means, lol. Something like, that tells the script when to start running?

Anyway, I just wanted to guess for Question 2: The "0" in llSay indicates which channel the script will "say" something, and channel 0 is open chat, so everyone can hear it?

Pretty sure using llOwnerSay lets only "you" hear what the script is saying. I did research that one before, as a script I had for something kept shouting a greeting (llShout), and I wanted to keep the noise down a bit, hehe, so I looked up llSay and llWhisper as well, before finding that llOwnerSay.

Dalien said...

Wrath, yes, correct.

The first item would need some more clarification though, (it was intentionally piggybacking on the material that I did not tell yet - the script states :)

More on this today...

Anonymous said...

Curious, Dalien - if the 0 in llSay represents the open chat channel for all to hear - what if 0 was some other number, say 1, for example. Does anyone hear it? I am guessing the script would get a bit more complicated at that point to determine who has the ability to hear the script on a certain channel?