Jump to content

Star Trek Door Scripting


Reymundo
 Share

You are about to reply to a thread that has been inactive for 2832 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hi so I have two mesh prims that I've textured into Star Trek doors, my problem is scripting them to both open at the same time and link them to a wall panel that will give lock access to the room's owner, and when locked allow for someone to chime the door to alert someone they have a visitor.

 

Something along the lines of what this door does: https://marketplace.secondlife.com/p/SoverignIntrepid-Trek-Doors-v21/1808032

 

This is all for a project I'm working on as a Star Trek themed wedding venue I plan to sell once it's finished and have failed to find a script that does what I need it to or rather even works properly.

Link to comment
Share on other sites

Since these are double doors, which you want to open at the same time, I think I would adapt Rolig's advice slightly, and have the doors open when they receive a link message rather than have them .listen to each other.

You can have the listener in one door and then, when it hears a message, it sends a link message to the whole linkset (including itself) and then both doors move when they receive the link message.   

I've always had much better results that way -- if they're listening to each other, one always opens and closes slightly before the other.

Link to comment
Share on other sites

So, start with a door script that you can be sure already works, and make cautious changes.  You really only need to make one change of any consequence. (The rest -- sounds and a lock -- are trivial additions.)  As Innula and I suggested, you'll need to send a signal with llMessageLinked from one door and receive it in a link_message event in the other.  Study examples of both in the LSL wiki.  The two doors should have almost identical scripts, except that you want one to slide left and the other to slide right.  Study the script at the link I gave you earlier (or another of your own choosing) until you understand how it works, and then start playing.  If you get stuck, come back and show us exactly where you have trouble.

ETA: If you decide to go with that door script, I'd suggest giving your two doors separate, distinctive names, like "Left Door" and "Right Door" so they don't get confused.

Link to comment
Share on other sites

if you need code to study, here is a mod of Linda's Linkable door script...

( this should work with doors scaled for width on any axis and any rotation. )

This script goes in each door.

 

integer up = 0; // set to 1 for other door on 2 door systmslist vecs;float slide;vector door;vector upVec;float pause = 3.0;integer tog;// get the scale and open door according to width, // ( could be x,y, or z scale depending on how door prim is made )// the slide variable opens the door it's entire width scalereset(){    door = ZERO_VECTOR;     vector mySize = llGetScale();     vecs = [mySize.x ,mySize.y, mySize.z];     list check =  llListSort( [mySize.x ,mySize.y, mySize.z], 1, TRUE) ;     slide = llList2Float(check,1);     integer index = llListFindList(vecs, [ llList2Float(check,1) ]);       if( index == 0) { door.x = slide;}       if( index == 1) { door.y = slide;}       if( index == 2) { door.z = slide;}}default{    state_entry()    {         }   link_message(integer sender_num, integer num, string msg, key id)    { if( num == 1)      { llSetTimerEvent(0.02);            }         }    timer()    {        if(tog >= 2)        { tog = 0;        llSetTimerEvent(0.0);                return;       }        reset();        up = !up;        upVec = door * llGetLocalRot();             if (up)        { llSetPos(llGetLocalPos()+upVec);                   }        else        { llSetPos(llGetLocalPos()-upVec);                   }         ++tog;         if( tog == 2) {  llSetTimerEvent(0.02);}         else { llSetTimerEvent(pause);}    }}

*Note - remember to change the second door's UP integer to 1

Then you just need a linked control pad to send a link message, kinda like..

 touch_start(integer total_number)
    {
        llMessageLinked(LINK_SET, 1,"", "");
    }

if you have a keypad prim with a nine faced texture, you could use something like this... (texture on face 4)

 

integer numberOfColumns = 3;integer numberOfRows = 3; default{    touch_start(integer num_detected)    {   integer face = llDetectedTouchFace(0);         vector touchST = llDetectedTouchST(0);                if (face != 4) { llSay(0,"Please touch the front!"); }         else        {   //we flip vertically and calculate a cell number             integer currentCellNumber = llFloor(touchST.x*numberOfColumns) +             (numberOfRows -llCeil(touchST.y*numberOfRows))*numberOfColumns + 1;                      llMessageLinked(LINK_SET, currentCellNumber , "" , "");        }    }}

The above 9 cell touchpad will send a number (1 - 9 ) and you could have 9 door sets listen for their number

( the door example above listens for the number 1 in link messages)

hope this help,

 test / play with this and post any probs you have back here?

 

 

 

Link to comment
Share on other sites

Okay so let's just say I have the two doors okay, then a two button control panel on the wall. The top button when pressed by the owner locks the doors and then unlocks them when clicked again. The bottom button opens both doors at the same time and then after a short period, closes. Obviously if the doors are locked then someone trying to open the doors is not going to do anything. What scripts would I need in the doors and in the control panel respectively? What you explained in the last post as far as the control panel as confusing.

Link to comment
Share on other sites

You could do the job with multiple scripts, but you actually only need one script.  Whether you put it in a separate control panel or in a door is immaterial, since they are all parts of the same linkset.  You already have more than one suggestion here for a basic sliding door script, if you can't write one of your own. All that the script has to do is move each of the doors. You can perform the necessary calculations for each door's movement parameters and then combine them in a single statement with llSetLinkPrimitiveParams. To lock/unlock the doors, all you need is a simple one-line toggle switch that either allows or disallows triggering in the touch_start event where the movement is triggered.

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 2832 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...