Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Sitting, Keying, and Names

Shippou Oud
The Fox Within
Join date: 11 Jul 2005
Posts: 141
12-12-2006 15:20
This should be fairly simple, but I can not find an example of it. The script is fairly common, and used when an AV sits on something.

Here is what I am trying to do.

Create a script for when an AV sits on my object, it will say "Hello (AV Name)"

So far all I have coded is 2 failed scripts, one of them (I am using touch_start to test) says the key number of the AV touching it waether or not any one's sitting on the object, and the other spits out the name of the object.

What am I doing wrong?!
Shippou Oud
The Fox Within
Join date: 11 Jul 2005
Posts: 141
12-12-2006 16:04
here is my latest failed script, which spits out a bunch of 0's

From: someone

key agent = llAvatarOnSitTarget();
llWhisper(0, "Hello " + (string) agent);


this version spits out nothing
From: someone

key aw = llAvatarOnSitTarget();
string as = llKey2Name(aw);
llWhisper(0, "Hello " + (string) as);

ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
12-12-2006 17:14
The "changed" event is triggered when an av sits on an object.
Example at this link:
http://rpgstats.com/wiki/index.php?title=Changed
Tyken Hightower
Automagical
Join date: 15 Feb 2006
Posts: 472
12-12-2006 19:37
llAvatarOnSitTarget() will always return a NULL_KEY if there's either no one sitting or if you haven't set a sit target with llSitTarget(). You must set a sit target with a non-zero vector before it'll give you anything.
_____________________
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
12-13-2006 00:11
CODE

default
{
state_entry()
{
llSitTarget(<0.1,0.1,0.1>, ZERO_ROTATION);
}

changed(integer change)
{
// something changed
if (change & CHANGED_LINK)
{
// and it was a link change
key id = llAvatarOnSitTarget();
if (id != NULL_KEY)
{
string Name = llKey2Name(id);
llWhisper(0, "Hello " + Name);
}
}
}
}