Difference between revisions of "User:Toy Wylie/Meeroos/Meeroo Finder"

From Second Life Wiki
Jump to navigation Jump to search
(New version)
(Clarified notecard)
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
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'''
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;
You can also add a notecard to the object with all the names of your Meeroos on it (one name per line). This enables you to just sit on the follower and click it to jump to the next Meeroo in the list. Your camera will be focused on the critter to make petting a lot easier.
 
<lsl>key target=NULL_KEY;
key avatar=NULL_KEY;
 
vector home;
rotation homeRot;
 
integer names;
key nameRequest=NULL_KEY;


follow(key k)
follow(key k)
Line 11: Line 20:


     target=k;
     target=k;
}
moveTo(vector pos,rotation rot)
{
    while(llVecDist(llGetPos(),pos)>9.0)
        llSetLinkPrimitiveParamsFast(LINK_THIS,
        [
            PRIM_POSITION,pos
        ]);
    llSetLinkPrimitiveParamsFast(LINK_THIS,
    [
        PRIM_POSITION,pos,
        PRIM_ROTATION,rot
    ]);
}
}


Line 39: Line 62:
             0.3
             0.3
     ]);
     ]);
    llWhisper(0,"Sit on me and say your Meeroo's name on channel 6. Example for Kiki Meeroo, say: /6Kiki\nBe sure to keep the correct capitalization. Or click on me to move to the next Meeroo on the embedded notecard.");
}
nextName()
{
    string name=llGetInventoryName(INVENTORY_NOTECARD,0);
    if(name=="")
    {
        llRegionSayTo(avatar,0,"Please add a notecard with your meeroos' names on it to the object to use the automation.");
        return;
    }
    nameRequest=llGetNotecardLine(name,names);
    names++;   
}
sense(string name)
{
    llSensor(name+" Meeroo",NULL_KEY,SCRIPTED,96.0,PI);
}
}


Line 52: Line 93:
         rebuild();
         rebuild();
         target=NULL_KEY;
         target=NULL_KEY;
         llSitTarget(<0.0,0.0,0.80>,ZERO_ROTATION);
         llSitTarget(<-0.5,0.0,0.80>,ZERO_ROTATION);
         llSetClickAction(CLICK_ACTION_SIT);
         llSetClickAction(CLICK_ACTION_SIT);
        llSetCameraAtOffset(<0.0,0.0,0.0>);
        llSetCameraEyeOffset(<1.0,0.0,0.5>);
        avatar=NULL_KEY;
        names=0;
        nameRequest=NULL_KEY;
     }
     }


     listen(integer c,string name,key k,string message)
     listen(integer c,string name,key k,string message)
     {
     {
         llSensor(message+" Meeroo",NULL_KEY,SCRIPTED,96.0,PI);
         sense(message);
     }
     }


     no_sensor()
     no_sensor()
     {
     {
         llOwnerSay("Not found.");
         llRegionSayTo(avatar,0,"Not found.");
     }
     }


Line 69: Line 118:
     {
     {
         target=llDetectedKey(0);
         target=llDetectedKey(0);
         while(llVecDist(llGetPos(),llDetectedPos(0))>9.0)
         moveTo(llDetectedPos(0),llDetectedRot(0)*llEuler2Rot(<0.0,0.0,-90.0>*DEG_TO_RAD));
            llSetLinkPrimitiveParamsFast(LINK_THIS,
            [
                PRIM_POSITION,llDetectedPos(0)
            ]);
         follow(llDetectedKey(0));
         follow(llDetectedKey(0));
     }
     }
Line 79: Line 124:
     changed(integer change)
     changed(integer change)
     {
     {
         if(change==CHANGED_LINK)
         if(change & CHANGED_LINK)
         {
         {
             key avatar=llAvatarOnSitTarget();
             key sitter=llAvatarOnSitTarget();
             if(avatar!=NULL_KEY)
             if(sitter!=NULL_KEY && avatar==NULL_KEY)
             {
             {
                avatar=sitter;
                home=llGetPos();
                homeRot=llGetRot();
                 llListen(6,"",avatar,"");
                 llListen(6,"",avatar,"");
                 llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
                 llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
             }
             }
             else
             else if(sitter==NULL_KEY && avatar!=NULL_KEY)
             {
             {
                avatar=NULL_KEY;
                moveTo(home,homeRot);
                llSleep(1.0);
                 llResetScript();
                 llResetScript();
             }
             }
Line 114: Line 165:
             PRIM_ROTATION,rot*llEuler2Rot(<0.0,0.0,-90.0>*DEG_TO_RAD)
             PRIM_ROTATION,rot*llEuler2Rot(<0.0,0.0,-90.0>*DEG_TO_RAD)
         ]);
         ]);
    }
    touch_start(integer num)
    {
        if(avatar==NULL_KEY)
            return;
        if(llDetectedKey(0)!=avatar)
            return;
        nextName();
    }
    dataserver(key k,string data)
    {
        if(k!=nameRequest)
            return;
        if(data==EOF)
        {
            llRegionSayTo(avatar,0,"End of list reached.");
            names=0;
            return;
        }
        nameRequest=NULL_KEY;
        data=llStringTrim(data,STRING_TRIM);
        if(data!="")
        {
            sense(data);
            llRegionSayTo(avatar,0,"Looking for "+data+" ...");
        }
        else
            nextName();
     }
     }
}
}
</lsl>
</lsl>

Latest revision as of 07:36, 12 September 2011

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

You can also add a notecard to the object with all the names of your Meeroos on it (one name per line). This enables you to just sit on the follower and click it to jump to the next Meeroo in the list. Your camera will be focused on the critter to make petting a lot easier.

<lsl>key target=NULL_KEY; key avatar=NULL_KEY;

vector home; rotation homeRot;

integer names; key nameRequest=NULL_KEY;

follow(key k) {

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

}

moveTo(vector pos,rotation rot) {

   while(llVecDist(llGetPos(),pos)>9.0)
       llSetLinkPrimitiveParamsFast(LINK_THIS,
       [
           PRIM_POSITION,pos
       ]);
   llSetLinkPrimitiveParamsFast(LINK_THIS,
   [
       PRIM_POSITION,pos,
       PRIM_ROTATION,rot
   ]);

}

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
   ]);
   llWhisper(0,"Sit on me and say your Meeroo's name on channel 6. Example for Kiki Meeroo, say: /6Kiki\nBe sure to keep the correct capitalization. Or click on me to move to the next Meeroo on the embedded notecard.");

}

nextName() {

   string name=llGetInventoryName(INVENTORY_NOTECARD,0);
   if(name=="")
   {
       llRegionSayTo(avatar,0,"Please add a notecard with your meeroos' names on it to the object to use the automation.");
       return;
   }
   nameRequest=llGetNotecardLine(name,names);
   names++;    

}

sense(string name) {

   llSensor(name+" Meeroo",NULL_KEY,SCRIPTED,96.0,PI);

}

default {

   on_rez(integer dummy)
   {
       llResetScript();
   }
   state_entry()
   {
       rebuild();
       target=NULL_KEY;
       llSitTarget(<-0.5,0.0,0.80>,ZERO_ROTATION);
       llSetClickAction(CLICK_ACTION_SIT);
       llSetCameraAtOffset(<0.0,0.0,0.0>);
       llSetCameraEyeOffset(<1.0,0.0,0.5>);
       avatar=NULL_KEY;
       names=0;
       nameRequest=NULL_KEY;
   }
   listen(integer c,string name,key k,string message)
   {
       sense(message);
   }
   no_sensor()
   {
       llRegionSayTo(avatar,0,"Not found.");
   }
   sensor(integer num)
   {
       target=llDetectedKey(0);
       moveTo(llDetectedPos(0),llDetectedRot(0)*llEuler2Rot(<0.0,0.0,-90.0>*DEG_TO_RAD));
       follow(llDetectedKey(0));
   }
   changed(integer change)
   {
       if(change & CHANGED_LINK)
       {
           key sitter=llAvatarOnSitTarget();
           if(sitter!=NULL_KEY && avatar==NULL_KEY)
           {
               avatar=sitter;
               home=llGetPos();
               homeRot=llGetRot();
               llListen(6,"",avatar,"");
               llRequestPermissions(avatar,PERMISSION_TRIGGER_ANIMATION);
           }
           else if(sitter==NULL_KEY && avatar!=NULL_KEY)
           {
               avatar=NULL_KEY;
               moveTo(home,homeRot);
               llSleep(1.0);
               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)
       ]);
   }
   touch_start(integer num)
   {
       if(avatar==NULL_KEY)
           return;
       if(llDetectedKey(0)!=avatar)
           return;
       nextName();
   }
   dataserver(key k,string data)
   {
       if(k!=nameRequest)
           return;
       if(data==EOF)
       {
           llRegionSayTo(avatar,0,"End of list reached.");
           names=0;
           return;
       }
       nameRequest=NULL_KEY;
       data=llStringTrim(data,STRING_TRIM);
       if(data!="")
       {
           sense(data);
           llRegionSayTo(avatar,0,"Looking for "+data+" ...");
       }
       else
           nextName();
   }

} </lsl>