Jump to content

Smooth sliding doors with sound


LegitBonzai
 Share

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

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

Recommended Posts

4 hours ago, LegitBonzai said:

I did found this: https://wiki.secondlife.com/wiki/Smooth_Sliding_Door

and that works perfect for my project.

but i found there is no sound in it.

I'm not an expert scripter, but it seems that the script on this page just needs to call llPlaySound() just before the door starts to move.  I'd probably drop the sound file in the door's inventory and call it by name in the script (rather than using a key for it).

  • Like 1
Link to comment
Share on other sites

3 hours ago, SeanMcDonald said:

I'm not an expert scripter, but it seems that the script on this page just needs to call llPlaySound() just before the door starts to move.  I'd probably drop the sound file in the door's inventory and call it by name in the script (rather than using a key for it).

Even better, the script has pretty obvious sections for when the door opens and closes, you could add a different sound for each.

MoveDoor()
{
    if(!bOpen)
    {   /* some code*/    
        llPlaySound("Door opening sound",1.0);
    }else
    {   /* some code*/
        llPlaySound("Door closing sound",1.0);
    }
    /* more code*/
}
Quote
// ********************************************************************
//
// Basic Physical Sliding Door Script
// by SimonT Quinnell (11/07/2009) edited by Flax Quirina
// for auto-close (17/06/2011).
//
// NOTE: If you are going to reposition the door, do it while the door is closed.
//  Otherwise it will try and use the old close position as a reference point.
//
// Licensed under the "OpenCollar License"
// Ie. Licensed under the GPLv2, with the additional requirement that these scripts remain "full perms" in Second Life.
//
// Edit: Simplified the script to be just a basic move script .. removed the sound triggers (5/1/2010)
//
// ********************************************************************
 
 
// ********************************************************************
// CONSTANTS
// ********************************************************************
 
string SOUND_OPEN = "Door open sound";
string SOUND_CLOSE = "Door close sound";
// Movement Constants
vector      OFFSET = <-2.0, 0.0, 0.0>;      // Directional offset for moving the door in x,y,z coordinates
float       OPENTIME = 3.5;                 // Time taken to open door
float       CLOSETIME = 3.5;                // Time taken to close door
float       AUTO_CLOSE_TIME = 5;              // Time to auto-close the door
 
// ********************************************************************
// Variables
// ********************************************************************
 
vector      vPosition;
rotation    rRot;
float       omega=0.0;
vector      vTargetPos;
integer     bOpen = FALSE;
integer     bMoving = FALSE;
integer     destTarget;
 
// ********************************************************************
// Functions
// ********************************************************************
 
 
MoveDoor()
{
    if(!bOpen)
    {   llPlaySound(SOUND_OPEN,1.0);
      	// Initial conditions
        bOpen = TRUE;                
        rRot = llGetRot();
        vPosition = llGetPos();
 
        // Target Position
        omega=OPENTIME/llVecDist(<0,0,0>,OFFSET);
        vTargetPos = vPosition+OFFSET*rRot;
 
        // Set the timer to cleanup position
        //llSetTimerEvent(OPENTIME);        
    }else
    {   
        llPlaySound(SOUND_CLOSE,1.0);
        bOpen = FALSE;
 
        // Target Position
        omega=CLOSETIME/llVecDist(<0,0,0>,OFFSET);
        vTargetPos = vPosition;
 
        // Set the timer to cleanup position
        //llSetTimerEvent(CLOSETIME);
    }
 
    // Set Door Physical and move it
    bMoving = TRUE;
    llSetStatus(STATUS_PHANTOM, TRUE);
    llSetStatus(STATUS_PHYSICS, TRUE);
    destTarget = llTarget(vTargetPos, llVecDist(<0,0,0>,OFFSET));
    llMoveToTarget(vTargetPos,omega);
    
}
 
 
default
{            
    state_entry()
    {   // Initial conditions
        rRot = llGetRot();
        vPosition = llGetPos();
    }    
    at_target(integer tnum, vector targetpos, vector ourpos) {
        if(llVecDist(targetpos, ourpos) < 0.1) {
            // Clean up Position
            bMoving = FALSE;
            llSetStatus(STATUS_PHYSICS, FALSE);
            llSetStatus(STATUS_PHANTOM, FALSE);         
            llSetPrimitiveParams([ PRIM_POSITION, vTargetPos, PRIM_ROTATION, rRot ]);
            llTargetRemove(destTarget);
            if(bOpen) {
                llSetTimerEvent(AUTO_CLOSE_TIME);
            }
        }
    }
    touch_start(integer num_detected)
    {
        MoveDoor();
    } 
 
    timer()
    {
        llSetTimerEvent(0.0);
        MoveDoor();
    }
}

or so.

 

Edited by Quistess Alpha
  • Like 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 511 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...