Second Life/Selfreplication: Unterschied zwischen den Versionen

aus Metalab Wiki, dem offenen Zentrum für meta-disziplinäre Magier und technisch-kreative Enthusiasten.
Zur Navigation springenZur Suche springen
K
Zeile 1: Zeile 1:
// The ttl variable is a counter, decreased for each subsequent replication,
+
// The ttl variable is a counter, decreased for each subsequent replication,
// the child that get rezzed with a ttl value of zero will not procreate.
+
// the child that get rezzed with a ttl value of zero will not procreate.
 
integer ttl = 3;
 
 
 
  
rez_child()
+
integer ttl = 3;
{
 
    // Check if we're allowed to create any more offspring
 
    if(ttl > 0)
 
    {
 
        // Offspring ttl should be one closer to zero
 
        integer ttl_child = ttl - 1;
 
        // Rez child one meter above me
 
        llRezObject("1000er", llGetPos()+<0,0,1>, <0,0,0>, <0,0,0,0>, ttl_child);
 
    }
 
}
 
  
  
default
 
{
 
    // If you touch me, we'll have babies!
 
    touch_start(integer total_number)
 
    {
 
        rez_child();
 
    }
 
 
  
    // llRezObject throws event object_rez on the parent with the offspring as parameter 
+
rez_child()
    object_rez(key child)  
+
{
    {  
+
  // Check if we're allowed to create any more offspring
        // Give copy of child to child
+
  if(ttl > 0)
        llGiveInventory(child, llKey2Name(child));  
+
  {
    }  
+
      // Offspring ttl should be one closer to zero
   
+
      integer ttl_child = ttl - 1;
 +
      // Rez child one meter above me
 +
      llRezObject("1000er", llGetPos()+<1.5,0,0>, <0,0,0>, llEuler2Rot(<0,90,0> * DEG_TO_RAD) , ttl_child);
 +
  }
 +
}
  
    // When rezzed, the event on_rez is called on me as the child
 
    on_rez(integer ttl_in)
 
    {
 
        // Save child (this one) ttl;
 
        ttl = ttl_in;
 
    }
 
  
 +
default
 +
{
 +
  // If you touch me, we'll have babies!
 +
  touch_start(integer total_number)
 +
  {
 +
      rez_child();
 +
  }
  
  
    // Because of the script-delay we have to connect the grand-child rezzing  
+
  // llRezObject throws event object_rez on the parent with the offspring as parameter 
    // to the 'changed' event, which happens when someone (the parent) has
+
  object_rez(key child)
    // given me (as the child) something (a copy of myself)
+
  {
    changed(integer change)
+
      // Give copy of child to child
    {
+
      llGiveInventory(child, llKey2Name(child));
        if(change == CHANGED_INVENTORY)
+
  }
        {
+
 
            rez_child();         
+
 
        }
+
  // When rezzed, the event on_rez is called on me as the child
    }
+
  on_rez(integer ttl_in)
}
+
  {
 +
      // Save child (this one) ttl;
 +
      ttl = ttl_in;
 +
  }
 +
 
 +
 
 +
  // Because of the script-delay we have to connect the grand-child rezzing  
 +
  // to the 'changed' event, which happens when someone (the parent) has
 +
  // given me (as the child) something (a copy of myself)
 +
  changed(integer change)
 +
  {
 +
      if(change == CHANGED_INVENTORY)
 +
      {
 +
          rez_child();         
 +
      }
 +
  }
 +
}

Version vom 5. April 2007, 19:17 Uhr

// The ttl variable is a counter, decreased for each subsequent replication, // the child that get rezzed with a ttl value of zero will not procreate.

integer ttl = 3;


rez_child() {

  // Check if we're allowed to create any more offspring
  if(ttl > 0)
  {
      // Offspring ttl should be one closer to zero
      integer ttl_child = ttl - 1;
      // Rez child one meter above me
      llRezObject("1000er", llGetPos()+<1.5,0,0>, <0,0,0>, llEuler2Rot(<0,90,0> * DEG_TO_RAD) , ttl_child);
  }

}


default {

  // If you touch me, we'll have babies!
  touch_start(integer total_number)
  {
      rez_child();
  }


  // llRezObject throws event object_rez on the parent with the offspring as parameter   
  object_rez(key child) 
  { 
      // Give copy of child to child
      llGiveInventory(child, llKey2Name(child)); 
  } 
  
  // When rezzed, the event on_rez is called on me as the child
  on_rez(integer ttl_in)
  {
      // Save child (this one) ttl;
      ttl = ttl_in;
  }


  // Because of the script-delay we have to connect the grand-child rezzing 
  // to the 'changed' event, which happens when someone (the parent) has
  // given me (as the child) something (a copy of myself)
  changed(integer change)
  {
      if(change == CHANGED_INVENTORY)
      {
          rez_child();        
      }
  }

}