Yesterday, Dad and I worked on a simple elevator script for Second Life.
Well, actually, it wasn’t technically on Second Life — rather, it was on my OpenSim node attached to OSGrid, but this script should work on Second Life as well. Note that I haven’t actually tested it on Second Life, and OpenSim translates LSL to C# and compiles it with Mono, so behaviour may not be smooth on Second Life.
But anyways, here’s the script:
vector LIFT_TOP = <112.,112.,81.5>;
vector LIFT_BOTTOM = <112.,112.,27.>;
Travelator(vector start, vector finish)
{
float distance = 0;
float progress = 0;
float increment = 1;
vector direction = finish - start;
vector dir_normal = llVecNorm(direction);
distance = llVecDist(finish, start);
vector next_pos = start;
llSetPos(next_pos);
do
{
progress += increment;
if (progress >= distance)
{
llSetPos(finish);
return;
}
next_pos += increment * dir_normal;
llSetPos(next_pos);
} while (progress <= distance);
}
default
{
state_entry()
{
llWhisper(0, "Going down...");
Travelator(LIFT_TOP, LIFT_BOTTOM);
}
touch_start(integer num_detected)
{
state top;
}
}
state top
{
state_entry()
{
llWhisper(0, "Going up...");
Travelator(LIFT_BOTTOM, LIFT_TOP);
}
touch_start(integer num_detected)
{
state default;
}
}
The constants LIFT_TOP and LIFT_BOTTOM are the coordinates of the top and bottom points of the elevator. This script does not support multiple storeys or call buttons -- rather, it's something you should build upon, rather than use out of the box.
Have fun.


