User:Toy Wylie/Meeroos/Meeroo Finder

From Second Life Wiki
< User:Toy Wylie
Revision as of 04:38, 7 July 2011 by Toy Wylie (talk | contribs) (New version)
Jump to navigation Jump to search

Copy this script into a normal 0.5m box, sit on it and say the name of the Meeroo you are looking for on channel 6. If it is within 96.0 meters of range, the finder will move towards it and follow it around. Make sure to type the exact meeroo name, capital letters matter. So if your Roo was named "Kiki Meeroo", type: /6Kiki

<lsl>key target;

follow(key k) {

   if(k==NULL_KEY)
       llSetTimerEvent(0.0);
   else
       llSetTimerEvent(0.5);
   target=k;

}

rebuild() {

   llSetPrimitiveParams(
   [
       PRIM_TYPE,PRIM_TYPE_CYLINDER,
           PRIM_HOLE_DEFAULT,
           <0.0,1.0,0.0>,
           0.5,
           <0.0,0.0,0.0>,
           <1.0,1.0,0.0>,
           <0.0,0.0,0.0>,
       PRIM_SIZE,<1.0,1.0,0.0375>,
       PRIM_TEXTURE,
           ALL_SIDES,
           TEXTURE_BLANK,
           <1.0,1.0,0.0>,
           <0.0,0.0,0.0>,
           0.0,
       PRIM_COLOR,
           ALL_SIDES,
           <0.0,0.5,1.0>,
           0.6,
       PRIM_GLOW,
           ALL_SIDES,
           0.3
   ]);

}

default {

   on_rez(integer dummy)
   {
       llResetScript();
   }
   state_entry()
   {
       rebuild();
       target=NULL_KEY;
       llSitTarget(<0.0,0.0,0.80>,ZERO_ROTATION);
       llSetClickAction(CLICK_ACTION_SIT);
   }
   listen(integer c,string name,key k,string message)
   {
       llSensor(message+" Meeroo",NULL_KEY,SCRIPTED,96.0,PI);
   }
   no_sensor()
   {
       llOwnerSay("Not found.");
   }
   sensor(integer num)
   {
       target=llDetectedKey(0);
       while(llVecDist(llGetPos(),llDetectedPos(0))>9.0)
           llSetLinkPrimitiveParamsFast(LINK_THIS,
           [
               PRIM_POSITION,llDetectedPos(0)
           ]);
       follow(llDetectedKey(0));
   }
   changed(integer change)
   {
       if(change==CHANGED_LINK)
       {
           key avatar=llAvatarOnSitTarget();
           if(avatar!=NULL_KEY)
           {
               llListen(6,"",avatar,"");
               llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
           }
           else
           {
               llResetScript();
           }
       }
   }
   run_time_permissions(integer perms)
   {
       if(perms & PERMISSION_TRIGGER_ANIMATION)
       {
           llStopAnimation("sit");
       }
   }
   timer()
   {
       list details=llGetObjectDetails(target,[OBJECT_POS,OBJECT_ROT]);
       vector pos=llList2Vector(details,0);
       rotation rot=llList2Rot(details,1);
       llSetLinkPrimitiveParamsFast(LINK_THIS,
       [
           PRIM_POSITION,pos,
           PRIM_ROTATION,rot*llEuler2Rot(<0.0,0.0,-90.0>*DEG_TO_RAD)
       ]);
   }

} </lsl>