052c2183-f8a7-967b-13af-353bfd112421_script.lsl 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. //
  2. // The line above should be left blank to avoid script errors in OpenSim.
  3. //////////
  4. // SLODLE Quiz Chair Poseball (www.sloodle.org)
  5. // For SLOODLE 0.4
  6. //
  7. // Note: designed for the "myCourse Quiz Chair" design, supplied by Solent University
  8. //
  9. // Copyright (c) 2009 SLOODLE Project (various contributors)
  10. //
  11. // Released under the GNU GPL v3.
  12. //////////
  13. // Name of the animation to use
  14. string anim = "sit";
  15. // Stores the key of the avatar who's sitting on us
  16. key sitter = NULL_KEY;
  17. // Start the poseball animation
  18. startPoseballAnimation()
  19. {
  20. if (anim != "sit") {
  21. llStopAnimation("sit"); // Stop the regular sit animation first
  22. llStartAnimation(anim);
  23. }
  24. }
  25. // Stop the poseball animation
  26. stopPoseballAnimation()
  27. {
  28. if (anim != "sit") {
  29. llStopAnimation(anim);
  30. }
  31. }
  32. // Checks if we have animation permissions for the current sitter.
  33. integer gotAnimationPermissions()
  34. {
  35. if (sitter == NULL_KEY) return FALSE;
  36. if ((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) && (llGetPermissionsKey() == sitter)) return TRUE;
  37. return FALSE;
  38. }
  39. default
  40. {
  41. state_entry()
  42. {
  43. // Set our sit target
  44. llSitTarget(<0.25, 0.0, 0.4>, ZERO_ROTATION);
  45. }
  46. on_rez(integer par)
  47. {
  48. llResetScript();
  49. }
  50. changed(integer change)
  51. {
  52. // Has it been a link change?
  53. if (change & CHANGED_LINK) {
  54. // Is there an avatar sitting on us?
  55. key av = llAvatarOnSitTarget();
  56. if (av == NULL_KEY) {
  57. // Stop the animation
  58. if (gotAnimationPermissions()) stopPoseballAnimation();
  59. sitter = NULL_KEY;
  60. } else if (av != sitter) {
  61. // Make sure we have animation permission
  62. sitter = av;
  63. if (gotAnimationPermissions()) startPoseballAnimation();
  64. else llRequestPermissions(sitter, PERMISSION_TRIGGER_ANIMATION);
  65. }
  66. }
  67. }
  68. run_time_permissions(integer perm)
  69. {
  70. // Permissions have been granted - start the animation
  71. if (perm & PERMISSION_TRIGGER_ANIMATION) startPoseballAnimation();
  72. }
  73. }
  74. // Please leave the following line intact to show where the script lives in Git:
  75. // SLOODLE LSL Script Git Location: mod/quiz-1.0/objects/default/assets/sloodle_quiz_chair_poseball.lslp