HG water.lsl 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. // :SHOW:1
  2. // :CATEGORY:Gaming
  3. // :NAME:Hypergate water by Ferd Frederix
  4. // :AUTHOR:Ferd Frederix
  5. // :KEYWORDS:Water, Game, Hypergate
  6. // :REV:2.0
  7. // :WORLD:OpenSim
  8. // :DESCRIPTION:
  9. // teleport a game player back a step when they violate a game rule.
  10. // Useful when placed under water, or over their heads to stop flying, and next to obstacles to keep them from going around it.
  11. // To use, put the destination coordinate vector in the Description of the prim. When collided, they get tp'ed away.
  12. // Requires osTeleportAgent to be enabled
  13. // :CODE:
  14. // Rev 2.0 with Linux reset bug patched
  15. string msg = "You fell in!";
  16. vector LandingPoint; // Where you want the Avatar to arrive at comes from the description
  17. vector LookAt = <0.0,0.0,-1.0>; // which way you want them facing.
  18. list LastFewAgents;
  19. string TargetAddress ; // In-Grid Teleport (Region Na
  20. PerformTeleport( key AgentToTP )
  21. {
  22. integer CurrentTime = llGetUnixTime();
  23. integer AgentIndex = llListFindList( LastFewAgents, [ AgentToTP ] ); // Is the agent we're teleporting already in the list?
  24. if (AgentIndex != -1) // If yes, check to make sure it's been > 5 seconds
  25. {
  26. integer PreviousTime = llList2Integer( LastFewAgents, AgentIndex+1 ); // Get the last time they were teleported
  27. if (PreviousTime >= (CurrentTime - 5)) return; // Less than five seconds ago? Exit without teleporting
  28. LastFewAgents = llDeleteSubList( LastFewAgents, AgentIndex, AgentIndex+1); // Delete the agent from the list
  29. }
  30. LastFewAgents += [ AgentToTP, CurrentTime ]; // Add the agent and current time to the list
  31. osTeleportAgent( AgentToTP, TargetAddress, LandingPoint, LookAt ); // Teleport agent to their target
  32. llSleep(1.0);
  33. llResetScript();
  34. }
  35. RESET_VOL_DET()
  36. {
  37. llSetStatus(STATUS_PHANTOM, FALSE); // Rev 2.
  38. llVolumeDetect(FALSE);
  39. llSleep(0.1);
  40. llVolumeDetect(TRUE);
  41. }
  42. default
  43. {
  44. on_rez(integer int)
  45. {
  46. llResetScript();
  47. }
  48. state_entry()
  49. {
  50. LandingPoint = (vector) llGetObjectDesc();
  51. TargetAddress = llGetRegionName();
  52. RESET_VOL_DET();
  53. }
  54. collision_start(integer total_number) // total_number is the number of avatars detected.
  55. {
  56. if (osIsNpc(llDetectedKey(0)))
  57. return;
  58. llSay(0, msg);
  59. TargetAddress = llGetRegionName();
  60. PerformTeleport( llDetectedKey(0));
  61. RESET_VOL_DET();
  62. }
  63. changed(integer change) // something changed, take action
  64. {
  65. if(change & CHANGED_OWNER)
  66. {
  67. llResetScript();
  68. }
  69. else if (change & CHANGED_REGION_START) // that bit is set during a region restart
  70. {
  71. llResetScript();
  72. }
  73. }
  74. }