reporter1

Untitled

Jun 19th, 2016
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.48 KB | None | 0 0
  1. string DoubleDoor = "NO"; // set this to "YES" if it's a double door
  2. integer InOut = 1; // 1 to open one direction, -1 to open other direction
  3. string doorsound = "TARDIS"; // leave blank for no sound, or change sound name
  4.  
  5. // CHANGE THESE IF YOUR HOUSE HAS MULTIPLE DOOR SETS
  6. string Open = "OPEN"; // change to OPEN2... OPEN3 etc
  7. string Close = "CLOSE"; // change to CLOSE2... CLOSE3 etc.
  8.  
  9. // Doors open in THREE steps. Change these three variables to degree of rotation desired divided by 3 (ie: 90 / 3 = 30)
  10. // These are the X Y Z axis. Depending on which axis your door rotates on, switch the 30 apprppriately.
  11. float X = 0;
  12. float Y = 0;
  13. float Z = 30;
  14.  
  15. integer opentime = 30; // Amount of time it stays open
  16.  
  17. //NOTE: If creating a phantom door, set collliding=0 and phantom=1 and DO NOT LINK
  18. integer colliding = 0; // 1=Door opens when bumped (ie Star Trek) 0=Door requires touching (standard door)
  19. integer phantom = 0; // Phantom door option (vanishes). 0=Not phantom 1=phantom.
  20.  
  21. integer lockchan = 5; // 0-ignore locking ... any other number is the speaking channel to lock your door (ie /5 LOCK)
  22.  
  23. string NoEntry = "Sorry, this door is locked."; // Set this to your locked response
  24.  
  25. //=================================
  26. // Non-changable variables. Ignore code from this point onward unless modifying.
  27. //=================================
  28.  
  29. rotation orig; // original position of door
  30. integer locked; // is door locked or unlocked?
  31. integer open; // is door open or closed?
  32. key touched; // who's at the door?
  33. key owner; // owner of the door
  34.  
  35.  
  36. OpenDoor(){
  37. open=1; // set door flag to "open"
  38. // Phantom door routine
  39. if(phantom == 1){
  40. llSetStatus(STATUS_PHANTOM,TRUE);
  41. llSetAlpha(0.3,ALL_SIDES);
  42. llSetTimerEvent(opentime);
  43. return;
  44. }
  45. // Otherwise... it's a standard door
  46. //Now do idiotic pain-in-hiney rotation math.
  47. //Thanks lots Linden Lab. Never use one simple command when 3 complex ones will do
  48. llSetLocalRot(llEuler2Rot(<X, Y, Z> * InOut * DEG_TO_RAD) * llGetLocalRot());
  49. llSetLocalRot(llEuler2Rot(<X, Y, Z> * InOut * DEG_TO_RAD) * llGetLocalRot());
  50. llSetLocalRot(llEuler2Rot(<X, Y, Z> * InOut * DEG_TO_RAD) * llGetLocalRot());
  51. llSetTimerEvent(opentime); // wait for x seconds before closing door automatically
  52. }
  53.  
  54. CloseDoor(){
  55. llSetTimerEvent(0);//turn off automatic close
  56. open = 0; // set open flag to "not open"
  57. if(phantom == 1){
  58. llSetAlpha(1,ALL_SIDES);
  59. llSetStatus(STATUS_PHANTOM,FALSE);
  60. return;
  61. }
  62. llSetLocalRot(llEuler2Rot(<X, Y, Z> * -InOut * DEG_TO_RAD) * llGetLocalRot());
  63. llSetLocalRot(llEuler2Rot(<X, Y, Z> * -InOut * DEG_TO_RAD) * llGetLocalRot());
  64. llSetLocalRot(llEuler2Rot(<X, Y, Z> * -InOut * DEG_TO_RAD) * llGetLocalRot());
  65. llSetLocalRot(orig); // make sure the door is closed to original postion
  66. }
  67.  
  68.  
  69. default{
  70.  
  71. on_rez(integer q){llResetScript();}
  72.  
  73. state_entry(){
  74. orig = llGetLocalRot(); // record the original position of the door for closing consistency
  75. owner = llGetOwner();
  76. if(lockchan > 0){llListen(lockchan,"",owner,"");} // set up listen for lock/unlock command
  77. }
  78.  
  79. changed(integer change){
  80. if(change & CHANGED_OWNER){llResetScript();} // This fixes ownership recognition bugs
  81. }
  82.  
  83.  
  84. listen(integer chan,string name,key id,string str){
  85. if(lockchan == 0){return;} // if not a lockable door, skip this section
  86. str = llToUpper(str);
  87. if(str == "LOCK"){locked=1;llOwnerSay("Door locked.");}
  88. if(str == "UNLOCK"){locked=0;llOwnerSay("Door unlocked.");}
  89. }
  90.  
  91. link_message(integer src,integer num,string msg,key id){
  92. if((msg == Open) && (open == 0)){OpenDoor();}
  93. if((msg == Close) && (open == 1)){CloseDoor();}
  94. }
  95.  
  96.  
  97. touch_start(integer a){
  98. touched=llDetectedKey(0); // who touched the door?
  99. // if door is locked and owner not at the door, don't open
  100. if(locked & (touched != owner)){llSay(0,NoEntry);return;}
  101. // if door is already open, close it
  102. if(DoubleDoor == "YES" && open){llMessageLinked(LINK_ALL_OTHERS,0,Close,"");}
  103. if(open){CloseDoor();return;}
  104. // otherwise... open the door
  105. if((DoubleDoor == "YES")){llMessageLinked(LINK_ALL_OTHERS,0,Open,"");}
  106. OpenDoor();
  107. }
  108.  
  109.  
  110. timer(){
  111. llSetTimerEvent(0);CloseDoor(); // auto-close the door
  112. }}
  113.  
  114. // NOTE: This script is free, open source and is to be kept that way.
  115. // This script may be freely distributed, even in objects for sale, but not resold of iteself.
  116. // If you try to sell the script itself, your most prized bodily parts may fail to work and possibly even fall off entirely. :D
Advertisement
Add Comment
Please, Sign In to add comment