I'm putting out a prefab for this garage, and I was given a Garage Door script to make the door go up and down. The top stays in place, the bottom resizes so the prim for the garage door itself "squishes" up to the top. I can set how far up the garage door goes. I've got the door itself all figured out, now I'd like to add a sound or two to the door, but I'm not talented enough with the scripting language to edit it and have the door stay functional.
Lets say the sound for the door opening is "Opensound" and closing is "Closesound"
Any help is GREATLY appreciated!
Here is the script:
integer no_steps = 20; // Number of steps when opening/closing. More means smoother action, but takes longer
float open_height = 2.5; // Height of remaining door to show when open
vector closed_position;
vector closed_scale;
integer open;
open_door()
{
integer i;
float dz = (closed_scale.z - open_height) / no_steps;
for (i = 1; i <= no_steps; i++)
{
float height = closed_scale.z - i*dz;
llSetScale(<closed_scale.x, closed_scale.y, height>
;//llSleep(1.0);
llSetPos(<closed_position.x, closed_position.y, closed_position.z + 0.5*(closed_scale.z - height)>
;//llSleep(1.0);
}
}
close_door()
{
integer i;
float dz = (closed_scale.z - open_height) / no_steps;
for (i = no_steps - 1; i > 0; i--)
{
float height = closed_scale.z - i*dz;
llSetScale(<closed_scale.x, closed_scale.y, height>
;//llSleep(1.0);
llSetPos(<closed_position.x, closed_position.y, closed_position.z + 0.5*(closed_scale.z - height)>
;//llSleep(1.0);
}
// set to predefined closed position, to prevent errors accumulating
llSetScale(closed_scale);
llSetPos(closed_position);
}
default
{
state_entry()
{
open = FALSE;
closed_position = llGetPos();
closed_scale = llGetScale();
}
touch_start(integer total_number)
{
if (open) {
close_door();
} else {
open_door();
}
open = !open;
}
}