Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Tracking Satellite

Nick Svarog
Registered User
Join date: 9 Sep 2004
Posts: 5
05-25-2005 22:31
I'm trying to make a satellite that can track me so that I... have a satellite following me around. Just something to do I guess.

So far my satellite can float and come back down. That wasn't too bad. A little help from this forum and now I'm figuring some of this out.

The next thing I want it to do is follow me. How can I get my vector location (wherever I am) and pass it to the object to have it follow me?

The thing after that is converting strings into keys so that my satellite can track my friends based on giving a string value of their name or tracking my objects so that I can't lose them as easily?

Thanks for all the help. I've been looking at the Wiki and guide for a while and can't find things to get this done.
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
05-26-2005 03:08
From: Nick Svarog
The next thing I want it to do is follow me. How can I get my vector location (wherever I am) and pass it to the object to have it follow me?

Try using one from this list.

In this case, you probably want llDetectedPos from llSensorRepeat("",llGetOwner(),AGENT,50,TWO_PI,0.5);

Or the like.

Then plug the detected stuff into the sensor event

From: Nick Svarog
The thing after that is converting strings into keys so that my satellite can track my friends based on giving a string value of their name or tracking my objects so that I can't lose them as easily?

Try llDetectedKey and llKey2Name. Replace llGetOwner() above with this key.

So it would look something like this:
CODE
llSensorRepeat("","your friend's key",AGENT,50,TWO_PI,0.5);


As for making it return, you can program that into the no sensor event. That's called every time a sensor fails to find a return.
_____________________
---
Nick Svarog
Registered User
Join date: 9 Sep 2004
Posts: 5
05-26-2005 04:04
So would it look something like this:

CODE
default
{
state_entry()
{
llSay(0, "Hello, Avatar!");
llSensorRepeat("",llGetOwner(),AGENT,50,TWO_PI,.5);
}

sensor(integer total_number)
{
integer i;
if(is_floating==TRUE)
{
targetPos = llDetectedPos(total_number);
targetPos.y += 10;
llSetPos(targetPos);
}
}
}
Frans Charming
You only need one Frans
Join date: 28 Jan 2005
Posts: 1,847
05-26-2005 07:14
i believe the totalnumber will be 1, but the first number is 0.
It has to be this:
llDetectedPos(0)
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
05-26-2005 11:31
You missed a bit, and there are a few easy optimizations.

CODE
default
{
state_entry()
{
llSensorRepeat("",llGetOwner(),AGENT,50,TWO_PI,.5);
}

sensor(integer total_number)
{
if(is_floating==TRUE)
{
llSetPos( llDetectedPos( 0 ) + <0,0,10> );
}
}
}


Also, consider making it physical to make the tracking seem more natural.

CODE
default
{
state_entry()
{
llSetStatus( STATUS_PHYSICS , TRUE );
llSetStatus( STATUS_PHANTOM , FALSE );
llSensorRepeat("",llGetOwner(),AGENT,50,TWO_PI,.5);
}

sensor(integer total_number)
{
if(is_floating==TRUE)
{
llMoveToTarget( llDetectedPos( 0 ) + <0,0,10> , 1 );
}
}
}
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
05-26-2005 18:08
Close. Starting from Keknehv's code:

CODE
default
{
state_entry()
{
llSetStatus( STATUS_PHYSICS , TRUE );
llSetStatus( STATUS_PHANTOM , FALSE );
llSensorRepeat("",llGetOwner(),AGENT,50,TWO_PI,.5);
}

sensor(integer total_number)
{
if(is_floating==TRUE)
{
llMoveToTarget( llDetectedPos(total_number) + <0,0,10> , 1 );
}
}
}


Two oversights I'd like to point out. The first is that llMoveToTarget will not work unless the object is physical. This is a simple fact. For nonphysical movement, you should always use llSetPos or the lesser-known constant in llSetPrimitiveParams.

Second, total_number starts at 1 in the sensor event - it is called when at least one object/agent is detected. However, as mentioned, llDetected starts at zero. As such, you will need to do the following:

CODE
// For just one agent, you should just do this:
llMoveToTarget( llDetectedPos(0) + <0,0,10> , 1 );

// However, if you wanted several agents, try this:
integer i;
for(i = 0; i < total_number; ++i)
llMoveToTarget( llDetectedPos(i) + <0,0,10> , 1 );
// Start at i = 0, loop until i is equal or greater than total_number,
// add 1 to i each pass. Note the < instead of <=. This is because
// querying the return for total_number would be invalid.

// For example, suppose three agents are detected.
// total_number = 3
// The agents would be llDetectedFunction(0), llDetectedFunction(1),
// and llDetectedFunction(2). There is no llDetectedFunction(3).

Hope that helps.
_____________________
---
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
05-26-2005 19:07
Two oversights that I'd like to point out in your revisions to my "oversights".

My code makes the object physical, so it is a non-issue that the llMoveToTarget requires the object to be physical. I even commented on how if it was physical, this would work. Did you completely miss this line of code?
CODE

llSetStatus( STATUS_PHYSICS , TRUE );


Also, my for loop was not flawed. Please examine it again.

All of my code was correct.

Next time you decide to correct oversights, please ensure that they are really oversights and not your own errors.
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
05-26-2005 19:28
Huh? Calm down. I'm just pointing out a few revisions, not bashing your way of life.

The first is a correction for clarity, it doesn't mean you are wrong or stupid. I just wanted to make it clear what it is that works and that does not.

However, I did miss the fact he was using llSetPos prior, but this does bring up another interesting point. llMoveToTarget(position, 1); may have trouble. I would use a damping number of 0.3 to 0.1 instead.

------

The second was a correction that I believe was improper, but again, this is for correctness, not to bash on you.

The use of the total_number variable is a minor problem. As mentioned, simply plugging in total_number in llDetectedPos, like this:

CODE
llDetectedPos(total_number)


... is incorrect. This is more proper for total_number = 1:

CODE
llDetectedPos(total_number - 1)


... though I would just do this instead:


CODE
llDetectedPos(0)



------

I will again stress that this is not to "bash" on your methods, but rather, to offer the most correct information that I know.

If I see a response like that again, I'm going to abuse report it - self-righteousness is not a friend of coding, especially when the corrections would save needless frustration later.

That said, let's discuss the topic again, shall we?
_____________________
---
Keknehv Psaltery
Hacker
Join date: 11 Apr 2005
Posts: 1,185
05-26-2005 19:31
Sorry about that--I get too involved sometimes...

Also, my code was in error because I failed to catch Nick's error.

Maybe I should get a bit more sleep before I continue posting...
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
05-26-2005 19:34
S'ok. It happens to the best of us. :D
_____________________
---