elven door script.lsl 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. // :CATEGORY:Teleport
  2. // :NAME:Elven Door Teleport System
  3. // :AUTHOR:Ferd Frederix
  4. // :KEYWORDS:
  5. // :CREATED:2014-12-04 12:10:29
  6. // :EDITED:2014-12-04
  7. // :ID:1056
  8. // :NUM:1676
  9. // :REV:1
  10. // :WORLD:Second Life
  11. // :DESCRIPTION:
  12. // Elven Door teleport System
  13. // :CODE:
  14. ////----------------------------------------
  15. //
  16. //
  17. // Q: What do I need to know right away?
  18. //
  19. // Use two or more doors to make a sim-wide teleport network.
  20. //
  21. // Click a door to open or close. Click the spiral to get a menu for teleport.
  22. //
  23. // Installation:
  24. //
  25. // Rename each door as you place it. This name appears in the menu. Use 12 characters or fewer for each name
  26. //
  27. // For more door networks, or to prevent interference, change the number in the Objects Description field to a new channel.
  28. //
  29. // The teleport will sync up automatically to a maximum of 16 doors.
  30. //
  31. integer debug = 0;
  32. integer isopen ; // TRUE sf the door is open
  33. // position it in front and up from the base
  34. vector relativePosOffset = <0, -.80, 0.4>; // "Forward" of this prim
  35. vector startROT = <0,0,90> ; // initial rotation
  36. rotation MYROT ;
  37. string moover;
  38. integer channel = -44442; // listener from other prim
  39. integer listener; // channel handle
  40. string myName; // Name of this prim
  41. integer startParam = 30; // seconds to poof, then door closes
  42. Tell()
  43. {
  44. string location = (string) llGetPos() + "|" + (string) llGetRot();
  45. if (! debug)
  46. llRegionSay(channel,location);
  47. else
  48. llSay(channel,location);
  49. }
  50. default
  51. {
  52. state_entry()
  53. {
  54. channel = (integer) llGetObjectDesc();
  55. if (debug) llOwnerSay("Channel=" + (string) channel);
  56. listener = llListen(channel,"","","");
  57. }
  58. on_rez(integer p)
  59. {
  60. llResetScript();
  61. }
  62. link_message(integer sender_num,integer num, string str, key id)
  63. {
  64. channel = (integer) llGetObjectDesc();
  65. if (debug) llOwnerSay("Channel=" + (string) channel);
  66. listener = llListen(channel,"","","");
  67. if (str =="rez")
  68. {
  69. moover = llGetInventoryName(INVENTORY_OBJECT,0);
  70. string myname = llGetObjectName();
  71. rotation myRot = llGetRot();
  72. rotation relativeRot = myRot * llEuler2Rot (startROT * DEG_TO_RAD) ;
  73. vector myPos = llGetPos();
  74. vector rezPos = myPos+relativePosOffset*myRot;
  75. vector rezVel = <0,0,0>;
  76. //llOwnerSay("Rezzing " + moover);
  77. llRezObject(moover,rezPos, rezVel, relativeRot, channel);
  78. }
  79. }
  80. listen(integer channel,string name, key id, string message)
  81. {
  82. if (debug) llOwnerSay("Heard " + message);
  83. // ignore what I say to myself
  84. if (id == llGetKey())
  85. return;
  86. // announce our location
  87. if (message == "reset")
  88. {
  89. Tell();
  90. return;
  91. }
  92. // If the person is coming, open the door
  93. if (message == "open" && isopen == FALSE)
  94. {
  95. isopen = TRUE;
  96. llMessageLinked(LINK_ALL_OTHERS, 0,"open","");
  97. llSetTimerEvent(10);
  98. return;
  99. }
  100. }
  101. timer()
  102. {
  103. llMessageLinked(LINK_ALL_OTHERS, 0,"close","");
  104. llSetTimerEvent(0);
  105. isopen = FALSE;
  106. }
  107. }