Talk:Collision message sender

From Second Life Wiki
Jump to navigation Jump to search

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)