Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

llUnSit, llAvatarOnSitTarget, llSitTarget ARGH!

Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
09-19-2008 11:32
heyas;

okay, making a game... with an object to catch. i need people not to sit on it.

oh, easy, you think? i thought so too.

at first, i just used a sphere to work out the movement script. it didnt have a sit target, and (for some reason) was not a sittable prim.

i just added more prims to it (the actual creature model). now it has sittable spots galore. ARGH!

so i thought setting llSitTarget( ZERO_VECTOR, ZERO_ROTATION) made it unsittable. haha, NO. not in all cases. certainly not in THIS case. i put that in EVERY prim. i put it in EVERY STATE in the main script.

so, yeah, okay, use the change & CHANGED_LINK and llAvatarOnSitTarget to llUnSit them. exept... this **CANNOT** work if the prim does not 'find' an avatar on its sit target. which, apparently, i am NOT sitting on, cuz it don't find me. ever.


oh wait, i have an idea.... this is stupid, but i DO happen to know if you change a prim parameter in the linkset, all avatars are automatically booted off. had that problem with by sea turtle with blinking eyes. how stupid is that? gah!


but anyhow... is there a formula for using llUnSit? geeze, i thought it was easier than this.


omg, the dimple, the cut, the changing prim type parameters... IT AINT WORKING!!! WHY LSL, **WHY**!?!??!?!?!?!??!!?
_____________________
Why Johnny Can't Rotate:
http://forums.secondlife.com/showthread.php?t=94705
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
09-19-2008 11:36
llAvatarOnSitTarget only works if you give the object a non-zero target - if you say ZERO_VECTOR and ZERO_ROTATION, it will always return NULL_KEY.

Something like this should work..
CODE

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

changed (integer mask)
{
if (mask & CHANGED_LINK)
{
key sitter = llAvatarOnSitTarget();
if (sitter)
{
llShout (0, llKey2Name (sitter) + " is sitting on me! I need an adult!!!");
llUnSit (sitter);
}
}
}
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
09-19-2008 11:39
Using changed/CHANGED_LINK with llAvatarOnSitTarget() and llUnSit() should work. The problem is that setting a sit target displacement of ZERO_VECTOR actually removes the sit target. So you'll want to use some other value like <0.0, 0.0, 0.1>.

You can also iterate over the keys in the link set and unsit any that belong to avatars. This approach will work whether or not there is a link target set. Something like:

CODE

unsitAllAvatars()
{
integer nPrims = llGetNumberOfPrims();
integer i;
for (i = nPrims; i > 1; --i)
{
key id = llGetLinkKey(i);
if (llGetAgentSize(id) != ZERO_VECTOR)
{
// All avatars are added to the end of the link set, so once we find an actual prim....
return;
}

llUnSit(id);
}
}


Note that the order of iteration is important, because unsitting an avatar that is not at the end of the link set is going to change the link numbers of the avatars after it, and either way changes the size of the link set (llGetNumberOfPrims()).
Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
09-19-2008 11:55
okay...

but imma do the sit target 300,300,300 :X THEN boot them off!

do i need a sit target in EVERY freekin prim?


thanks, guys.
_____________________
Why Johnny Can't Rotate:
http://forums.secondlife.com/showthread.php?t=94705
Annabelle Babii
Unholier than thou
Join date: 2 Jun 2007
Posts: 1,797
09-19-2008 12:06
From: Bloodsong Termagant
okay...

but imma do the sit target 300,300,300 :X THEN boot them off!

do i need a sit target in EVERY freekin prim?


thanks, guys.


Nope. Just the root. If the other prims aren't targetted any sit event defaults to the one prim with a target.

oh, and I do the teleport on sit for things I don't want people sitting on... but max coords in any sim are 255.
_____________________
Deep inside we're all the same - we're an amorphous fog clouod.
Bloodsong Termagant
Manic Artist
Join date: 22 Jan 2007
Posts: 615
09-25-2008 09:56
thats okay.

i sat them in the next sim :X or smushed them up against the border.


as a side note... when did phantom prims with no sit target become sittable??? ARGH!