Pilot Sit.lsl 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. // :CATEGORY:Tour
  2. // :NAME:TourCopter
  3. // :AUTHOR:Ferd Frederix
  4. // :CREATED:2013-09-06
  5. // :EDITED:2013-09-18 15:39:08
  6. // :ID:909
  7. // :NUM:1298
  8. // :REV:1
  9. // :WORLD:Second Life
  10. // :DESCRIPTION:
  11. // Tour
  12. // :CODE:
  13. // ______ _ ______ _ _
  14. // | ___| | | | ___| | | (_)
  15. // | |_ ___ _ __ __| | | |_ _ __ ___ __| | ___ _ __ ___ __
  16. // | _/ _ \ '__/ _` | | _| '__/ _ \/ _` |/ _ \ '__| \ \/ /
  17. // | || __/ | | (_| | | | | | | __/ (_| | __/ | | |> <
  18. // \_| \___|_| \__,_| \_| |_| \___|\__,_|\___|_| |_/_/\_\
  19. //
  20. // fred@mitsi.com
  21. // tour copter script
  22. //
  23. //Revisions:
  24. // 1/28/2010 initial release
  25. // Seat
  26. // Pilot Sit
  27. // This script sets the pilot's seat sit target and camera. A link message is sent when the pilot sits or unsits.
  28. // The string of the link message is "pilot". The key of the pilot will be sent if the pilot just sat, or NULL_KEY if the pilot just got up.
  29. // This is the animation to be run when the pilot sits. if it's equal to "", then the default sit animation will be used.
  30. string sit_anim = "recline sit";
  31. // This is the sit target offset.
  32. vector sit_offset = <0.07700, -0.52750, -0.39870>;
  33. // This is the sit rotation.
  34. rotation sit_rotation = <0.70779, -0.00319, -0.00288, 0.70641>;
  35. // This is where the pilot camera is relative to the pilot seat.
  36. vector camera_position = <-10.0, -5.0, .01>;
  37. // This is where the pilot camera is looking.
  38. vector camera_target = <4.5, 0.01, 0.01>;
  39. key pilot;
  40. default
  41. {
  42. state_entry()
  43. {
  44. llSitTarget(sit_offset, sit_rotation);
  45. llSetCameraEyeOffset(camera_position);
  46. llSetCameraAtOffset(camera_target);
  47. pilot = NULL_KEY;
  48. llMessageLinked(LINK_SET, 0, "pilot", NULL_KEY);
  49. }
  50. changed(integer change)
  51. {
  52. key sitting = llAvatarOnSitTarget();
  53. if (change == CHANGED_LINK)
  54. {
  55. if (sitting != NULL_KEY && pilot == NULL_KEY)
  56. {
  57. pilot = sitting;
  58. llMessageLinked(LINK_SET, 0, "half", NULL_KEY); // half blades
  59. // llMessageLinked(1, 0, "llWhisper", "/me Pilot " + llKey2Name(sitting)); // odd way to do a whisper
  60. llMessageLinked(LINK_SET, 0, "pilot", pilot); // say pilot ID on id
  61. if (sit_anim != "")
  62. llRequestPermissions(pilot, PERMISSION_TRIGGER_ANIMATION);
  63. }
  64. else if (sitting == NULL_KEY && pilot != NULL_KEY)
  65. {
  66. if ((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) == PERMISSION_TRIGGER_ANIMATION && llGetPermissionsKey() == pilot)
  67. llStopAnimation("recline sit");
  68. pilot = NULL_KEY;
  69. llMessageLinked(LINK_SET, 0, "pilot", NULL_KEY);
  70. }
  71. }
  72. }
  73. run_time_permissions(integer permissions)
  74. {
  75. if ((permissions & PERMISSION_TRIGGER_ANIMATION) == PERMISSION_TRIGGER_ANIMATION)
  76. llStartAnimation(sit_anim);
  77. }
  78. link_message(integer sender_num, integer num, string message, key id)
  79. {
  80. if (message == "unsit" )
  81. {
  82. if ( ((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) == PERMISSION_TRIGGER_ANIMATION) && llGetPermissionsKey() == pilot)
  83. {
  84. llStopAnimation("recline sit");
  85. llMessageLinked(LINK_SET, 0, "pilot", NULL_KEY);
  86. llUnSit(pilot);
  87. }
  88. }
  89. }
  90. }