NPV_1.lsl 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. // :CATEGORY:Vehicles
  2. // :NAME:No Physics Vehicle
  3. // :AUTHOR:Anonymous
  4. // :KEYWORDS:
  5. // :CREATED:2010-01-10 05:20:56.000
  6. // :EDITED:2013-09-17 21:48:39
  7. // :ID:576
  8. // :NUM:789
  9. // :REV:1.0
  10. // :WORLD:Second Life
  11. // :DESCRIPTION:
  12. // NPV.lsl
  13. // :CODE:
  14. float speed = 0.5;
  15. vector velocity = <0,0,0>;
  16. default
  17. {
  18. state_entry()
  19. {
  20. llSitTarget(<0,0,-0.5>,<0,0,0,0>);
  21. llSetCameraEyeOffset(<-6.0, 0.0, 2.00>);
  22. llSetCameraAtOffset(<0.0, 0.0, 1.0>);
  23. llListen(4,"",llGetOwner(),"");
  24. }
  25. changed(integer c)
  26. {
  27. if(c & CHANGED_LINK && llAvatarOnSitTarget() == llGetOwner())
  28. {
  29. llRequestPermissions(llAvatarOnSitTarget(),PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS | PERMISSION_CONTROL_CAMERA);
  30. }
  31. }
  32. listen(integer c, string n, key id, string msg)
  33. {
  34. speed = (float)msg;
  35. }
  36. run_time_permissions(integer perm)
  37. {
  38. if(perm & PERMISSION_TRIGGER_ANIMATION && llAvatarOnSitTarget() == llGetOwner())
  39. {
  40. llStopAnimation("Sit");
  41. llStartAnimation("!WAway");
  42. }
  43. if(perm & PERMISSION_TAKE_CONTROLS && llAvatarOnSitTarget() == llGetOwner())
  44. {
  45. llTakeControls(CONTROL_FWD | CONTROL_BACK | CONTROL_LEFT | CONTROL_RIGHT | CONTROL_UP | CONTROL_DOWN | CONTROL_ROT_LEFT | CONTROL_ROT_RIGHT,TRUE,FALSE);
  46. }
  47. if(perm & PERMISSION_CONTROL_CAMERA && llAvatarOnSitTarget() == llGetOwner())
  48. {
  49. }
  50. }
  51. touch_start(integer n)
  52. {
  53. llRequestPermissions(llAvatarOnSitTarget(),PERMISSION_TRIGGER_ANIMATION | PERMISSION_TAKE_CONTROLS | PERMISSION_CONTROL_CAMERA);
  54. }
  55. control(key id, integer held, integer change)
  56. {
  57. rotation rot;
  58. if(held & CONTROL_FWD)
  59. velocity.x = velocity.x + speed;
  60. else
  61. velocity.x *= 0.75;
  62. if(held & CONTROL_BACK)
  63. velocity.x = velocity.x - speed;
  64. else
  65. velocity.x *= 0.75;
  66. if(held & CONTROL_LEFT)
  67. velocity.y = velocity.y - speed;
  68. else
  69. velocity.y *= 0.75;
  70. if(held & CONTROL_RIGHT)
  71. velocity.y = velocity.y + speed;
  72. else
  73. velocity.y *= 0.75;
  74. if(held & CONTROL_UP)
  75. llSetPos(llGetPos() + <0,0,speed>);
  76. if(held & CONTROL_DOWN)
  77. llSetPos(llGetPos() + <0,0,-speed>);
  78. if(held & CONTROL_ROT_LEFT)
  79. {
  80. //llSetRot(llEuler2Rot(llRot2Euler(llGetRot())*RAD_TO_DEG - (<0,0,0.001>*DEG_TO_RAD)));
  81. rot = llGetRot() * llEuler2Rot(<0,0,0.12>);
  82. llSetRot(rot);
  83. }
  84. if(held & CONTROL_ROT_RIGHT)
  85. {
  86. //llSetRot(llEuler2Rot(llRot2Euler(llGetRot())*RAD_TO_DEG - (<0,0,0.001>*DEG_TO_RAD)));
  87. rot = llGetRot() * llEuler2Rot(<0,0,-0.12>);
  88. llSetRot(rot);
  89. }
  90. //if(velocity.x > 0.5) velocity.x = 0.5;
  91. //if(velocity.x < -0.5) velocity.x = -0.5;
  92. //if(velocity.y > 0.5) velocity.y = 0.5;
  93. //if(velocity.y < -0.5) velocity.y = -0.5;
  94. llSetPos(velocity * llGetRot() + llGetPos());
  95. }
  96. }
  97. // END //