Advertisement
salahzar

Script teleferica (kit#2)

Jan 21st, 2014
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. float VEL=0.3;
  2.  
  3. list gLocations=[
  4.     "Pos1",<10, 30.43, 24.96>,
  5.     "Pos2",<153.781, 162.724, 21.3398>,
  6.     "Boneflower",<155,155,127>,
  7.     "IMD",<155,168,138>,
  8.     "Cyber Apoc",<164,52,27>,
  9.     "Pirate Kitty",<36,32,21>,
  10.     "Telehub",<155,108,30>,
  11.     "Shrine",<29,178,27>,
  12.     "Moon",<184,143,147>
  13.         ];
  14. rotation r0;
  15. string gAnimation;
  16. // Text for the "pie menu"
  17. string gSitText="Teleport";
  18. // If you don't enable this teh teleport object will be left at the destination.
  19. integer gReturnToStartPos=TRUE;
  20. // Alpha for hovertext
  21. float gTextAlpha=0.5;
  22. // colour for hovertext
  23. vector gTextColour=<1.0,1.0,1.0>;
  24.  
  25.  
  26. /////////////////////////////////////////////////////////////////
  27. //Runtime variables. You should leave these alone.
  28.  
  29. vector gStartPos=<0,0,0>;
  30. key gAvatarID=NULL_KEY;
  31. integer gChannel=574368374;
  32. vector gTargetPos=<0,0,0>;
  33.  
  34.  
  35. //////////////////////////////////////////////////////////////////
  36. // Function for instant intra-sim movement
  37.  
  38. warpPos( vector d, float vel )
  39. {
  40.     //vector direction=llVecNorm(d - llGetPos());
  41.     rotation r=getRotToPointAxisAt(<1,0,0>,d);
  42.     llRotLookAt(r,1.0,1.0);
  43.     vector norm=llVecNorm(d-llGetPos());
  44.     while(llVecDist(llGetPos(),d)>10)
  45.         llSetPos(llGetPos()+norm*vel);
  46.     llSetPos(d);
  47. }
  48.  
  49. rotation getRotToPointAxisAt(vector axis, vector target) {
  50.     return llGetRot() * llRotBetween(axis * llGetRot(), target - llGetPos());
  51. }
  52.  
  53. //////////////////////////////////////////////////////////////////
  54. // Main codeblock.
  55.  
  56. default
  57. {
  58.     state_entry() {
  59.         llSetSitText(gSitText);
  60.         gStartPos = llGetPos();
  61.         llSitTarget(<0,0,0.1>,ZERO_ROTATION);
  62.         gChannel=(integer)llFrand(1000000000)+1000000000;
  63.         llSetText(" ",<1,1,1>,1);
  64.        // llSetText(llList2String(gLocations,0),gTextColour, gTextAlpha);
  65.         gTargetPos=(llList2Vector(gLocations,1));
  66.         llListen(gChannel,"",NULL_KEY,"");
  67.         r0=ZERO_ROTATION; llSetRot(r0); //llGetRot();
  68.     }
  69.     on_rez(integer start_param){
  70.         llResetScript();
  71.     }
  72.     changed(integer change){
  73.         if(change & CHANGED_LINK)
  74.         {
  75.             gAvatarID = llAvatarOnSitTarget();
  76.             if(gAvatarID != NULL_KEY)
  77.             {
  78.                 llSetAlpha(0.0,ALL_SIDES);
  79.                  llRequestPermissions(llAvatarOnSitTarget(), PERMISSION_TRIGGER_ANIMATION);
  80.             }
  81.             else
  82.             {
  83.                 integer perm=llGetPermissions();
  84.                 if ((perm & PERMISSION_TRIGGER_ANIMATION) && llStringLength(gAnimation)>0)      
  85.                 llStopAnimation(gAnimation);
  86.                 llSetAlpha(1.0, ALL_SIDES);
  87.                 gAnimation="";
  88.             }
  89.         }
  90.     }
  91.     run_time_permissions(integer perm)
  92.     {
  93.         if (perm & PERMISSION_TRIGGER_ANIMATION)
  94.         {
  95.             llStopAnimation("sit");
  96.             gAnimation=llGetInventoryName(INVENTORY_ANIMATION,0);
  97.             llStartAnimation(gAnimation);
  98.             //llSetAlpha(0.0, ALL_SIDES);
  99.             //llSetText("",<0,0,0>,0.0);
  100.              list options=[];
  101.              integer i =0;
  102.              for(i=0;i<llGetListLength(gLocations);i=i+2){
  103.                 options+=[llList2String(gLocations,i)];
  104.              }
  105.              llDialog(gAvatarID,"Choose target location",options,gChannel);
  106.        
  107.         }
  108.     }
  109.  
  110.     listen(integer channel, string name, key id, string message){
  111.         integer index=llListFindList(gLocations,[message]);
  112.         if (index==-1) return;
  113.    
  114.         gTargetPos=llList2Vector(gLocations,index+1);
  115.        
  116.         warpPos(gTargetPos,VEL);
  117.         llSleep(1);
  118.         llUnSit(gAvatarID);
  119.         llSleep(1);
  120.        
  121.  
  122.         warpPos(gStartPos,10);
  123.         llSetRot(r0);
  124.     }
  125.  
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement