Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 2.64 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. float distanceForThisStake = 2.007047;
  2.  
  3. key MasterKey;
  4. integer listener;
  5. integer channel;
  6.  
  7. MoveThisPrim(vector MoveTo, vector offsetOf )
  8. {
  9.     vector d =  MoveTo + offsetOf;
  10.     if ( d.z > 4096 ) return;
  11.     integer s = (integer)(llVecMag(d-llGetPos())/10)+1; //The number of jumps necessary
  12.     if ( s > 100 )  //Try and avoid stack/heap collisions with far away destinations
  13.         s = 100;    //  1km should be plenty
  14.     integer e = (integer)( llLog( s ) / llLog( 2 ) );   //Solve '2^n=s'
  15.     list rules = [ PRIM_POSITION, d ];  //The start for the rules list
  16.     integer i;
  17.  
  18.     for ( i = 0 ; i < e ; ++i )     //Start expanding the list
  19.         rules += rules;
  20.     integer r = s - (integer)llPow( 2, e );
  21.     if ( r > 0 )                    //Finish it up
  22.         rules += llList2List( rules, 0, r * 2 + 1 );
  23.     llSetPrimitiveParams( rules );
  24. }
  25.  
  26. KillIt()
  27. {
  28.     llSay(0,"Removing Stake");
  29.     llShout(channel,"STAKEDIE");
  30.     llSleep(2);
  31.     llDie();
  32. }
  33.  
  34. default
  35. {
  36.     state_entry()
  37.     {
  38.    
  39.     }
  40.    
  41.     on_rez(integer a)
  42.     {
  43.         // llOwnerSay((string)a);
  44.         if (a != 0)
  45.         {
  46.             listener = llListen(a + 1,"","","");
  47.             channel = a;
  48.             llSay(a,"STAKEDATA");
  49.         }
  50.     }
  51.    
  52.     touch_start(integer a)
  53.     {
  54.         if (llDetectedKey(0) == MasterKey)
  55.         {
  56.             KillIt();
  57.         }
  58.     }
  59.    
  60.     listen(integer channels, string name, key id, string message)
  61.     {
  62.         list command = llParseString2List( message, ["|"], []);
  63.         if (llList2String(command, 0) == "HEREISSTAKEDATA")
  64.         {
  65.             vector tempPos = (vector)llList2String(llGetObjectDetails(llGetOwner(), [ OBJECT_POS ]), 0);
  66.             // llOwnerSay((string)tempPos);
  67.             MoveThisPrim(tempPos, <1,1,0>);
  68.             tempPos.z = llGround(ZERO_VECTOR);
  69.             vector mypos = llGetPos();
  70.             float distance = (mypos.z - tempPos.z);
  71.            
  72.             if (distance > distanceForThisStake)
  73.             {
  74.                 if (distance < 3) MoveThisPrim(tempPos, <1,1,distanceForThisStake>);
  75.             }
  76.             else
  77.             {
  78.                 MoveThisPrim(tempPos, <1,1,distanceForThisStake>);
  79.             }
  80.            
  81.             MasterKey = (key)llList2String(command, 2);
  82.             llListenRemove(listener);
  83.             listener = llListen(channel,"","","");
  84.         }
  85.         else
  86.         {
  87.             if ((string)llGetOwnerKey(id) == (string)MasterKey)
  88.             {
  89.                 if (llToLower(message) == "unstake")
  90.                 {
  91.                     KillIt();
  92.                 }
  93.             }
  94.         }
  95.     }
  96. }