Change font size
It is currently Thu Nov 22, 2018 5:27 am

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 1 post ]
Author Message
 Post subject: FSS-Linkable Door System (Simple)
PostPosted: Fri Nov 09, 2012 4:51 pm 
OSG Elite
User avatar

Joined: Wed Mar 11, 2009 3:57 pm
Posts: 444
Hello folks,

Seems that a few people are looking for a simple & easy door with a few basic functions.
I am posting a "Simple" Linkable Door system which I use frequently. This allows for the following configurations:

  • Can be used as a Master & Slave combo (double doors)
  • Can be used as a Single Door (using Master door)
  • Can have multiple door sets linked into a build.
  • Can operate so that one door opens/closes all, or each can operate independently.
  • Uses link messages so no chatter / chat spam. Effective even in Large Linksets over 255 prim.
  • Can send greeting / parting message if set. (Greeting is usually the only one to use, on a main door)
  • Sends messages to Avatar using llInstantMessage so as to not spam others in-region. (Spamless)
  • Does NOT do collision detection but can be altered to do so. (requires debouncing, as collisions in OpenSim are 7x faster than in SL)

* Scripts shown below.
* Attachment FSS_LinkedDoors.zip is a Cool Viewer XML export of the actual doors, scripts & sound files included. This XML format can be imported with Cool VL Viewer, & Imprudence, other viewers with XML Export/Import unknown.

Master Door Script:
{L_CODE}:
// ----------------------------------------------------------------
// Script Title:     FSS-Simple_Linkable_Door (Master) & FSS-Simple_Linkable_Door (Slave)
// Created by:       WhiteStar Magic
// Creation Date:    October.01.2012
// Platforms:
//    SecondLife:    Y
//    OpenSim:       Y
//
// Revision:        1.4
// Revision History: derivitive from FSS-MultiDoor
//
//  DESCRIPTION & INSTRUCTIONS
//
//  NOTE: 
//      The prim type used for this is a Box Prim cut in half [Path Cut (0.375 / 0.875)]
//      The cut edge is on the outside (hinge side) of the door prim.
//
//  This is a Simple Door system which is linkable to your build. 
//  This simply opens & closes door(s).  no security or extras.
//  Master & Slave can be linked into a build for use as Double Doors.
//  Master can linked to a build for use as a Single Door.
//
//  To use as a "door set"  edit the Description field on the door prim,
//  and enter DOOR_NUM=-4120     where  -4120 is any 4 digit negative number you choose.
//  This is used for the Master & Slave doors to communicate & coordinate opening & closing.
//  Each "door set" in a build must have unique numbers, or they will all open/close at the same time.
//
//  To use as a "Single Door" be sure to use the MASTER script and use a unique DOOR_NUM= to prevent
//  one door from interacting with teh other linked doors.
//
//================================================================
//  Welcome & Close messages & sounds which you can adjust.
string open_message = "Welcome ";
string close_message = "";
string open_sound = "door_open.wav";    // These can be set to ""
string close_sound = "door_close.wav";   // to disable the sounds.
float open_time = 30.0;                   // how long the door stays open before it closes

