Does anyone know how to fix this script for Kitely?

Creating scripts
Post Reply
Catya Smith
Posts: 21
Joined: Sun Jan 06, 2013 4:42 am
Has thanked: 8 times
Been thanked: 5 times

Does anyone know how to fix this script for Kitely?

Post by Catya Smith »

Script for one avatar to follow another:
This script sets up properly in Kitely and says it is working (no errors at all) it even recognizes the avatar you are to follow, but will not work. Does anyone know how I can make it work in Kitely? It works in SL. Thanks :)

Code: Select all

integer CHANNEL = 15;  // That's "f" for "follow", haha
 
float DELAY = 0.5;   // Seconds between blinks; lower for more lag
float RANGE = 3.0;   // Meters away that we stop walking towards
float TAU = 1.0;     // Make smaller for more rushed following
 
// Avatar Follower script, by Dale Innis
// Do with this what you will, no rights reserved
// See https://wiki.secondlife.com/wiki/AvatarFollower for instructions and notes
 
float LIMIT = 60.0;   // Approximate limit (lower bound) of llMoveToTarget
 
integer lh = 0;
integer tid = 0;
string targetName = "";
key targetKey = NULL_KEY;
integer announced = FALSE;
 
init() {
  llListenRemove(lh);
  lh = llListen(CHANNEL,"",llGetOwner(),"");
}
 
stopFollowing() {
  llTargetRemove(tid);  
  llStopMoveToTarget();
  llSetTimerEvent(0.0);
  llOwnerSay("No longer following.");
}
 
startFollowingName(string name) {
  targetName = name;
  llSensor(targetName,NULL_KEY,AGENT_BY_LEGACY_NAME,96.0,PI);  // This is just to get the key
}
 
startFollowingKey(key id) {
  targetKey = id;
  llOwnerSay("Now following "+targetName);
  keepFollowing();
  llSetTimerEvent(DELAY);
}
 
keepFollowing() {
  llTargetRemove(tid);  
  llStopMoveToTarget();
  list answer = llGetObjectDetails(targetKey,[OBJECT_POS]);
  if (llGetListLength(answer)==0) {
    if (!announced) llOwnerSay(targetName+" seems to be out of range.  Waiting for return...");
    announced = TRUE;
  } else {
    announced = FALSE;
    vector targetPos = llList2Vector(answer,0);
    float dist = llVecDist(targetPos,llGetPos());
    if (dist>RANGE) {
      tid = llTarget(targetPos,RANGE);
      if (dist>LIMIT) {
          targetPos = llGetPos() + LIMIT * llVecNorm( targetPos - llGetPos() ) ; 
      }
      llMoveToTarget(targetPos,TAU);
    }
  }
}
 
default {
 
  state_entry() {
    llOwnerSay("/"+(string)CHANNEL+" [name of person to magically follow]");
    init();
  }
 
  on_rez(integer x) {
    llResetScript();   // Why not?
  }
 
  listen(integer c,string n,key id,string msg) {
    if (msg == "off") {
      stopFollowing();
    } else {
      startFollowingName(msg);
    }
  }
 
  no_sensor() {
    llOwnerSay("Did not find anyone named "+targetName);
  }
 
  sensor(integer n) {
    startFollowingKey(llDetectedKey(0));  // Can't have two ppl with the same name, so n will be one.  Promise.  :)
  }
 
  timer() {
    keepFollowing();
  }
 
  at_target(integer tnum,vector tpos,vector ourpos) {
    llTargetRemove(tnum);
    llStopMoveToTarget();  
  }
 
}
Last edited by Catya Smith on Sun Aug 11, 2013 3:42 am, edited 1 time in total.
These users thanked the author Catya Smith for the post:
Barnard Smith
User avatar
Dundridge Dreadlow
Posts: 616
Joined: Mon May 06, 2013 2:23 pm
Location: England
Has thanked: 590 times
Been thanked: 339 times

Re: Does anyone know how to fix this script for Kitely?

Post by Dundridge Dreadlow »

Ooookay.

I now have a cube chasing me around the place. It moves and flies straight at me.
What is it doing/not doing ? The physics between SL and Kitely are different, but it looks like it is doing pretty much what the script says ?
ImageImageImageImageImageImage
PS. Kitely is awesome.
Catya Smith
Posts: 21
Joined: Sun Jan 06, 2013 4:42 am
Has thanked: 8 times
Been thanked: 5 times

Re: Does anyone know how to fix this script for Kitely?

Post by Catya Smith »

Oookay, that would be great if the script was used in the manner it was designed to be used in. It is an "Avatar Follower script" where as one avatar follows another. I didn't bother to test this on an inanimate prim, as I already have a script for this.

I'm sorry you missed the line in the code that gets the avatar key that engages the scripts functionality. I'm surprised it even worked on a prim!
User avatar
Dundridge Dreadlow
Posts: 616
Joined: Mon May 06, 2013 2:23 pm
Location: England
Has thanked: 590 times
Been thanked: 339 times

