Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!

npv.xgrids

By: Mick_Scarbridge on Jul 17th, 2013  |  syntax: Linden Scripting  |  size: 6.55 KB  |  views: 336  |  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. ///////////////////////////////////////// Code start:
  2. //   Yes, a WORKING Cross-Grid (X-Grids) Non Physical Vehicle Script.
  3. //
  4. //   I have personally tested this script to work in
  5. //   Second Life, InWorldz, & OpenSim. It works great
  6. //   in all grids that I have tested so far, and can
  7. //   be used as a flying/levitating vehicle of sorts.
  8. //
  9. //   Pro Tips: Non physical vehicles are not as CPU intensive
  10. //             as physical vehicles for the sim, and they can
  11. //             help protect you from being pushed across the
  12. //             sim from giant bullets, sim cleaners, and chaos.
  13. //             Setting the object to phantom further reduces
  14. //             CPU load on the sim because the physics engine
  15. //             is no longer used for collision detection with
  16. //             the phantom object. Micro optimizations include
  17. //             renaming all child links in a linkset to ".",
  18. //             keeping all object, script, and animation names
  19. //             under 16 characters, and setting all object
  20. //             textures to the factory "Blank" texture for
  21. //             very small sim and viewer load reductions.
  22. //
  23. //   Copyright 2013 Michael R. Horton
  24. //
  25. //   Real Life ............. Michael R. Horton
  26. //   Second Life ........... Mick Scarbridge
  27. //   InWorldZ .............. Mick Daftwood
  28. //
  29. //   This program is free software; you can redistribute it and/or modify
  30. //   it under the terms of the GNU General Public License as published by
  31. //   the Free Software Foundation; Version 32 of the License.
  32. //
  33. //   This program is distributed in the hope that it will be useful,
  34. //   but WITHOUT ANY WARRANTY; without even the implied warranty of
  35. //   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  36. //   GNU General Public License for more details.
  37. //
  38. //   You should have received a copy of the GNU General Public License
  39. //   along with this program; if not, write to the Free Software
  40. //   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  41. //   MA 02110-1301, USA.
  42. //
  43. //   This header must remain in tact for your application of this script.
  44. //   Any modifications that you do should be recorded below with each new
  45. //   version, including your name or avatar name, etc for proper credit to
  46. //   your modifications.
  47. //
  48. //   Upgrades
  49. //
  50. //   v0.4.6 Features:
  51. //
  52. //    * llSetRegionPos() used for higher efficiency than llSetPos().
  53. //    * Tested to work across all grids as of 2013.05.15
  54. //
  55. //   v0.4.8 Features:
  56. //
  57. //    * Tested to self-delete when user stands for AutoCleanup.
  58. //    * Tested to self-delete when user accidentally sits on another object.
  59. //    * Tested to self-delete when user crashes or teleports.
  60. //
  61. //   v0.5.0 Features:
  62. //
  63. //    * Final code cleanup.
  64. //    * Inserted GPL licensing information.
  65. //    * Adjusted formatting for better readability.
  66. //    * Final testing for directional speeds.
  67. //
  68. //   Instructions:
  69. //
  70. //    * Build a one prim object, such as a box or sphere.
  71. //    * Set the rotation to <0,0,0> and set texture to "Blank".
  72. //    * Drop in an animation you like, then rename the animation to "dz" inside the object.
  73. //    * Create a new script in the object then paste this into it.
  74. //    * Set the default action to "Sit" for the object.
  75. //    * Set to compile in MONO instead of LSO/LSL for greater efficiency.
  76. //    * Rename the object you created to something you will remember, such as "npv.xgrids".
  77. //    * Take the object into inventory before sitting or it will self-delete when you stand.
  78. //    * Rez the object in-world and left click to sit.
  79. //    * Enjoy!
  80.  
  81. integer r=FALSE;
  82. key s;
  83. key t;
  84. key p=NULL_KEY;
  85. string a="";
  86. integer b=FALSE;
  87. c(key d,string n)
  88. {
  89.     p=d;
  90.     a=n;
  91.     llRequestPermissions(d,PERMISSION_TAKE_CONTROLS);
  92. }
  93.  
  94. q(){
  95.     if(b)
  96.     {
  97.         p=NULL_KEY;
  98.         b=FALSE;
  99.         llReleaseControls();
  100.     }
  101. }
  102.  
  103. f(vector g)
  104. {
  105.     llSetRot(llEuler2Rot(llRot2Euler(llGetRot())+g*DEG_TO_RAD));
  106. }
  107.  
  108. default
  109. {
  110.     on_rez(integer h)
  111.     {
  112.         llResetScript();
  113.         llSetSitText("^,..,^");// Better than boring "Sit Here".
  114.         llSetStatus(STATUS_PHANTOM,TRUE);// Reduces CPU load on the sim server.
  115.         llVolumeDetect(FALSE);// Set to TRUE if you desire collision detection.
  116.         t=llGetOwner();
  117.     }
  118.  
  119.     state_entry()
  120.     {
  121.         llSitTarget(<0.0,0.0,1.0>,<0.0,0.0,0.0,1.0>);// Haxx - seems to allow sit even if rezzed inside a megaprim sensor type.
  122. //        llSitTarget(ZERO_VECTOR,ZERO_ROTATION);// Alternative that may work better than the previous line in YOUR sim grid.
  123.         llSetCameraEyeOffset(<-5.0,0.0,2.0>);// I nuu wanna be staring at every hair follicle in the back o my head.
  124.         llSetCameraAtOffset(<0.0,0.0,2.0>);
  125. //        llCollisionSound("",0.0);// If non phantom, why sound like beating them when bumping them?
  126.     }
  127.  
  128.     touch(integer j)
  129.     {
  130.         if(llDetectedKey(0))
  131.         {
  132.             c(llDetectedKey(0),llDetectedName(0));
  133.         }
  134.     }
  135.  
  136.     changed(integer u)
  137.     {
  138.         s=llAvatarOnSitTarget();
  139.         if(u&CHANGED_LINK)
  140.         {
  141.             if((s==p)&&(r))
  142.             {
  143.                 llStopAnimation("sit_ground");
  144.                 llReleaseControls();
  145.                 r=FALSE;
  146.                 llSleep(0.1);
  147.                 llDie();
  148.             }
  149.  
  150.         else if(!r)
  151.         {
  152.             t=llAvatarOnSitTarget();
  153.             r=TRUE;
  154.             llRequestPermissions(t,PERMISSION_TAKE_CONTROLS|PERMISSION_TRIGGER_ANIMATION);
  155.             llSetAlpha(0.0,ALL_SIDES);
  156.         }
  157.     }
  158. }
  159.  
  160.     control(key n,integer l,integer e)
  161.     {
  162.         if(l&CONTROL_FWD){llSetRegionPos(llGetPos()+(<4.0,0,0>)*llGetRot());}
  163.         if(l&CONTROL_BACK){llSetRegionPos(llGetPos()+(<-4.0,0,0>)*llGetRot());}
  164.         if(l&CONTROL_LEFT||l&CONTROL_ROT_LEFT){f(<0,0,25.0>);}
  165.         if(l&CONTROL_RIGHT||l&CONTROL_ROT_RIGHT){f(<0,0,-25.0>);}
  166.         if(l&CONTROL_UP){llSetRegionPos(llGetPos()+(<0,0,4.0>)*llGetRot());}
  167.         if(l&CONTROL_DOWN){llSetRegionPos(llGetPos()+(<0,0,-4.0>)*llGetRot());}
  168.     }
  169.  
  170.     run_time_permissions(integer k)
  171.     {
  172.         if(k&PERMISSION_TAKE_CONTROLS)
  173.         {
  174.             llTakeControls(CONTROL_FWD|CONTROL_BACK|CONTROL_LEFT|
  175.             CONTROL_RIGHT|CONTROL_ROT_LEFT|CONTROL_ROT_RIGHT|
  176.             CONTROL_UP|CONTROL_DOWN,TRUE,FALSE);
  177.             b=TRUE;
  178.         }
  179.  
  180.         if(k & PERMISSION_TRIGGER_ANIMATION)
  181.         {
  182.             llStartAnimation("dz");
  183.             llStopAnimation("sit");
  184.         }
  185.  
  186.         else
  187.         {
  188.             q();
  189.         }
  190.     }
  191. }
  192. ///////////////////////////////////////// Code end.
  193. // EOF