Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Changed Link Question/Problem

WhiteStar Magic
Build it+Script it=RUN!
Join date: 24 Jul 2008
Posts: 36
02-25-2009 07:12
Good Morning All.

I have been looking for some definitive info on the CHANGED_LINK issue I am having.

I want to continue using CHANGED_LINK as a way to test for the avatar sitting on the object as it's efficient, BUT If I de-link a prim from the device this is triggered (as it should be) BUT it will immediately execute the do_end_stuff() call. IF I de-link a prim or Add a prim to the device I don't want the do_end_stuff() call to be executed, I would prefer to have it test that this (was not an avatar link change) and therefore bypass do_end_stuff().

So I guess the quick question in a NutShell, is there a way to further "Filter" the CHANGED_LINK event for the various possible triggers ?

=code snippet =
changed(integer change)
{
if (change & CHANGED_LINK)
{
AviSitting = llAvatarOnSitTarget(); // Get AVI Key sitting on here
if (AviSitting == NULL_KEY)
{
// avi got off //
do_end_stuff();
}
else
{
// avi got on //
do_start_stuff();
}
// *** possible trigger filters ***
// if (prim_link_change) do_prims_changed();
// if (prim_shape_change) do_shape_changed();
// if (prim_type_change) do_type_changed();

}
}

Thanks in Advance
_____________________
Build it, Script it & Enjoy It, then Share it !!!
Lazink Maeterlinck
Registered User
Join date: 8 Nov 2005
Posts: 332
02-25-2009 11:08
Do a number check on the links:

state_entry()
{
gNumberOfPrims = llGetNumberOfPrims();
}

changed(integer change)
{
if(change & CHANGED_LINK)
{
integer newNumberOfLinks = llGetNumberOfPrims();
key avatar = llAvatarOnSitTarget();
if(avatar == NULL_KEY && (gNumberOfPrims == newNumberOfLinks))
{
//Code for if someone hopped off the object
}
else if(avatar == NULL_KEY && gNumberOfPrims != newNumberOfLinks)
{
//something was added or deleted in the link set, technically you don't need
//the second conditional gNumberOfPrims != newNumberOfLinks
//code for when an object is added to the link set
}
else if(avatar != NULL_KEY)
{
//code for someone sitting on the object
}
}
}

Basically, you need to check the number of prims in your set, if it changes from your initial number, and there is no avatar on the object, you know you changed the link set via a prim.
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
02-25-2009 11:58
You can also make the code work like this:

CODE

key last_avatar = NULL;

changed(integer c)
{
if(c & CHANGED_LINK)
{
key new_avatar = llAvatarOnSitTarget();
if(new_avatar != last_avatar)
{
// someone got off or on
}
else
{
// something else
}
last_avatar = new_avatar;
}
}
_____________________
Argent Stonecutter - http://globalcausalityviolation.blogspot.com/

"And now I'm going to show you something really cool."

Skyhook Station - http://xrl.us/skyhook23
Coonspiracy Store - http://xrl.us/coonstore
WhiteStar Magic
Build it+Script it=RUN!
Join date: 24 Jul 2008
Posts: 36
02-25-2009 14:54
Thanks Lazink & Argent.

That helps a LOT. I was suffering form an LSL Laps there... LOL... I'll implement those suggestions and expand on them further.


Take Care !

IF THIS THING WILL POST !
Ughhh the forums are bagged lately !
3rd attempt ! (They need to upgrade from the C=64 to a TRS-80 M-12 or maybe a ZX-1) LMAO
4th shot !
_____________________
Build it, Script it & Enjoy It, then Share it !!!