Re: Does anyone know how to fix this script for Kitely?

Post by Dundridge Dreadlow »

heh :)

Doesn't say anything in the script about that... just follow avatar :D

looking at the code, it should work exactly the same though.

There is very little difference to a cube following something with physics, to an avatar doing the same. As long as you are wearing the cube (or whatever it is the script ends up in) it should be fine. On testing, it seems to work fine attached to me following another avatar, what issues are you having ?
ImageImageImageImageImageImage
PS. Kitely is awesome.
Catya Smith
Posts: 21
Joined: Sun Jan 06, 2013 4:42 am
Has thanked: 8 times
Been thanked: 5 times

Re: Does anyone know how to fix this script for Kitely?

Post by Catya Smith »

Did you change the script in order to get the prim to follow you or to get another avatar to follow you? I would like to know what changes you made in order to do so. We tested it after you said you could get a prim to follow you but we aren't sure how it could, since it looks for an avatar (name)key and it didn't recognize the prim.

We also tested it again on two real avatars over and over and it looked as if it would work, it initiates, but does not function.

Please let us know if you made changes and what they are. We are wondering if it is something to do with a setting on the sim since you are able to get it to work. Thanks.
User avatar
Dundridge Dreadlow
Posts: 616
Joined: Mon May 06, 2013 2:23 pm
Location: England
Has thanked: 590 times
Been thanked: 339 times

Re: Does anyone know how to fix this script for Kitely?

Post by Dundridge Dreadlow »

Catya Smith wrote: since it looks for an avatar (name)key and it didn't recognize the prim.
Hmmmmmmmmmmm? It takes the name of the agent/avatar requested, scans for it by sensor, gets the key (a weird way, but it works) then calls startFollowing. This sends a message saying "now following", sets up a timer then calls keepFollowing. This does some stuff and moves towards the target.

If it reaches the target, it stops following till the timer tells it to keepFollowing again. The timer runs every 0.5 seconds... which is probably a "little" more than it really needs to.

I did nothing special and make no changes to the script. Worked first time. I just dropped it into a prim, set the prims physics on, and it worked. Was kind of floaty and behaved like it was very light. On attaching to me, I just hit wear.

Does your region have physics enabled ? Does your object ? Is it a megaregion ? are you out of sensor range ? Did you type the avatar name EXACTLY with capital letters and spaces ? Are you wearing the object ? Is it on as a HUD ?
ImageImageImageImageImageImage
PS. Kitely is awesome.
Catya Smith
Posts: 21
Joined: Sun Jan 06, 2013 4:42 am
Has thanked: 8 times
Been thanked: 5 times

Re: Does anyone know how to fix this script for Kitely?

Post by Catya Smith »

I'm not sure if you read the first post I made, but I have put this script into use in SL, so I know how it works and how to type the info in to make it work. I contacted Ilan and Oren and they said to post here to see if anyone knew of a solution-since it seemed not to work in Kitely.

I have done everything in here, that I have done in SL (where, as I said it worked on the first try) I contacted Ilan and Oren because I thought maybe it didn't work in here because of some feature that may or may not be turned on in Kitely. The fact that you say you are able to get it working, makes me think it is something here, because we have done the exact same things and I totally understand how to set this script up! I have been using it for a while and wanted to use it here . When you wrote out how you made it work, you didn't talk about how it you had to type 15 into chat, did you do that, or did you change the script? I'm curious how it would work without that, when it is part of the script.

We are going to go and try it in a sandbox, if we can not get it working there, I would appreciate you meeting us so we can see how you are able to get it to work in here with objects and other avatars.
Catya Smith
Posts: 21
Joined: Sun Jan 06, 2013 4:42 am
Has thanked: 8 times
Been thanked: 5 times

Re: Does anyone know how to fix this script for Kitely?

Post by Catya Smith »

Tried it in sandbox and it works...not as smooth as SL but it works. Will have to contact Ilan and Oren to see why it does not work in certain areas.
User avatar
Dundridge Dreadlow
Posts: 616
Joined: Mon May 06, 2013 2:23 pm
Location: England
Has thanked: 590 times
Been thanked: 339 times

Re: Does anyone know how to fix this script for Kitely?

Post by Dundridge Dreadlow »

scripts are easy, people are hard :)
Glad you got it working.

Things that MIGHT be different - physics being enabled, megaregions, parcel boundaries, the object with the script in it, size of the object, number of prims in the object, sometimes an object can misbehave and a replacement works perfectly.

Unrelated, I have one object without detectable scripts in that moves several cm up and along when I move it in any direction or just toggle phantom on and off.

I like setting objects to temp, enabling physics, and unlinking them to explode. Often, the "physics enabled" switches itself off. (By itself, after clicking the enable button, it gets itself toggled back off from something that isn't me) Perhaps your issue is related to this. I've not tested it in detail to see where/why. Maybe later :)
ImageImageImageImageImageImage
PS. Kitely is awesome.
Post Reply