|
Sarah Balderdash
Applesauce Unlimited
Join date: 13 Dec 2005
Posts: 28
|
01-23-2007 13:07
Hi, I've been working on a collision_start Greeter/Visitor Detector script, on the assumption that a collision_start would be "inactive," using fewer sim resources than "active" types of detectors. If I'm wrong on this please correct me! Anyway, I put this script in a prim inside the door to my house, and it works wonderfully when someone comes in. Unfortunately it *also* triggers when they walk *out* the door. Is there a way to make it trigger once per person per visit?
key owner;
default { state_entry() { owner = llGetOwner(); llVolumeDetect(TRUE); //makes the prim phantom-like but still register collisions llSetTexture("701917a8-d614-471f-13dd-5f4644e36e3c",ALL_SIDES); }
collision_start(integer num_detected) { if (llDetectedType(0) & AGENT) //only greet avatars, not prims. { llSay(0,"Hello, " + llDetectedName(0) +" welcome to X's land."); } if (llDetectedType(0) & AGENT) //only count avatars, not prims. { llInstantMessage(owner, llDetectedName(0) + " is visiting your land."); } } }
|
|
Osgeld Barmy
Registered User
Join date: 22 Mar 2005
Posts: 3,336
|
01-23-2007 23:12
make a list of ppl who have entered, and remove them after a set time or exit
|
|
Valradica Vanek
Registered User
Join date: 1 Aug 2006
Posts: 78
|
yes there is
01-24-2007 05:47
I have just finished such a greeter for a shop keeper who needed it. Its rather simple but require a bit of math. Simply make the prim so they can walk through it. Make the X direction of the prim the direction that the avatar walks in and out of the door. On collision_start, put the name of the avatar in a list and detect the velocity of the Avatar. take the X component of that velocity and compare it to the X direction of the prim. If the Avatar is going in the right direction, deliver the message on Collision_end and remove the name from the list.
If the avatar walks through the door the other way, then you simply detect that velocity and compare the directions again. You can tell what direction they are going and don't have to send a message if they are going out.
The best way to compare the direction is by normalizing the velocity into a unit vector. If you add the Unit vector of the Xdirection of the prim and the Xvelocity of the Avatar and the sum is > 1.414 (square root of 2) the avater is moving opposite to the direction of the prim. If the sum is < 1.414, then the avatar is moving in the same direction as the prim is pointing.
Hope this helps.
If not, contatct me in world and I can help you with the scripts.
|
|
Emily Triskaidekaphobia
Registered User
Join date: 13 Jan 2007
Posts: 44
|
02-25-2007 18:27
This worked for me ... but was actually simpler still. I have two doorways, and the direction is on the y axis so vector StartPt; vector EndPt;
default { state_entry() { llVolumeDetect(TRUE); }
collision_start(integer num_detected) { if (llDetectedType(0) & AGENT) { StartPt = llDetectedPos(0); } }
collision_end(integer num_detected) { float y_move; if (llDetectedType(0) & AGENT) { EndPt = llDetectedPos(0); y_move = StartPt.y - EndPt.y; if (y_move > 0) { llWhisper(0, "Welcome to Emily's Garage " + llDetectedName(0) + "!"); llWhisper(0, "This area is a public thoroughfare, please feel free to come and go as you like."); llInstantMessage(llGetOwner(), llDetectedName(0) + " entered the front door of the garage."); } } }
}
And then on the back door I have the same, but with y_move < 0 instead. So a person passes through either way but is only greeted when they first enter the room, no matter which way they leave. A simple change could be made for detecting motion on x. Using velocity seemed more trouble than it is worth. Cheers - em13
|
|
Winter Ventura
Eclectic Randomness
Join date: 18 Jul 2006
Posts: 2,579
|
02-26-2007 01:08
My store's kinda small, so I made one of these, with a "huge prim" that was phantom. Mine was really dumb, comparatively, just giving a notecard when the person started colliding The huge prim allowed me to encompass my entire store perfectly, keeping people from colliding with several prims in a linkset (I tried that first).
I like the door idea.. I just wish my store HAD a door. it's a TP in, TP out.
_____________________
 ● Inworld Store: http://slurl.eclectic-randomness.com ● Website: http://www.eclectic-randomness.com ● Twitter: @WinterVentura
|