// =========================== \\
// === DO NOT CHANGE BELOW === \\
//GLOBALS
integer door_num = -4120;       //Default Door number in the house, change if more doors in Build (this is adjusted internally in script.)
string startup_message ="Door Initializing";
integer door_open = FALSE;
integer Listen_Handle = -1;
string name;
key avi_key;
//
// ==== TOOL FUNCTIONS ==== \\
touched()
{
    if (!door_open)
    {
        llSetTimerEvent(open_time);
        door_open = open(name);
    }
    else
    {
        llSetTimerEvent(0.0);
        door_open = close(name);
    }
}
//
////- - - - - - - - - - - - - - - -
integer open(string av_name) // Opens the door.
{
    if (open_message != "") llInstantMessage(avi_key, open_message+av_name);
    llMessageLinked(LINK_SET, door_num, "Open", NULL_KEY);//send open link message
    //
    rotation rot = llGetLocalRot();
    rotation delta = llEuler2Rot(<0,0,-PI/4>); //was 3
    rot = delta * rot;
    llSetLocalRot(rot);
    llSleep(0.05);
    if (open_sound != "") llTriggerSound(open_sound, 0.5);
    rot = delta * rot;
    llSetLocalRot(rot);
    return TRUE;
}
//- - - - - - - - - - - - - - - -
integer close(string av_name) // Closes the door.
{
    if (close_message != "") llInstantMessage(avi_key, close_message+av_name);
    llMessageLinked(LINK_SET, door_num, "Close", NULL_KEY);//send close link message
    //
    rotation rot = llGetLocalRot();
    rotation delta = llEuler2Rot(<0,0,PI/4>); // was 3
    rot = delta * rot;
    llSetLocalRot(rot);
    llSleep(0.05);
    if (close_sound != "") llTriggerSound(close_sound, 0.5);
    rot = delta * rot;
    llSetLocalRot(rot);
    return FALSE;
}
// ******** CODE ENTRY ********* \\
//===============================\\
default
{
    state_entry()
    {
        string desc = llGetObjectDesc();
        string partA = llGetSubString(desc,0,8);  //DOOR_NUM=
        string partB = llGetSubString(desc,9,13); //4409   (we only grab 4 digits)
        if(partA=="DOOR_NUM=" && partB != "") door_num=(integer)partB;
        else llSay(0,"DOOR_NUM= not set in Prim Description.  Using default of:"+ (string)door_num);
        //
        open_sound = llGetInventoryKey(llGetInventoryName(1,0));
        close_sound = llGetInventoryKey(llGetInventoryName(1,0));
        //
        if (startup_message != "") llOwnerSay(startup_message);
    }
    on_rez(integer rez)
    {
        llResetScript();
    }
    changed(integer change)
    {
        if (change & CHANGED_OWNER) llResetScript();
    }
    touch_end(integer total_number)
    {
        name = llDetectedName(0);
        avi_key = llDetectedKey(0);
        touched();
    }
    link_message(integer sender_num, integer num, string str, key id)
    {
        if (num==door_num)
        {
            if (str=="Touched")
            {
                name = (string)llKey2Name(id);
                avi_key = id;
                touched();
            }
        }
    }
    timer()
    {
        if (door_open)
        {
            llSetTimerEvent(0.0);
            door_open = close("the script");
        }
    }
}


Slave Door Script
{L_CODE}:
// This is the SLAVE door to the FSS-Simple_Linkable door
// change this to be whatever door number the adjacent matching door has
integer door_num=-4120; // DOOR_NUM= must be set in Prim Description to assign the unique number to use.
 
//- - - - - - - - - - - - - - - -     
integer open() // Opens the door.
{
    rotation rot = llGetLocalRot();
    rotation delta = llEuler2Rot(<0,0,PI/4>); // was 3
    rot = delta * rot;
    llSetLocalRot(rot);
    llSleep(0.05);
    rot = delta * rot;
    llSetLocalRot(rot);
    return TRUE;
}
//- - - - - - - - - - - - - - - -     
integer close() // Closes the door.
{
    rotation rot = llGetLocalRot();
    rotation delta = llEuler2Rot(<0,0,-PI/4>); // was 3
    rot = delta * rot;
    llSetLocalRot(rot);
    llSleep(0.05);
    rot = delta * rot;
    llSetLocalRot(rot);
    return FALSE;
}
//- - - - - - - - - - - - - - - -     
default
{
    state_entry()
    {
        string desc = llGetObjectDesc();
        string partA = llGetSubString(desc,0,8);//DOOR_NUM=
        string partB = llGetSubString(desc,9,13); //4409   (we only grab 4 digits)
        if(partA=="DOOR_NUM=" && partB != "") door_num=(integer)partB;
        else llSay(0,"DOOR_NUM= not set in Prim Description.  Using default of:"+ (string)door_num);
    }

    touch_start(integer total_number)
    {
        llMessageLinked(LINK_SET, door_num, "Touched", llDetectedKey(0));
    }
   
    link_message(integer sender_num, integer num, string str, key id)
    {
        if (num==door_num)
        {
            if (str=="Open")
            {
                open();
            }
            if (str=="Close")
            {
                close();
            }
        }
    }
}


Attached File:
{L_ATTACHMENT}:
FSS_LinkedDoors.zip


Hope it helps and good luck.

_________________
No further support of any kind, for any of my materials. Use as/is whereis.
PLEASE UNSTICKY Any Stickied Posting by myself.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 1 post ]


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  


Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of Gamexe.net