Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Detecting Worn or Attached items

Rock Vacirca
riches to rags
Join date: 18 Oct 2006
Posts: 1,093
02-11-2008 06:45
Is there ANY way of detecting if an avi is wearing or has attached a particular prim? I would like to script a door that ONLY opens if an avi has picked up a key at a previous location.

TIA

Rock
Rock Vacirca
riches to rags
Join date: 18 Oct 2006
Posts: 1,093
02-11-2008 07:13
OK, after thoroughly reading the wiki, it would appear that the answer is an emphatic 'no!'.

OK, so it is workaround time. An idea that occurred to me is to have the object to be picked up scripted, so that it says the word KEY on channel -7654321 every 3 seconds, and for the Door to be listening on this channel for the KEY word.

It seems an awful waste of resources to have the Key saying this word, maybe forever, if no-one picks it up, so i was wondering if it would be possible to start the script ONLY when the object is worn or attached, and to Die after 30 minutes (by which time they should have got to the Door that needs it).

The simple script so far is:

CODE

integer channel = -7654321;

default
{
state_entry()
{
llSetTimerEvent(3); //trigger every 3 seconds
}

timer()
{
llSay(channel, "KEY");
}
}


Any suggestions for the script to start only when worn or attached?

I guess I can figure out how to count the time until 30 minutes is reached and issue the Die command (but any caveats or pitfalls to look out for also welcome).

Rock
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
02-11-2008 07:22
solution:

when the door is touched, it requests the key on a given channel.

if the prim hears the request, it responds to the door.

Now when the door hears the proper response, it opens or unlocks.
Hewee Zetkin
Registered User
Join date: 20 Jul 2006
Posts: 2,702
02-11-2008 09:10
Right. And if the key must be worn, only have it respond if it is currently attached (by using 'attach' events or testing llGetAttached() when it hears the query). If you need the know who the key is attached to, you can simply test its owner with llGetOwnerKey() since you can only attach your own objects.
Billy Islander
Registered User
Join date: 3 Nov 2006
Posts: 35
02-11-2008 11:09
From: Squirrel Wood
solution:

when the door is touched, it requests the key on a given channel.

if the prim hears the request, it responds to the door.

Now when the door hears the proper response, it opens or unlocks.


a nice touch to this would be an animation that has the avie produce a prim key insert it into the door and voila the door opens lol
Imnotgoing Sideways
Can't outlaw cute! =^-^=
Join date: 17 Nov 2007
Posts: 4,694
02-11-2008 12:02
If I remember right. Carnival of Doom has a ticket HUD that does exactly that to let visitors ride the rides while following the rules of the park. (^_^)y
_____________________
Somewhere in this world; there is someone having some good clean fun doing the one thing you hate the most. (^_^)y


http://slurl.com/secondlife/Ferguson/54/237/94
Rock Vacirca
riches to rags
Join date: 18 Oct 2006
Posts: 1,093
02-11-2008 13:43
Many thanks for the responses guys. Unfortunately the solution based on touching the door will not work in my case, as the avatar does not know that there is a door there to touch. The magical door only opens if the avi has picked up something elsewhere (that he does not necessarily know to be a key). But just by walking close to the place where the door is located (but disguised) it will magically open for him. It is then that the relevance of the object picked up and the door appearing and opening becomes clear to him, and helps him solve other puzzles as he progresses.

So, could someone help with the question posed, how do I get a script to run only when either worn or attached?

TIA

Rock
Imnotgoing Sideways
Can't outlaw cute! =^-^=
Join date: 17 Nov 2007
Posts: 4,694
02-11-2008 14:16
Actually, that's exactly how scripts are run in wearable objects... They only work when worn.... I just got a 'store card' that worked that way yesterday. 50L$ off anything in the store just by wearing it and picking a special spot in the pie. \(^_^)/

Anyways, having a loop spamming text to an obscure channel isn't that much of a load. Just be sure to put in a nice sensible delay and few people will notice. Maybe just put the spam loop in the door and set the attachment card to listen and respond on another channel once it gets something. That way you can have one looping script and thousands of listeners with the potential to open the door. Think about the load AOs have and you will find there is nothing to worry about. (^_^)y

I think the idea is cool... Virtual RFID tag for your virtual home and office. (^_^)y
_____________________
Somewhere in this world; there is someone having some good clean fun doing the one thing you hate the most. (^_^)y


http://slurl.com/secondlife/Ferguson/54/237/94
Harleen Gretzky
Registered User
Join date: 27 Oct 2005
Posts: 51
02-11-2008 22:24
Put an invisible llVolumeDetect collision prim in front of the door, when an avatar collides with the prim, it asks the key if it is being worn (just like the touch example), the collision prim then tells the door to open.
Imnotgoing Sideways
Can't outlaw cute! =^-^=
Join date: 17 Nov 2007
Posts: 4,694
02-12-2008 05:38
I played with the idea a little yesterday by using llWhisper and made it so the object would activate (open door) if the person was carrying (attached somewhere) the card and came near.

It didn't seem to be the best idea for a door... But, I'm thinking a hall or a home with dynamic lights would be really cool. Imagine, having each light turn on and off or changing color depending on who's strolling though. (^_^)

I'm sure there are way better ways to do that stuff though, I've seen some freebie sim scanners that can get the location of each object and avatar around it. (^_^)y
_____________________
Somewhere in this world; there is someone having some good clean fun doing the one thing you hate the most. (^_^)y


http://slurl.com/secondlife/Ferguson/54/237/94