| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899 |
- integer debug = 0;
- integer isopen ; // TRUE sf the door is open
- // position it in front and up from the base
- vector relativePosOffset = <-1, 0.0, 0.4>; // "Forward" of this prim
- vector startROT = <0,0,0> ; // initial rotation
- rotation MYROT ;
- string moover;
- integer channel = -44442; // listener from other prim
- integer listener; // channel handle
- string myName; // Name of this prim
- integer startParam = 30; // seconds to poof, then door closes
- Tell()
- {
- string location = (string) llGetPos() + "|" + (string) llGetRot();
- if (! debug)
- llRegionSay(channel,location);
- else
- llSay(channel,location);
- }
- default
- {
- state_entry()
- {
- channel = (integer) llGetObjectDesc();
- if (debug) llOwnerSay("Channel=" + (string) channel);
- listener = llListen(channel,"","","");
- }
-
- on_rez(integer p)
- {
- llResetScript();
- }
-
- link_message(integer sender_num,integer num, string str, key id)
- {
- if (str =="rez")
- {
- moover = llGetInventoryName(INVENTORY_OBJECT,0);
- string myname = llGetObjectName();
-
- rotation myRot = llGetRot();
- rotation relativeRot = myRot * llEuler2Rot (startROT * DEG_TO_RAD) ;
-
- vector myPos = llGetPos();
-
- vector rezPos = myPos+relativePosOffset*myRot;
- vector rezVel = <0,0,0>;
-
- //llOwnerSay("Rezzing " + moover);
- llRezObject(moover,rezPos, rezVel, llGetRot(), channel);
- }
- }
-
- listen(integer channel,string name, key id, string message)
- {
- if (debug) llOwnerSay("Heard " + message);
-
- // ignore what I say to myself
- if (id == llGetKey())
- return;
-
- // announce our location
- if (message == "reset")
- {
- Tell();
- return;
- }
-
- // If the person is coming, open the door
- if (message == "open" && isopen == FALSE)
- {
- isopen = TRUE;
- llMessageLinked(LINK_ALL_OTHERS, 0,"open","");
- llSetTimerEvent(10);
- return;
- }
-
- }
-
- timer()
- {
- llMessageLinked(LINK_ALL_OTHERS, 0,"close","");
- llSetTimerEvent(0);
- isopen = FALSE;
- }
-
- }
|