Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

linked camping devices = bad?

Yamil Dagger
Registered User
Join date: 10 Jul 2007
Posts: 36
04-01-2008 22:12
Hello everybody, I have a question about camping devices. I made a VERY good quality camping script with a ton of features (trying to add anything anybody would ever need) and sofar it's worked out great.

Not too long ago, I made a bench with 3 poseballs people can use to sit on the bench. Inside each poseball I added my script and set it up. The bench and the poseballs are all linked so you just drop it and set each one up. I'm noticing some big problems now like when somebody sits, it records their key so when they stand and resit, they have to wait at least 1 minute (to allow others to have a chance to sit) BUT if somebody is sitting on this bench and somebody else sits, they both get kicked off. I turned off the resit wait time but now whenever somebody sits, the other 2 spots revert back to 0 nomatter what they were at.

Is there something in my scripts that make linking not work correctly? Why are the poseballs even effecting eachother? And what can I do to make this work short of unlinking the poseballs from the bench and eachother?
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
04-02-2008 03:25
I've encountered this issue myself; if you're relying on the changed() event then you need to remember that when someone sits/unsits from your object then EVERY script will receive a changed() event.

So basically you need to ensure that your script tracks who is on the object (using llAvatarOnSitTarget()) and check it where relevant. For example:

CODE
key onMe = NULL_KEY;

default {
changed(integer x) {
if (x & CHANGED_LINK) {
key id = llAvatarOnSitTarget();

if (id != onMe) { // It's me that changed
if (id != NULL_KEY) {
// Someone just sat on me
} else {
// Someone just unsat from me
}

onMe = id;
}
}
}
}


The above is usually correct practise for using sit-targets, even if you only expect to ever have one prim, just in case.
_____________________
Computer (Mac Pro):
2 x Quad Core 3.2ghz Xeon
10gb DDR2 800mhz FB-DIMMS
4 x 750gb, 32mb cache hard-drives (RAID-0/striped)
NVidia GeForce 8800GT (512mb)
Kephra Nurmi
winged bug
Join date: 12 Jan 2007
Posts: 180
04-02-2008 18:54
Moin Haravikk,

From: Haravikk Mistral
The above is usually correct practise for using sit-targets, even if you only expect to ever have one prim, just in case.


*hm* // Someone just sat from me
in a linked object this could be triggered while someone is already sitting on me, by someone else who is sitting or unsitting somewhere in the linkset.

so you need to compare the av key, and if its the same, then the link change was on an other prim. If there is no av who sits on the target, then i clean the key of the av who is sitting on me.

ciao,Kephra
Haravikk Mistral
Registered User
Join date: 8 Oct 2005
Posts: 2,482
04-03-2008 04:21
From: Kephra Nurmi
so you need to compare the av key, and if its the same, then the link change was on an other prim. If there is no av who sits on the target, then i clean the key of the av who is sitting on me.

ciao,Kephra

Isn't that what my script snippet does? I know the formatting is awful, but it works basically like this:

- The 'onMe' variable stores the id of anyone on the scripted prim, or NULL_KEY if there is no-one.
- A CHANGED_LINK changed event comes through.
- If the value of llAvatarOnSitTarget() is no longer identical to 'onMe' then either someone has sat on the scripted prim, or unsat from it.
- The script decides which of these two things happened, does some stuff, and then updates 'onMe'.
_____________________
Computer (Mac Pro):
2 x Quad Core 3.2ghz Xeon
10gb DDR2 800mhz FB-DIMMS
4 x 750gb, 32mb cache hard-drives (RAID-0/striped)
NVidia GeForce 8800GT (512mb)