Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

changed event wont tell me which prim?

bucky Barkley
Registered User
Join date: 15 May 2006
Posts: 200
03-30-2007 21:42
Oh hell, LSL ...

I'm trying to streamline an elevator TP (11 floors). It would be great
if I could make each button a sit target, and have one script and one object (per floor) ....

If I rely on a changed event, I can't tell which prim was clicked. Is that
correct? (shakes head in disbelief)

What I fear is that I need to break out all of the prims on their own, each
with their own silly changed event script. Of course, my way to minimize
impact is to have a '?' button bring up a temporary (1 min) directory
of the 11 floors (I dont want 100+ scripts running...)

Any good reason why llDetectedLinkNumber() shouldn't work from changed()?

adding to my LSL pet peeves list:
touch_xyz()
llTeleportAgent()
_____________________
Bucky Barkley -- Mammal, Scripter, Builder, Lover
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
03-31-2007 02:46
The various llDetected* events, almost certainly including that one only work in a limited number of events - collision*, touch* and sensor.

I'm confused how a button gets invoked by a changed event anyway - surely you touch buttons, and llDetectedLinkNumber is described as "Returns the link position (0 for a non-linked object, 1 for the root (parent) of a linked object, 2 for the first child, etc.) of the object the touch or collision event is triggered for." which is what I'd expect and makes no mention of changed events.
_____________________
Eloise's MiniMall
Visit Eloise's Minimall
New, smaller footprint, same great materials.

Check out the new blog
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
03-31-2007 05:24
From: Eloise Pasteur
The various llDetected* events, almost certainly including that one only work in a limited number of events - collision*, touch* and sensor.

I'm confused how a button gets invoked by a changed event anyway - surely you touch buttons, and llDetectedLinkNumber is described as "Returns the link position (0 for a non-linked object, 1 for the root (parent) of a linked object, 2 for the first child, etc.) of the object the touch or collision event is triggered for." which is what I'd expect and makes no mention of changed events.


Bucky is talking about a sit taget 'button' rather than a touch button.
Thne confusion is that, as you have already stated, a touch will give you the prim number (via llDetectedLink) where as a changed event purely says what has changed not where in the link set the change occurred.
bucky Barkley
Registered User
Join date: 15 May 2006
Posts: 200
03-31-2007 10:26
Yep, hence my frustration. I want a sit target, so that I can make a "left click and go" tp.

but I dont want 11 floors of 11 scripts each running...

.. I can temp rez a directory for the user, and let them pick a floor..

.. but if that's a sit target, I don't know what they picked, so I don't know where to take them...

.. if it's individual unlinked prims in the directory, I gotta make the user wait for them to rez... I'm certainly not going to hit them with a dialog asking permission to unlink prims...

.. or if it is all linked, and they pick a floor, I can then rez a sit target prim that will take them to the right floor (but it's one more click)

.. that's why I want llDetectedLink() to be available after a change() event.
_____________________
Bucky Barkley -- Mammal, Scripter, Builder, Lover
bucky Barkley
Registered User
Join date: 15 May 2006
Posts: 200
04-01-2007 12:58
Solved!

From: bucky Barkley
.. if it's individual unlinked prims in the directory, I gotta make the user wait for them to rez...


This was a fun one to get around. Rather than having a loop doing an llRezAtRoot(), I now have the faceplate prim for the elevator [1] set up as:

* there are scripts named 1 - 12 (11 floors, plus roof)
* each script has an on_rez event, they look up the script name so that they can
position the warpPos/sittarget prim for the floor
* et voila! 12 unlinked prims rez almost instantaneously, each positioned for the correct floor, and with the warpPos target appropriately

It was amazing to see the side by side difference of the 1 script/loop vs 12 script/direct rez.

All prims disappear after 30 seconds - I dont want 11 floors + roof elevators active 24/7

This has enabled me to cut the user interface clicks from 3 to 2 (1 to summon the directory, and 1 to go direct to the floor)

Oh, and right before warpPos(), the transport prim will do a quick llSay to the others, so that they can llDie() right away. No residue.

[1] the faceplate prim itself is rezzed from an elevator call button.
_____________________
Bucky Barkley -- Mammal, Scripter, Builder, Lover
BamBam Sachertorte
floral engineer
Join date: 12 Jul 2005
Posts: 228
04-01-2007 17:40
Although you seem to have solved your problem, I will respond to your original question. If you have an object that has multiple sit targets in multiple prims then the way to identity which prim was sat upon is to use llAvatarOnSitTarget(). All of the sit prims will get a changed() event, but only the prim that had the sit or unsit will see a change in llAvatarOnSitTarget(). For a multi-prim teleport system you would have code like this:
CODE
    changed(integer change)
{
if (change & CHANGED_LINK && llAvatarOnSitTarget() != NULL_KEY) {
llUnSit(llAvatarOnSitTarget());
}
}


For a multi-sit object like a couch you would store the key of the current sitting avatar in a variable and check to see if llAvatarOnSitTarget() changes. If you get a changed() event but your avatar key hasn't changed then some other prim was the source of the sit/unsit event.
bucky Barkley
Registered User
Join date: 15 May 2006
Posts: 200
04-02-2007 09:25
Ah, very good BamBam. I hadn't done the step of running the script in every sit-target prim. Thanks!

I suppose that reinforces my request to the Lindens.. make llDetected* work with changed(). It's overkill to have to run 12 scripts just to see which one got clicked on as a sit target :-)
_____________________
Bucky Barkley -- Mammal, Scripter, Builder, Lover