- float distanceForThisStake = 2.007047;
- key MasterKey;
- integer listener;
- integer channel;
- MoveThisPrim(vector MoveTo, vector offsetOf )
- {
- vector d = MoveTo + offsetOf;
- if ( d.z > 4096 ) return;
- integer s = (integer)(llVecMag(d-llGetPos())/10)+1; //The number of jumps necessary
- if ( s > 100 ) //Try and avoid stack/heap collisions with far away destinations
- s = 100; // 1km should be plenty
- integer e = (integer)( llLog( s ) / llLog( 2 ) ); //Solve '2^n=s'
- list rules = [ PRIM_POSITION, d ]; //The start for the rules list
- integer i;
- for ( i = 0 ; i < e ; ++i ) //Start expanding the list
- rules += rules;
- integer r = s - (integer)llPow( 2, e );
- if ( r > 0 ) //Finish it up
- rules += llList2List( rules, 0, r * 2 + 1 );
- llSetPrimitiveParams( rules );
- }
- KillIt()
- {
- llSay(0,"Removing Stake");
- llShout(channel,"STAKEDIE");
- llSleep(2);
- llDie();
- }
- default
- {
- state_entry()
- {
- }
- on_rez(integer a)
- {
- // llOwnerSay((string)a);
- if (a != 0)
- {
- listener = llListen(a + 1,"","","");
- channel = a;
- llSay(a,"STAKEDATA");
- }
- }
- touch_start(integer a)
- {
- if (llDetectedKey(0) == MasterKey)
- {
- KillIt();
- }
- }
- listen(integer channels, string name, key id, string message)
- {
- list command = llParseString2List( message, ["|"], []);
- if (llList2String(command, 0) == "HEREISSTAKEDATA")
- {
- vector tempPos = (vector)llList2String(llGetObjectDetails(llGetOwner(), [ OBJECT_POS ]), 0);
- // llOwnerSay((string)tempPos);
- MoveThisPrim(tempPos, <1,1,0>);
- tempPos.z = llGround(ZERO_VECTOR);
- vector mypos = llGetPos();
- float distance = (mypos.z - tempPos.z);
- if (distance > distanceForThisStake)
- {
- if (distance < 3) MoveThisPrim(tempPos, <1,1,distanceForThisStake>);
- }
- else
- {
- MoveThisPrim(tempPos, <1,1,distanceForThisStake>);
- }
- MasterKey = (key)llList2String(command, 2);
- llListenRemove(listener);
- listener = llListen(channel,"","","");
- }
- else
- {
- if ((string)llGetOwnerKey(id) == (string)MasterKey)
- {
- if (llToLower(message) == "unstake")
- {
- KillIt();
- }
- }
- }
- }
- }