Excluding certain avatars from sensors?
|
Lisa Trudeau
Registered User
Join date: 22 Aug 2005
Posts: 29
|
12-18-2005 19:12
I'm trying to throw together a script to detect anyone who comes to my events an item, and say hello and rules and regulations, what theme night it is, etc. I've gotten everything thrown together using a sensor, but my only problem is everytime anyone comes within 10m of the sensor it repeats itself to them;
i only know how to either exclude only specific avatars/include only specific avatars (by using keys), or include anyone within distance of sensor sweep
I would basically like to be able to give item/say rules/regs to everyone the first time they come through the door, not again if they happen to come too close to the sensor or come back for the night.
could anyone possibly help me out? thanks!
Lisa
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
12-18-2005 20:11
What you have to do is keep a list of whom the object has given things to, and then check that list whenever a new avatar is detected within range. Each time you detect something, use llListFindList to check whether they've been seen before, and if not add their name to the list of given names. (You can use names for avatars because they don't change and are shorter than keys.)
You'll probably want to clear the list every now and then or it will get too full - when will depend on how busy the area is.
|
Lisa Trudeau
Registered User
Join date: 22 Aug 2005
Posts: 29
|
12-18-2005 22:34
makes sense, i figured i'd have to use somthing to do with adding names to a list, what sensor syntax would i use to only give to ppl who aren't on the list htough?
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
12-18-2005 23:57
If you'd like to post the bit of code we can tell you absolutely. But basically you'd have something like: sensor (integer num) { integer i; for(i=0; i<num; ++i) { if(llListFindList(AlreadyReceived, [llDetectedName(i)])> -1) { llGiveInventoryList(llDetectedKey(i), "Goodies from here", goodyBag); AlreadyReceived+=llDetectedName(i); } } }
|
Ben Bacon
Registered User
Join date: 14 Jul 2005
Posts: 809
|
12-19-2005 03:31
Lisa - by all means, complete this project, if only for the satisfaction of completing it and the experience gained - but then..
Could I suggest that you not use this technique at all. As Ordinal said, you are going to run out of list space (sooner than you think) and be forced to clear out entries. This can be quite complex to do correctly, but will invariably end up activating for people that is already has.
Many people dislike having automated objects talking excessively or throwing unsolicited notecards at them when they arrive somewhere. Having a prominent "Touch here for the rules" note giver would be a bit more polite, IMHO.
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
12-19-2005 05:32
Yeah, a touch script would be better in practice. I prefer to request information and get it, rather than have it shoved at me. I might have lots of windows up at the time and another one popping up can be annoying. The other thing is that if somebody deletes a notecard and wants another one, they can't get it if it's handed out automatically. For informational purposes, though, to have people pop off the end of the list when it reaches a certain size, you could add integer maxListLength = 30; // or whatever at the start and put integer listLength = llGetListLength(AlreadyReceived); if (listLength > maxListLength) { AlreadyReceived = llList2List(listLength - maxListLength, -1); }
after the closing bracket of the "for" in that code. If you're collecting lists with sensor it's always a good idea to have something like this.
|
Kenn Nilsson
AeonVox
Join date: 24 May 2005
Posts: 897
|
12-19-2005 08:21
Let me add that...if your object plans to remain in the same place for a good amount of time...that a Volume Detect is much better/less laggy than a sensor and is really able to produce the same results.
And...lemme throw in my agreeance with the touch idea instead. If there is one thing that makes me DIS-like an area, it's throwin' info. at me unsolicited.
_____________________
--AeonVox--Computer games don't affect kids; I mean if Pac-Man affected us as kids, we'd all be running around in darkened rooms chasing ghosts, eating magic pills, and listening to repetitive, addictive, electronic music.
|
Lisa Trudeau
Registered User
Join date: 22 Aug 2005
Posts: 29
|
12-19-2005 10:40
i never really thought about that (throwing unwanted stuff at people)
It absolutely makes more sense to have a touch item that gives items instead. The scipt posted above would be helpful to say rules/regs to everyone, though i'm assuming, since i feel it's important for everyone who shows up to at least know what the rules/regs and theme for the night is; tossing in a whisper instead of giveinventory should work.
Thank you for all of your help!
And i'll definately have to read up on volumedetect. thanks again!
Lisa
|
Lisa Trudeau
Registered User
Join date: 22 Aug 2005
Posts: 29
|
12-19-2005 11:33
Wait, i'm confused on the snippet of code that was posted earlier sensor (integer num) { integer i; for(i=0; i<num; ++i) { if(llListFindList(AlreadyReceived, [llDetectedName(i)])> -1) { llGiveInventoryList(llDetectedKey(i), "Goodies from here", goodyBag); AlreadyReceived+=llDetectedName(i); } } }
Specifically, if(llListFindList(AlreadyReceived, [llDetectedName(i)])> -1). If the name is ON the already recieved list, it will return a number > -1, right? so it would give it to them again? shouldn't i use <= -1 to only give to people NOT on the list? Very new to lists, sorry for all the questions! -Lisa
|
Harris Hare
Second Life Resident
Join date: 5 Nov 2004
Posts: 301
|
12-19-2005 14:09
Good eye, Lisa! The IF statement should really be:
if (llListFindList(AlreadyReceived, [llDetectedName(i)]) == -1)
You can use <= -1 but I don't believe a list entry can have a negative index so == should always work fine.
|