Difference between revisions of "User:Fred Gandt/Scripts/Continued 2"

From Second Life Wiki
Jump to navigation Jump to search
m (→‎Swingin' Door: Added to notes)
Line 29: Line 29:
'''Just drop the script into a fresh prim.'''
'''Just drop the script into a fresh prim.'''


<lsl>key owner_id;
<lsl>key owner_id; // Use to store the UUID of the owner to save having to keep asking.
 
string owner_name;
string owner_name; // Use to store the name of the owner to save having to keep asking.


// This a UUID of a texture I created to show either the word "ONLINE" or "OFFLINE".
key ON_OFF_line = "124cfcec-6b8d-552c-42b8-6a1179884e74";
key ON_OFF_line = "124cfcec-6b8d-552c-42b8-6a1179884e74";


// This is added to the owner UUID to make an HTTP request for the owners profile image UUID.
string profile_url = "http://world.secondlife.com/resident/";
string profile_url = "http://world.secondlife.com/resident/";


key name_id;
key name_id; // This key is used to recognize the dataserver request if it is for the name of the owner.
 
key online_id;
key online_id; // This key is used to recognize the HTTP request if it is made automatically.
 
key touch_request_id;
key touch_request_id; // This key is used to recognize the HTTP request if it is made by a user.
 
integer lis;
integer lis; // This is used to store the value of a listen and to remove it when not needed.
 
integer channel;
integer channel; // This is used to store the value of the listen channel.
 
key requester;
key requester; // This is used to store the name of a user who asks to page the owner.
 
OnlineStatus(integer ol, integer tr)
OnlineStatus(integer ol, integer tr) // This function carries two integer type pieces of info.
{
{ // integer ol is the the boolean online data. 1 for online and zero for offline.
     list ol_params = [];
  // integer tr is also boolean. It carries whether the function is being called by a user or automatically.
     if(ol)
     list ol_params = []; // This is a local list creation.
     ol_params = [17, 5, ON_OFF_line, <1.4,0.25,0.0>, <0.0,0.375,0.0>, (90*DEG_TO_RAD),
     if(ol) // If the owner is online...
     ol_params = [17, 5, ON_OFF_line, <1.4,0.25,0.0>, <0.0,0.375,0.0>, (90*DEG_TO_RAD), // ..list the object parameters for displaying ONLINE.
                 18, 5, <0.0,1.0,0.0>, 1.0,
                 18, 5, <0.0,1.0,0.0>, 1.0,
                 18, 6, <1.0,1.0,1.0>, 1.0];
                 18, 6, <1.0,1.0,1.0>, 1.0];
     else
     else // If not...
     ol_params = [17, 5, ON_OFF_line, <1.4,0.25,0.0>, <0.0,0.625,0.0>, (90*DEG_TO_RAD),
     ol_params = [17, 5, ON_OFF_line, <1.4,0.25,0.0>, <0.0,0.625,0.0>, (90*DEG_TO_RAD), // ..list the object parameters for displaying OFFLINE.
                 18, 5, <1.0,0.0,0.0>, 1.0,
                 18, 5, <1.0,0.0,0.0>, 1.0,
                 18, 6, <0.5,0.5,0.5>, 1.0];
                 18, 6, <0.5,0.5,0.5>, 1.0];
     llSetPrimitiveParams(ol_params);
     llSetPrimitiveParams(ol_params); // Set the object parameters to show whatever the list is.
     if(tr)
     if(tr) // If this was a touch request...
     {
     {
         llSetTimerEvent(30.0);
         llSetTimerEvent(30.0); // Prepare to be ignored (we need to switch the listen off if we are ignored).
         if(ol)
         if(ol) // If the owner is online...
         {
         {
             lis = llListen(channel, "", requester, "");
             lis = llListen(channel, "", requester, ""); // Open a listen for the user who made the request.
             llDialog(requester, ("\nWould you like to page " + owner_name + "?"), ["YES", "NO"], channel);
             llDialog(requester, ("\nWould you like to page " + owner_name + "?"), ["YES", "NO"], channel); // Send them a dialog.
         }
         }
         else
         else // If not...
         llInstantMessage(requester, (owner_name + " is currently offline."));
         llInstantMessage(requester, (owner_name + " is currently offline.")); // Send a message explaining that the owner is offline.
     }
     }
}
}
 
default
default // Create an area for the events to play in. This is called a "state".
{
{
     state_entry()
     state_entry() // On state entry...
     {
     {
         owner_id = llGetOwner();
         owner_id = llGetOwner(); // Get the owner UUID (key) and store it.
         name_id = llRequestAgentData(owner_id, DATA_NAME);
         name_id = llRequestAgentData(owner_id, DATA_NAME); // Make a request for the owners name.
         channel = -5647;
         channel = -5647; // Set a channel to use for the dialog.
     }
     }
     dataserver(key q, string data)
     dataserver(key q, string data) // Triggered when a reply to a data request is recieved.
     {
     {
         if(q == name_id)
         if(q == name_id) // Check the id of the request.
         {
         {
             owner_name = data;
             owner_name = data; // Store the result.
             llSetObjectName(owner_name + "'s Online Status");
             llSetObjectName(owner_name + "'s Online Status"); // Set the name of the object to the owner name + "'s Online Status".
             llHTTPRequest((profile_url + ((string)owner_id)), [], "");
             llHTTPRequest((profile_url + ((string)owner_id)), [], ""); // Request the UUID of the owners profile.
         }
         }
         else if(q == online_id)
         else if(q == online_id) // Check the id of the request.
         OnlineStatus(((integer)data), FALSE);
         OnlineStatus(((integer)data), FALSE); // Call the OnlineStatus function for an automatic return.
         else if(q == touch_request_id)
         else if(q == touch_request_id) // Check the id of the request.
         OnlineStatus(((integer)data), TRUE);
         OnlineStatus(((integer)data), TRUE); // Call the OnlineStatus function for a touch-by-user return.
     }
     }
     http_response(key q, integer status, list metadata, string body)
     http_response(key q, integer status, list metadata, string body) // Triggered when a response for an HTTP request is recieved.
     {
     {
         integer tex_key_start = (llSubStringIndex(body, "imageid") + 18);
         integer tex_key_start = (llSubStringIndex(body, "imageid") + 18); // Establish the point where the image UUID is written in the page.
         integer tex_key_end = (tex_key_start + 35);
         integer tex_key_end = (tex_key_start + 35); // Establish the point where the image UUID ends.
         key profile_image = ((key)llGetSubString(body, tex_key_start, tex_key_end));
         key profile_image = ((key)llGetSubString(body, tex_key_start, tex_key_end)); // Store the the profile image UUID found.
         llSetPrimitiveParams([9, 0, 0, <0.6,0.875,0.0>, 0.02, ZERO_VECTOR, <1.0,1.0,0.0>, ZERO_VECTOR,
         llSetPrimitiveParams([9, 0, 0, <0.6,0.875,0.0>, 0.02, ZERO_VECTOR, <1.0,1.0,0.0>, ZERO_VECTOR, // Shape the object...
                               8, llEuler2Rot(<0.0,90.0,0.0>*DEG_TO_RAD),
                               8, llEuler2Rot(<0.0,90.0,0.0>*DEG_TO_RAD),
                               7, <0.85,0.01,0.6>,
                               7, <0.85,0.01,0.6>,
                               17, -1, TEXTURE_BLANK, <1.0,1.0,0.0>, ZERO_VECTOR, 0.0,
                               17, -1, TEXTURE_BLANK, <1.0,1.0,0.0>, ZERO_VECTOR, 0.0,
                               18, -1, ZERO_VECTOR, 1.0]);
                               18, -1, ZERO_VECTOR, 1.0]);
         llSetPrimitiveParams([17, 6, profile_image, <1.0,1.0,0.0>, ZERO_VECTOR, (90*DEG_TO_RAD),
         llSetPrimitiveParams([17, 6, profile_image, <1.0,1.0,0.0>, ZERO_VECTOR, (90*DEG_TO_RAD), // ...and texture it with the owners profile image and...
                               17, 5, ON_OFF_line, <1.4,0.25,0.0>, <0.0,0.375,0.0>, (90*DEG_TO_RAD),
                               17, 5, ON_OFF_line, <1.4,0.25,0.0>, <0.0,0.375,0.0>, (90*DEG_TO_RAD), // the ON/OFFline texture.
                               19, 5, 0, 1,
                               19, 5, 0, 1,
                               18, 6, <1.0,1.0,1.0>, 1.0,
                               18, 6, <1.0,1.0,1.0>, 1.0,
Line 112: Line 115:
                               20, 5, 1,
                               20, 5, 1,
                               20, 6, 1]);
                               20, 6, 1]);
         llSetTimerEvent(0.1);
         llSetTimerEvent(0.1); // Move to the timer quickly to run the first OnlineStatus check.
     }
     }
     timer()
     timer() // Triggered if a timer event is set to a non zero amount.
     {
     {
         llListenRemove(lis);
         llSetTimerEvent(10.0); // Reset the timer event to trigger every 10 seconds.
         llSetTimerEvent(10.0);
         llListenRemove(lis); // Always remove any listen we have open.
         online_id = llRequestAgentData(owner_id, DATA_ONLINE);
         online_id = llRequestAgentData(owner_id, DATA_ONLINE); // So every 10 seconds we check if the owner is online.
     }
     }
     touch_start(integer nd)
     touch_start(integer nd) // Triggered on clicking the object that contains the script.
     {
     {
         llSetTimerEvent(0.0);
         llSetTimerEvent(0.0); // Stop the timer.
         requester = llDetectedKey(0);
         requester = llDetectedKey(0); // Store the UUID of the person who touched us.
         touch_request_id = llRequestAgentData(owner_id, DATA_ONLINE);
         touch_request_id = llRequestAgentData(owner_id, DATA_ONLINE); // Request the online status of the owner before issuing any dialogs.
     }
     } // We do this becuse if the owner went offline 9 seconds ago we wouldn't know.
     listen(integer chan, string name, key id, string msg)
     listen(integer chan, string name, key id, string msg) // Triggered when all the specified info is recieved by the script if it has a listen open.
     {
     {
         llListenRemove(lis);
         llListenRemove(lis); // Remove the listen.
         llSetTimerEvent(10.0);
         llSetTimerEvent(10.0); // Set the timer to run automatically.
         if(msg == "YES")
         if(msg == "YES") // If the toucher wants to page the owner (the owner must be online)...
         {
         { // Instant message the owner with a link that when clicked will bring up the touchers profile. This saves searching for the touchers profile.
             llInstantMessage(owner_id, ("secondlife:///app/agent/" + ((string)requester) + "/about has requested to message you."));
             llInstantMessage(owner_id, ("secondlife:///app/agent/" + ((string)requester) + "/about has requested to message you."));
             llInstantMessage(requester, owner_name + " has been paged.");
             llInstantMessage(requester, owner_name + " has been paged."); // Inform the toucher that the owner has been paged.
         }
         }
     }
     }

Revision as of 10:42, 26 February 2010

FG jpg.jpg

My Contributions

Other Pages

Free Scripts

More Free Scripts

Legal Stuff

The legal stuff about contributing to this wiki (worth reading).

Tuition

Tuition scripts, notes, videos and screenshots etc. (hardly any content yet)

Free Scripts

Online Status Display & Pager

This will display the owners profile picture and a color coded and text texture sign that changes depending on the owners online status.

Just drop the script into a fresh prim.

<lsl>key owner_id; // Use to store the UUID of the owner to save having to keep asking.

string owner_name; // Use to store the name of the owner to save having to keep asking.

// This a UUID of a texture I created to show either the word "ONLINE" or "OFFLINE". key ON_OFF_line = "124cfcec-6b8d-552c-42b8-6a1179884e74";

// This is added to the owner UUID to make an HTTP request for the owners profile image UUID. string profile_url = "http://world.secondlife.com/resident/";

key name_id; // This key is used to recognize the dataserver request if it is for the name of the owner.

key online_id; // This key is used to recognize the HTTP request if it is made automatically.

key touch_request_id; // This key is used to recognize the HTTP request if it is made by a user.

integer lis; // This is used to store the value of a listen and to remove it when not needed.

integer channel; // This is used to store the value of the listen channel.

key requester; // This is used to store the name of a user who asks to page the owner.

OnlineStatus(integer ol, integer tr) // This function carries two integer type pieces of info. { // integer ol is the the boolean online data. 1 for online and zero for offline.

 // integer tr is also boolean. It carries whether the function is being called by a user or automatically.
   list ol_params = []; // This is a local list creation.
   if(ol) // If the owner is online...
   ol_params = [17, 5, ON_OFF_line, <1.4,0.25,0.0>, <0.0,0.375,0.0>, (90*DEG_TO_RAD), // ..list the object parameters for displaying ONLINE.
                18, 5, <0.0,1.0,0.0>, 1.0,
                18, 6, <1.0,1.0,1.0>, 1.0];
   else // If not...
   ol_params = [17, 5, ON_OFF_line, <1.4,0.25,0.0>, <0.0,0.625,0.0>, (90*DEG_TO_RAD), // ..list the object parameters for displaying OFFLINE.
                18, 5, <1.0,0.0,0.0>, 1.0,
                18, 6, <0.5,0.5,0.5>, 1.0];
   llSetPrimitiveParams(ol_params); // Set the object parameters to show whatever the list is.
   if(tr) // If this was a touch request...
   {
       llSetTimerEvent(30.0); // Prepare to be ignored (we need to switch the listen off if we are ignored).
       if(ol) // If the owner is online...
       {
           lis = llListen(channel, "", requester, ""); // Open a listen for the user who made the request.
           llDialog(requester, ("\nWould you like to page " + owner_name + "?"), ["YES", "NO"], channel); // Send them a dialog.
       }
       else // If not...
       llInstantMessage(requester, (owner_name + " is currently offline.")); // Send a message explaining that the owner is offline.
   }

}

default // Create an area for the events to play in. This is called a "state". {

   state_entry() // On state entry...
   {
       owner_id = llGetOwner(); // Get the owner UUID (key) and store it.
       name_id = llRequestAgentData(owner_id, DATA_NAME); // Make a request for the owners name.
       channel = -5647; // Set a channel to use for the dialog.
   }
   dataserver(key q, string data) // Triggered when a reply to a data request is recieved.
   {
       if(q == name_id) // Check the id of the request.
       {
           owner_name = data; // Store the result.
           llSetObjectName(owner_name + "'s Online Status"); // Set the name of the object to the owner name + "'s Online Status".
           llHTTPRequest((profile_url + ((string)owner_id)), [], ""); // Request the UUID of the owners profile.
       }
       else if(q == online_id) // Check the id of the request.
       OnlineStatus(((integer)data), FALSE); // Call the OnlineStatus function for an automatic return.
       else if(q == touch_request_id) // Check the id of the request.
       OnlineStatus(((integer)data), TRUE); // Call the OnlineStatus function for a touch-by-user return.
   }
   http_response(key q, integer status, list metadata, string body) // Triggered when a response for an HTTP request is recieved.
   {
       integer tex_key_start = (llSubStringIndex(body, "imageid") + 18); // Establish the point where the image UUID is written in the page.
       integer tex_key_end = (tex_key_start + 35); // Establish the point where the image UUID ends.
       key profile_image = ((key)llGetSubString(body, tex_key_start, tex_key_end)); // Store the the profile image UUID found.
       llSetPrimitiveParams([9, 0, 0, <0.6,0.875,0.0>, 0.02, ZERO_VECTOR, <1.0,1.0,0.0>, ZERO_VECTOR, // Shape the object...
                             8, llEuler2Rot(<0.0,90.0,0.0>*DEG_TO_RAD),
                             7, <0.85,0.01,0.6>,
                             17, -1, TEXTURE_BLANK, <1.0,1.0,0.0>, ZERO_VECTOR, 0.0,
                             18, -1, ZERO_VECTOR, 1.0]);
       llSetPrimitiveParams([17, 6, profile_image, <1.0,1.0,0.0>, ZERO_VECTOR, (90*DEG_TO_RAD), // ...and texture it with the owners profile image and...
                             17, 5, ON_OFF_line, <1.4,0.25,0.0>, <0.0,0.375,0.0>, (90*DEG_TO_RAD), // the ON/OFFline texture.
                             19, 5, 0, 1,
                             18, 6, <1.0,1.0,1.0>, 1.0,
                             18, 5, <0.0,1.0,0.0>, 1.0,
                             20, 5, 1,
                             20, 6, 1]);
       llSetTimerEvent(0.1); // Move to the timer quickly to run the first OnlineStatus check.
   }
   timer() // Triggered if a timer event is set to a non zero amount.
   {
       llSetTimerEvent(10.0); // Reset the timer event to trigger every 10 seconds.
       llListenRemove(lis); // Always remove any listen we have open.
       online_id = llRequestAgentData(owner_id, DATA_ONLINE); // So every 10 seconds we check if the owner is online.
   }
   touch_start(integer nd) // Triggered on clicking the object that contains the script.
   {
       llSetTimerEvent(0.0); // Stop the timer.
       requester = llDetectedKey(0); // Store the UUID of the person who touched us.
       touch_request_id = llRequestAgentData(owner_id, DATA_ONLINE); // Request the online status of the owner before issuing any dialogs.
   } // We do this becuse if the owner went offline 9 seconds ago we wouldn't know.
   listen(integer chan, string name, key id, string msg) // Triggered when all the specified info is recieved by the script if it has a listen open.
   {
       llListenRemove(lis); // Remove the listen.
       llSetTimerEvent(10.0); // Set the timer to run automatically.
       if(msg == "YES") // If the toucher wants to page the owner (the owner must be online)...
       { // Instant message the owner with a link that when clicked will bring up the touchers profile. This saves searching for the touchers profile.
           llInstantMessage(owner_id, ("secondlife:///app/agent/" + ((string)requester) + "/about has requested to message you."));
           llInstantMessage(requester, owner_name + " has been paged."); // Inform the toucher that the owner has been paged.
       }
   }

}</lsl>

Swingin' Door

  • NOW VERY UNLIKELY TO GET FREAKED OUT BY ODD ROTATIONS.
  • I will add full notes and guidance when I have finished the script. I am working on a few extra features though.
  • Although this is far more featured than you might imagine the one thing you need to know to get full use is to include a notecard in the doors something like the example below. If doors are linked together in any of the many possible ways only one of the doors needs to have the Whitelist/Blacklist NC.
  • Consecutively linked doors (at this time 3 doors won't function well as a local set) regard each other as Local (perfect for making double doors; either both acting as one folding door or each acting as one 1/2 of a double set of doors). All doors linked to the same set regard each other as Global
  • Features can be changed in Self (the door that gives you the menu), Local (double doors) or Global (all doors in a link set).
  • The following notecard example contains two important words - "Whitelist" & "Blacklist". The whitelist is those who you allow to use the door when against the general public it is locked. If the door is deadlocked only the owner can operate it. The blacklist is those who may NEVER use the door. You do not need to add yourself to the whitelist (owner oddly enough may always use the door). Names are cAsE & speelign sensitive.
  • There is a group option to allow members of the group the door is set to (not deeded) to use it when it is otherwise locked (not deadlocked). If group is set on the door both those on the whitelist and those wearing the correct group tag may use the door. Anyone on the blacklist will still be banned even if they are wearing the right group tag.
  • After changing the rotation of the doors (by editing) reset the script. I will hopefully work out a way to run the alignment checks fast enough to have it done automatically but, until that possibility comes to pass...reset the script after editing the door rotation.

<lsl>Whitelist Fred Flintstone Elmer Fudd Rank Xerox Blacklist The Joker Miss Crabapple M Linden</lsl><lsl>// THERE IS NO NEED FOR THE AVERAGE USER TO CHANGE ANYTHING IN THE SCRIPT. // THE SCRIPT WILL TAKE CARE OF ALMOST EVERYTHING. USE THE MENU TO CHANGE SETTINGS.


// I designed it to be dragged and dropped into a fresh prim. This will create the basic door. // Re-texture and color as you like. Re-shaping may cause problems... // ...(rotations are around the true center of the prim (this is a path-cut door) on it's local Z axis).


// DIALOG MENU FOR ALL USER SETTINGS OPTIONS // Touch and hold the mouse button until a blue drop-down dialog shows for config options.


// The next few lines could be altered by you without harming the script (within reason).

list angle_list = ["210", "240", "270", "120", "150", "180", "30", "60", "90"]; // More options coming. Max number 9 options.

list time_list = ["16", "18", "20", "10", "12", "14", "4", "6", "8"]; // Auto closure times. Max number 9 options.

key LL_Brazillian_Rosewood = "a25bebc8-4739-453d-d44e-fc522cf95488"; // Start texture. Sets as door is created.

key Door_Opening = "99236139-075b-3057-7c6f-0f68bb2af001"; // Door sounds (if replacing consider the length).

key Door_Closing = "43e46041-25fa-0a03-7be8-78297f579d53";

key Doorbell = "213aae54-6093-7fcc-118f-3039a5435986"; // Door bell sound.

// FROM HERE ON DO NOT CHANGE ANYTHING UNLESS YOU KNOW WHAT YOU ARE DOING.


integer notecard_length;

integer sound_on = TRUE;

string dia_msg = "\n";

list dia_buttons = [];

list whitelist = [];

list blacklist = [];

float angle = 90.0;

integer count_NCL;

string owner_name;

float time = 6.0;

integer dia_chan;

integer dia_lis;

integer t_count;

integer aligned;

integer global;

integer locked;

integer group;

integer local;

integer IGAN;

integer dead;

integer open;

integer nop;

key bell_id;

integer mln;

string NCN;

key owner;

key NoNL;

key NCK;

key OLC;

key NL;


OperateDoor(integer o, integer lm) {

   if(nop >= 2 && (!lm))
   llMessageLinked(LINK_ALL_OTHERS, dia_chan, owner_name, owner);
   if(sound_on)
   {
       key door_sound;
       if(o)
       door_sound = Door_Closing;
       else
       door_sound = Door_Opening;
       llPlaySound(door_sound, 1.0);
   }
   float d;
   float a = angle;
   vector v = (llRot2Euler(llGetLocalRot())*RAD_TO_DEG);
   float x = v.x;
   float y = v.y;
   float z = v.z;
   if(llFabs(x) < 1.0)
   d = 1.0;
   else
   d = -1.0;
   if(o)
   {
       if(llFabs(x) < 1.0)
       d = -1.0;
       else
       d = 1.0;
       a = -angle;
       llSetTimerEvent(0.0);
   }
   else
   llSetTimerEvent(time);
   if(aligned)
   {
       llTargetOmega(<0.0,0.0,d>, (angle/90.0), 1.0);
       llSleep(1.5);
       llTargetOmega(ZERO_VECTOR, 0.0, 0.0);
   }
   llSetLocalRot(llEuler2Rot(<x,y,(z + a)>*DEG_TO_RAD));
   open = (!open);

}

TouchMeAllOver(key id, integer t, integer te) {

   if(t && id == owner)
   {
       global = FALSE;
       local = FALSE;
       dia_msg = "\n\"Global\" - Instruct all doors linked to this.
       \n\"Local\" - Instruct only locally linked doors.
       \n\"Self\" - Instruct only this door.";
       dia_buttons = ["Self", "Local", "CANCEL", "Global"];
       dia_lis = llListen(dia_chan, owner_name, owner, "");
       llDialog(owner, dia_msg, dia_buttons, dia_chan);
   }
   if(te)
   {
       if(t_count < 10)
       {
           if(!dead)
           {
               if(!Whitelist(id))
               {
                   bell_id = id;
                   OLC = llRequestAgentData(owner, DATA_ONLINE);
                   return;
               } 
           }
           else
           {
               if(id != owner)
               return;
           }
           OperateDoor(open, FALSE);
       }
       t_count = 0;
   }

}

integer Whitelist(key id) {

   integer w = TRUE;
   integer index;
   if(id == NULL_KEY)
   {
       whitelist = [];
       blacklist = [];
       count_NCL = 0;
       NCN = llGetInventoryName(INVENTORY_NOTECARD, 0);
       if(llStringLength(NCN))
       {
           IGAN = TRUE;
           NCK = llGetInventoryKey(NCN);
           llMessageLinked(LINK_ALL_OTHERS, dia_chan, "IGAN", NCK);
           NoNL = llGetNumberOfNotecardLines(NCN);
       }
       else
       {
           IGAN = FALSE;
           if(nop > 1)
           llMessageLinked(LINK_ALL_OTHERS, dia_chan, "IGAN", owner);
       }
   }
   else
   {
       if(id != owner)
       {
           if(locked)
           {
               index = llListFindList(whitelist, [llKey2Name(id)]);
               if(index == -1)
               w = FALSE;
               if(group)
               {
                   if(!w)
                   {
                       if(llSameGroup(id))
                       w = TRUE;
                   }
               }
           }
           index = llListFindList(blacklist, [llKey2Name(id)]);
           if(index != -1)
           w = FALSE;
       }
   }
   return w;

}

GetCracking() {

   owner = llGetOwner();
   dia_chan = (-1*llAbs(((integer)("0x" + llGetSubString(((string)owner), -9, -3)))));
   owner_name = llKey2Name(owner);
   nop = llGetNumberOfPrims();
   mln = llGetLinkNumber();
   GetAligned(nop, mln);

}

GetAligned(integer p, integer l) {

   vector myrot = (llRot2Euler(llGetRot())*RAD_TO_DEG);
   vector rootrot = (llRot2Euler(llGetRootRotation())*RAD_TO_DEG);
   integer mrx = llRound(llFabs(myrot.x));
   integer mry = llRound(llFabs(myrot.y));
   integer rrx = llRound(llFabs(rootrot.x));
   integer rry = llRound(llFabs(rootrot.y));
   if(p > 1 && l != 1)
   {
       if((mrx == rrx && mry == rry))
       aligned = TRUE;
       else if((mrx == (rrx + 180) && mry == rry))
       aligned = TRUE;
       else if((mrx == (rrx - 180) && mry == rry))
       aligned = TRUE;
       else if((mrx == rrx && mry == (rry + 180)))
       aligned = TRUE;
       else if((mrx == rrx && mry == (rry - 180)))
       aligned = TRUE;
       else if((mrx == (rrx + 180) && mry == (rry + 180)))
       aligned = TRUE;
       else if((mrx == (rrx + 180) && mry == (rry - 180)))
       aligned = TRUE;
       else if((mrx == (rrx - 180) && mry == (rry - 180)))
       aligned = TRUE;
       else if((mrx == (rrx - 180) && mry == (rry + 180)))
       aligned = TRUE;
       else
       aligned = FALSE;
   }
   else
   {
       if((!mrx) && (!mry))
       aligned = TRUE;
       else if((mrx == 180) && (mry == 180))
       aligned = TRUE;
       else if((!mrx) && (mry == 180))
       aligned = TRUE;
       else if((mrx == 180) && (!mry))
       aligned = TRUE;
       else
       {
           aligned = FALSE;
           llSleep(0.2);
           llMessageLinked(LINK_ALL_OTHERS, dia_chan, "MA", owner);
       }
   }

}

StringControl(string s, integer g, integer l, integer lm) {

   if(s == "SoundOff")
   sound_on = FALSE;
   else if(s == "SoundOn")
   sound_on = TRUE;
   else if(s == "UnLock")
   locked = FALSE;
   else if(s == "Lock")
   locked = TRUE;
   else if(s == "GroupOff")
   group = FALSE;
   else if(s == "GroupOn")
   group = TRUE;
   else if(s == "UnDead")
   dead = FALSE;
   else if(s == "DeadLock")
   dead = TRUE;
   else if(s == "NoAuto")
   time = 0.0;
   else if(s != "-")
   {
       float m = ((float)s);
       if(m > 20.0)
       angle = m;
       else
       time = m;
   }
   if(!lm)
   {
       string w;
       if(g)
       w = "globules" + s;
       else if(l)
       w = "homies" + s;
       llMessageLinked(LINK_ALL_OTHERS, dia_chan, w, owner);
   }

}

default {

   on_rez(integer param)
   {
       GetCracking();
       Whitelist(NULL_KEY);
   }
   state_entry()
   {
       GetCracking();
       vector pos = llGetPos();
       llSetPrimitiveParams([9, 0, 0, <0.125, 0.375, 0.0>, 0.0, ZERO_VECTOR, <1.0, 1.0, 0.0>, ZERO_VECTOR,
                             17, 0, LL_Brazillian_Rosewood, <2.0, 0.1, 0.0>, <0.5, 0.025, 0.0>, 0.0,
                             17, 1, LL_Brazillian_Rosewood, <2.0, 1.0, 0.0>, <0.5, 0.0, 0.0>, 0.0,
                             17, 2, LL_Brazillian_Rosewood, <0.05, 1.0, 0.0>, <0.0125, 0.0, 0.0>, 0.0,
                             17, 3, LL_Brazillian_Rosewood, <2.0, 0.1, 0.0>, <0.5, -0.025, 0.0>, 0.0,
                             17, 4, LL_Brazillian_Rosewood, <0.05, 1.0, 0.0>, ZERO_VECTOR, 0.0,
                             17, 5, LL_Brazillian_Rosewood, <1.0, 1.0, 0.0>, ZERO_VECTOR, 0.0,
                             19, ALL_SIDES, 1, 13,
                             7, <3.0, 0.2, 3.0>]);
       Whitelist(NULL_KEY);
   }
   listen(integer chan, string name, key id, string msg)
   {
       llListenRemove(dia_lis);
       if(msg != "CANCEL")
       {
           if(msg == "Global" | msg == "Local" | msg == "Self")
           {
               if(msg == "Global")
               global = TRUE;
               else if(msg == "Local")
               local = TRUE;
               dia_msg = "\nConfigure your doors.";
               dia_buttons = ["AutoClose", "CANCEL", "Angle"];
               if(sound_on)
               dia_buttons += ["SoundOff"];
               else
               dia_buttons += ["SoundOn"];
               if(locked)
               dia_buttons += ["UnLock"];
               else
               dia_buttons += ["Lock"];
               if(group)
               dia_buttons += ["GroupOff"];
               else
               dia_buttons += ["GroupOn"];
               if(dead)
               dia_buttons += ["UnDead"];
               else
               dia_buttons += ["DeadLock"];
               dia_lis = llListen(dia_chan, owner_name, owner, "");
               llDialog(owner, dia_msg, dia_buttons, dia_chan);
           }
           else if(msg == "AutoClose" | msg == "Angle")
           {
               dia_lis = llListen(dia_chan, owner_name, owner, "");
               if(msg == "AutoClose")
               {
                   dia_msg = "\nSelect the length of time to wait before auto closing or turn off auto closure.";
                   if(llRound(time))
                   dia_msg += ("\nThe time this door is set at is \"" + ((string)((integer)time)) + "\" seconds now.");
                   dia_buttons = ["NoAuto", "-", "CANCEL"];
                   dia_buttons += time_list;
               }
               else
               {
                   dia_msg = ("\nSelect the degree of travel for your doors.\nThis door is set at \"" + ((string)angle) + "\" now.");
                   dia_buttons = ["-", "CANCEL", "-"];
                   dia_buttons += angle_list;
               }
               llDialog(owner, dia_msg, dia_buttons, dia_chan);
           }
           else
           StringControl(msg, global, local, FALSE);
       }
   }
   dataserver(key q, string data)
   {
       if(q == NoNL)
       {
           notecard_length = ((integer)data);
           NL = llGetNotecardLine(NCN, count_NCL);
       }
       else if(q == NL)
       {
           if(data != EOF)
           whitelist += [data];
           if(count_NCL < notecard_length)
           NL = llGetNotecardLine(NCN, (++count_NCL));
           else
           {
               integer index = llListFindList(whitelist, ["Blacklist"]);
               blacklist = llList2List(whitelist, index, -1);
               whitelist = llDeleteSubList(whitelist, index, -1);
           }
       }
       else if(q == OLC)
       {
           if(((integer)data))
           {
               llPlaySound(Doorbell, 1.0);
               llInstantMessage(owner, (llKey2Name(bell_id) + " is at the door"));
           }
       }
   }
   link_message(integer sender, integer num, string str, key id)
   {
       if(str == "MA" && num == dia_chan && id == owner)
       aligned = FALSE;
       else if(str == "IGAN")
       {
           if(num == dia_chan && id == owner)
           {
               if(IGAN)
               llMessageLinked(LINK_ALL_OTHERS, dia_chan, "IGAN", NCK);
           }
           else
           {
               NCN = ((string)id);
               whitelist = [];
               blacklist = [];
               count_NCL = 0;
               NoNL = llGetNumberOfNotecardLines(NCN);
           }
       }
       else if(num == dia_chan && llGetSubString(str, 0, 5) == "homies" && id == owner && (sender == (mln + 1) | sender == (mln - 1)))
       StringControl(llGetSubString(str, 6, -1), global, local, TRUE);
       else if(num == dia_chan && llGetSubString(str, 0, 7) == "globules" && id == owner)
       StringControl(llGetSubString(str, 8, -1), global, local, TRUE);
       else if(num == dia_chan && str == owner_name && id == owner && (sender == (mln + 1) | sender == (mln - 1)))
       OperateDoor(open, TRUE);
   }
   touch(integer nd)
   {
       ++t_count;
       if(t_count >= 10)
       {
           key id = llDetectedKey(0);
           TouchMeAllOver(id, TRUE, FALSE);
       }
   }
   touch_end(integer nd)
   {
       key id = llDetectedKey(0);
       TouchMeAllOver(id, FALSE, TRUE);
   }
   timer()
   {
       llSetTimerEvent(0.0);
       llListenRemove(dia_lis);
       OperateDoor(open, FALSE);

   }
   changed(integer change)
   {
       if(change & CHANGED_INVENTORY)
       {
           IGAN = FALSE;
           Whitelist(NULL_KEY);
       }
       if(change & CHANGED_LINK)
       {
           llSleep(2.0);
           nop = llGetNumberOfPrims();
           mln = llGetLinkNumber();
           GetAligned(nop, mln);
           Whitelist(NULL_KEY);
       }
   }

}</lsl>