Difference between revisions of "Talk:Collision message sender"

From Second Life Wiki
Jump to navigation Jump to search
(Created page with "Probably better should be : <lsl> string message = " Merry Christmas "; // put your message here. list users; string user; float TIME=600.0; default { collision_start(int…")
 
m
 
(One intermediate revision by the same user not shown)
Line 14: Line 14:
         do
         do
         {
         {
             user = llDetectedName(0);
             user = llDetectedName(i);
             if ( llDetectedType(i) & AGENT )
             if ( llDetectedType(i) & AGENT )
             {
             {
                 if (llListFindList(users,[user]) == -1)// look at the list, if the name is not there,
                 if (llListFindList(users,[user]) == -1)// look at the list, if the name is not there,
                 {
                 {
                     llOwnerSay( message + user);      // send the message to the detected avatar.
                     llSay(0, message + user);      // send the message to the detected avatar.
                     users += user;                  // add the users name to a list so they only get the message once.
                     users += user;                  // add the users name to a list so they only get the message once.
                     llSetTimerEvent(TIME);          // change the number for the number of seconds before clearing the list.
                     llSetTimerEvent(TIME);          // change the number for the number of seconds before clearing the list.
Line 29: Line 29:
     timer()
     timer()
     {
     {
         llSetTimerEvent(0);                // turn the timer off
         llSetTimerEvent(0.0);                // turn the timer off
         users = [];                        // clear the list
         users = [];                        // clear the list
         llCollisionFilter("", NULL_KEY, TRUE);
         llCollisionFilter("", NULL_KEY, TRUE);

Latest revision as of 13:03, 20 March 2014

Probably better should be :

<lsl>

string message = " Merry Christmas "; // put your message here. list users; string user; float TIME=600.0; default {

   collision_start(integer num_detected)   // check for an avatar colliding with the prim.
   {
       integer i;
       do
       {
           user = llDetectedName(i);
           if ( llDetectedType(i) & AGENT )
           {
               if (llListFindList(users,[user]) == -1)// look at the list, if the name is not there,
               {
                   llSay(0, message + user);       // send the message to the detected avatar.
                   users += user;                  // add the users name to a list so they only get the message once.
                   llSetTimerEvent(TIME);           // change the number for the number of seconds before clearing the list.
               }                
           } 
           llCollisionFilter(user, "", FALSE);
       } while ( ++i < num_detected );
   }
   timer()
   {
       llSetTimerEvent(0.0);                 // turn the timer off
       users = [];                         // clear the list
       llCollisionFilter("", NULL_KEY, TRUE);
   }

} </lsl>

because :

  • when you want avoid collisions , you should use llCollisionFilter
  • a collision can be an agent , but it can be too an object
  • multiple collisions can happen in the same 1/22th second (same event )

Miranda Umino 13:00, 20 March 2014 (PDT)