Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

follow fish

Cro Sola
Registered User
Join date: 19 Jul 2006
Posts: 34
09-12-2006 22:28
im trying to make a script that will sense for one object then when it goes to that one it will sense for the next one

this is the script im using to get to the first object but it not really working the way i want it to

CODE

default
{
state_entry()
{
vector pos = llGetPos();
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y, FALSE);
llSetStatus(STATUS_PHYSICS, TRUE);
llSleep(0.1);
llMoveToTarget(pos,0.1);
key id = llGetOwner();
llSensorRepeat("","pol1",PASSIVE,50,2*PI,.4);
}

sensor(integer total_number)
{
vector pos = llDetectedPos(0);
vector offset =<-1,0,0>;
pos+=offset;
llMoveToTarget(pos,.3);
}
}


please someone help and if any one can make it more basic that would be great
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
09-13-2006 05:25
The first problem I see is that you are passing the string "poll" to the call to the sensor rather than a key.
The syntax is

llSensorRepeat(string name, key id, integer type, float range, float arc, float rate)
See the wiki for details

Although keys are treated as special strings I dont think it will work.

Secondly you are only processing the first detected object.
Unless the targets are being deleted (eaten?) as the fish moves it will get to the point where it can detected at least two, the current one and the next one.

You will need to iterate the list of returned objects and find the second closest.
I'm not sure that sensor returns data in range order (Anyone?)