Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Getting pet to follow someone else

Johnny Night
Registered User
Join date: 18 Apr 2005
Posts: 33
04-27-2005 22:47
Ok, I'm trying to get my little pet to follow on command. Needless to say, it goes 10 meeters in one direction, then comes back to me, not attachting to anyone else. Any ideas where I went wrong?
default

{
state_entry()
{

llListen( 0, "", NULL_KEY, "" );

}

listen( integer channel, string name, key id, string message )

{

if ( id == llGetOwner() )
{

if ( message == "follow" )
{

vector follow = llGetPos() + <0, 10, 0>;;
llSay( 0, "Yes my Master!" );

llSetColor(<1.0, 0.0, 0.0>, ALL_SIDES);
llTriggerSound("yesmaster", 1.0);
llSetTimerEvent(1.8); // generate a timer event every 1 second
llMoveToTarget(follow,0.1);
llSensorRepeat("",id,AGENT,20,2*PI,.4);

}

}



vector pos = llGetPos();
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Z, FALSE);
llSetStatus(STATUS_PHYSICS, TRUE);
llSleep(0.1);
llMoveToTarget(pos,0.1);
key id = llGetOwner();
llSensorRepeat("",id,AGENT,20,2*PI,.4);


}

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


}
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
04-28-2005 03:09
Yep. Check your listener event there... you have the listener flow directly into the standard follower for yourself, effectively cancelling out what you wanted to do.

I'm too tired presently to format it and show you in the code, but the short of it is add an else or something after the if statements in the listen event. :p
_____________________
---
Kris Ritter
paradoxical embolism
Join date: 31 Oct 2003
Posts: 6,627
04-28-2005 03:59
And just as well you didnt post that code, Jeffrey! Can you imagine the outcry if you publicly release code to make objects follow OTHER people?!!!111!!!1! Griefer! Think before you script!!!11!

*rezzes pitchfork*
CrystalShard Foo
1+1=10
Join date: 6 Feb 2004
Posts: 682
04-28-2005 04:14
There's afew problems with your code:

Your llListen call makes the script listen to everyone, and then you filter who can give commands in the listen event itself. You dont really need to do this if its only one person you want the script to listen to: Just replace the "NULL_KEY" in the llListen with llGetOwner().

That will make the entire Listen event fire only when you (the owner) speaks.

Another small issue is this line:
vector follow = llGetPos() + <0, 10, 0>;;

Has double ";" marks. You only need one. :)

Now, here's the real headache: You have a whole slice of code in your listen() event, out of if(id == llGetOwner()) {} that will trigger whenever -anyone- says anything. Frankly i'm not really sure why its there.

What are you trying to do exactly? Do you want the pet to hop around at random until you tell it to follow? If you just want it to follow the moment you drop it, try to put the whole llSetStatus and llSensorRepeat startup in state_entry, without a listener. That'll work.

I am sorry if this does not answer your original question, but frankly - the code is too messy as it is right now to just fix it to make it work with your original purpose.

Sort the code first, then it will be much easier to sit and make it do what you actually intended. :)
Kris Ritter
paradoxical embolism
Join date: 31 Oct 2003
Posts: 6,627
04-28-2005 04:19
*sticks pitchfork in CS*

It's your typical cavalier scripterati techi wikki free loving tree hugging hippy kitty attitude that is precisely what is wrong with SL today. Why not just write the griefing tools for them? hmmmm? *sigh*