|
Juelz Smails
Registered User
Join date: 27 Feb 2006
Posts: 11
|
04-24-2006 06:44
Dear Reader, I need a bit of help, on Sensors. My problem is; I have a prim, and I want it to locate another prim of it's kind, but only if It comes from the owner. Could someone please post a reply ASAP? ---------------------------------------- Thank You! -- Juelz Smails
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
04-24-2006 07:14
You want to check that the owners of the two objects are the same, using llGetOwnerKey and llGetOwner. So something like: default { state_entry() { llSensor("", NULL_KEY, SCRIPTED, 96.0, PI); }
sensor(integer n) { integer f = 0; do { if (llGetOwnerKey(llDetectedKey(f)) == llGetOwner()) { llOwnerSay("I found " + llDetectedName(f)); } } while (++f < n); } }
|
|
Juelz Smails
Registered User
Join date: 27 Feb 2006
Posts: 11
|
Okay
04-24-2006 08:23
I understand that part, I just need help on making a prim, follow another rooted prim. I need It to follow the prim, just like it would follow an agent, but how do I specify the name?
|
|
Ordinal Malaprop
really very ordinary
Join date: 9 Sep 2005
Posts: 4,607
|
04-24-2006 08:59
I wouldn't use the name, I'd use the key. Probably once you'd detected the object you wanted to follow the first time, you'd then enter a state which scanned for that specific key using llSensorRepeat, and then used llMoveToTarget or llSetPos to move towards whatever was detected. That part wouldn't be much different from any other follow script, except that it would be looking for a SCRIPTED rather than an AGENT. i.e. something like key gFollowing = NULL_KEY;
default { state_entry() { llSensor(llGetObjectName(), NULL_KEY, SCRIPTED, 96.0, PI); }
sensor(integer n) { integer f = 0; do { key id = llDetectedKey(f); if (llGetOwnerKey(id) == llGetOwner()) { gFollowing = id; state following; } } while (++f < n); } }
state following { state_entry() { llSensorRepeat("", NULL_KEY, gFollowing, SCRIPTED, 96.0, PI, 1.0); }
sensor(integer n) { llSetPos(llDetectedPos(0)); } } I changed the llSensor to only scan for objects with the same name, too, which would stop it from sensing other, closer things you had. But once you have the key you don't need anything else to specify what you want to sense.
|