SHARE
TWEET

Elevator Script

a guest Aug 16th, 2019 113 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Criss, if this somehow makes it into your hands: "Eat a dick and stop being a plagiarizing autistic cunt" - Foxmerc
  2. integer targetHandle;
  3. list floors = [ <16.00000, 35.00000, 48.50000>,//groundPos
  4.                 <29.00000, 35.00000, 37.50000>,//groundPos
  5.                 <29.00000, 35.00000, 26.50000>];//subTwoPos
  6.  
  7. integer floorIndex = 0;
  8. integer floorListLength;
  9. integer moving;
  10.  
  11. startTarget(vector pos)
  12. {
  13.     llTriggerSound(NULL_KEY,1.0); //Initial Sound
  14.     llTargetRemove(targetHandle);
  15.     targetHandle = llTarget(pos, 0.5);
  16.     llLoopSound(NULL_KEY,1.0); //While Moving Sound
  17.     moving = 1;
  18. }
  19. elevatorEngine(string unParsedList)
  20. {
  21.     if(moving)return;
  22.     list derp = llParseString2List(unParsedList,[":"], []);
  23.     string command = llList2String(derp,0);
  24.     list queuedListing = [];//For queued way points, to be implimented later.
  25.     if(command == "Down")
  26.     {
  27.         if(floorIndex < (floorListLength-1))floorIndex++;
  28.     }
  29.     else if(command == "Up")
  30.     {
  31.         if(floorIndex>0)floorIndex--;
  32.     }
  33.     else if(command == "GoTo")
  34.     {
  35.         integer tempFloor = llList2Integer(derp,1);
  36.         if((tempFloor>=0)||(tempFloor<floorListLength))floorIndex=tempFloor;
  37.     }
  38.     else{return;}
  39.    
  40.     vector currPos = llGetPos();
  41.     vector targetPos = currPos;
  42.     targetPos = llList2Vector(floors, floorIndex);
  43.     vector moveThisMuch = targetPos - currPos;
  44.     float timeToReach =   llVecDist(targetPos,currPos)*0.5;
  45.     if(timeToReach<0.1)return;
  46.     startTarget(targetPos);
  47.     llSetKeyframedMotion(queuedListing+[moveThisMuch,  timeToReach],[KFM_DATA, KFM_TRANSLATION, KFM_MODE, KFM_FORWARD]);
  48. }
  49. default
  50. {
  51.     state_entry()
  52.     {
  53.         floorListLength = llGetListLength(floors);
  54.         llSetStatus(0x400,1);
  55.         llSetSoundQueueing(0);
  56.         elevatorEngine("GoTo:0");
  57.     }
  58.     touch_start(integer total_number)
  59.     {
  60.         elevatorEngine(llGetLinkName(llDetectedLinkNumber(0)));
  61.     }
  62.     listen(integer c, string n, key i, string m)
  63.     {
  64.         if(llGetOwner()==llGetOwnerKey(i))elevatorEngine(m);
  65.     }
  66.     at_target(integer tnum, vector targetpos, vector ourpos)
  67.     {
  68.         llPlaySound(NULL_KEY,1.0);//Stop Sound
  69.         llTargetRemove(targetHandle);
  70.         moving = 0;
  71.     }
  72. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top