Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

changed event and linked objects

Baron Hauptmann
Just Designs / Scripter
Join date: 29 Oct 2005
Posts: 358
08-01-2006 19:13
I have a table with several linked seats. I would like to detect when someone sits on a particular seat and give that person inventory. I have a script in each seat with a "changed" event. The problem comes in that the changed event fires in every chair when it fires in one chair. So, one person sitting down is okay. When the second one sits down, the first one gets a repeat gift.

CODE

changed(integer change)
{
if (change & CHANGED_LINK)
{
if (llAvatarOnSitTarget() != NULL_KEY)
{
AvatarSittingOnMe = llAvatarOnSitTarget();
llGiveInventory(AvatarSittingOnMe, . . .);
. . . etc
} else
{
AvatarSittingOnMe = NULL_KEY;
. . . etc

}
}
}


Any ideas for how to change this?

Baron Hauptmann
Angela Salome
Registered User
Join date: 6 Oct 2005
Posts: 224
08-01-2006 19:37
Something like this:

CODE

changed(integer change)
{
if (change & CHANGED_LINK)
{
AvatarSittingOnMe = llAvatarOnSitTarget();
if (NULL_KEY != llAvatarOnSitTarget())
{
if (!GaveGift)
{
llGiveInventory(AvatarSittingOnMe, . . .);
GaveGift = TRUE;
}
// . . . etc
}
else
{
GaveGift = FALSE;
// . . . etc
}
}
}
Baron Hauptmann
Just Designs / Scripter
Join date: 29 Oct 2005
Posts: 358
08-01-2006 19:48
Thanks, Angela. I'll try that. There are some other things that go on, too, but just having a global variable might keep it from triggering the event multiple times when it shouldn't.

Baron