Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Script: Simple Elevator

Peter Linden
Registered User
Join date: 18 Nov 2002
Posts: 177
04-14-2003 14:25
Simple Elevator- moves up and down alot

Summary: The following script will make an elevator raise an lower constantly. To use, create any convincing elevator, attach this script. Type the word "align" then type "start" to start the elevator and "stop" to stop the elevator, then watch it rise and fall like the stock market.

Usage: This is a very basic elevator that merely goes up and down over and over.. My first usage of it was on a small platform. You can set the height by changing the "integer distance" number.

Script:
CODE

vector top;
vector bottom;
integer counter = 1;
integer distance = 10; //this is the distance between the top and bottom of the elevators movement.
float time = 7; //you will have to play with this value probably
default
{
state_entry()
{
key id = llGetOwner();
llListen(0,"",id,"");
llSetStatus(STATUS_ROTATE_X| STATUS_ROTATE_Y| STATUS_ROTATE_Z, FALSE);
}

listen(integer channel, string name, key id, string message)
{
if(message == "align") // the code that follows sets the two positions
that it will oscillate between.
{
bottom = llGetPos();
top = bottom + <0,0,distance>;
llSetStatus(STATUS_PHYSICS,TRUE);
llSleep(0.1);
llMoveToTarget(bottom, 0.1);
}
if(message == "start")
{
llSetTimerEvent(time);
}
if(message == "stop")
{
llSetTimerEvent(0);
}
}

timer()
{
if(counter > 0)
{
llMoveToTarget(bottom,2);
}
else
{
llMoveToTarget(top,2);
}
counter *= -1;
}
}

Notes: This elevator is is on a timer, but it could just as easily have been put into a for loop with a llSleep call. Feel free to make improvements and additions.


Credits:
Script written by:
Nada Epoch 3-20-03
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Discussion Thread:
04-25-2005 08:38
/54/8f/44190/1.html
_____________________
i've got nothing. ;)