elven door script.lsl.txt 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. integer debug = 0;
  2. integer isopen ; // TRUE sf the door is open
  3. // position it in front and up from the base
  4. vector relativePosOffset = <-1, 0.0, 0.4>; // "Forward" of this prim
  5. vector startROT = <0,0,0> ; // initial rotation
  6. rotation MYROT ;
  7. string moover;
  8. integer channel = -44442; // listener from other prim
  9. integer listener; // channel handle
  10. string myName; // Name of this prim
  11. integer startParam = 30; // seconds to poof, then door closes
  12. Tell()
  13. {
  14. string location = (string) llGetPos() + "|" + (string) llGetRot();
  15. if (! debug)
  16. llRegionSay(channel,location);
  17. else
  18. llSay(channel,location);
  19. }
  20. default
  21. {
  22. state_entry()
  23. {
  24. channel = (integer) llGetObjectDesc();
  25. if (debug) llOwnerSay("Channel=" + (string) channel);
  26. listener = llListen(channel,"","","");
  27. }
  28. on_rez(integer p)
  29. {
  30. llResetScript();
  31. }
  32. link_message(integer sender_num,integer num, string str, key id)
  33. {
  34. if (str =="rez")
  35. {
  36. moover = llGetInventoryName(INVENTORY_OBJECT,0);
  37. string myname = llGetObjectName();
  38. rotation myRot = llGetRot();
  39. rotation relativeRot = myRot * llEuler2Rot (startROT * DEG_TO_RAD) ;
  40. vector myPos = llGetPos();
  41. vector rezPos = myPos+relativePosOffset*myRot;
  42. vector rezVel = <0,0,0>;
  43. //llOwnerSay("Rezzing " + moover);
  44. llRezObject(moover,rezPos, rezVel, llGetRot(), channel);
  45. }
  46. }
  47. listen(integer channel,string name, key id, string message)
  48. {
  49. if (debug) llOwnerSay("Heard " + message);
  50. // ignore what I say to myself
  51. if (id == llGetKey())
  52. return;
  53. // announce our location
  54. if (message == "reset")
  55. {
  56. Tell();
  57. return;
  58. }
  59. // If the person is coming, open the door
  60. if (message == "open" && isopen == FALSE)
  61. {
  62. isopen = TRUE;
  63. llMessageLinked(LINK_ALL_OTHERS, 0,"open","");
  64. llSetTimerEvent(10);
  65. return;
  66. }
  67. }
  68. timer()
  69. {
  70. llMessageLinked(LINK_ALL_OTHERS, 0,"close","");
  71. llSetTimerEvent(0);
  72. isopen = FALSE;
  73. }
  74. }