(And due to the sketchy searching powers here on the forums, i am unable to find out who originally posted the script, so my apologies!)
CODE
//Elevator Script
list Floors = ["mine","surface","whoknows!"]; // Floor names
list Offsets = [ 0, 15, -10 ]; // Z offsets, not really needed since all at 5m intervals
vector start_pos;
vector pos;
vector move_pos;
integer Listening = 0;
integer listenchannel = 0;
integer targetID;
ShowMenu(key id)
{
string text = "Lift Menu\nPlease Select a Floor";
UpdateListen(id);
llDialog(id,text,Floors,listenchannel);
}
UpdateListen(key id)
{
CancelListen();
listenchannel = - (integer)llFrand(2147483648);
Listening = llListen(listenchannel,"",id,"");
llSetTimerEvent(30);
}
CancelListen()
{
if(Listening > 0) llListenRemove(Listening);
Listening = 0;
llSetTimerEvent(0);
}
init()
{
llSetStatus(STATUS_PHYSICS,FALSE);
llSetTimerEvent(10);
llSetText("",<0,0,0>,0);
}
default
{
state_entry()
{
init();
llSetStatus (STATUS_ROTATE_X|STATUS_ROTATE_Y|STATUS_ROTATE_Z, FALSE);
start_pos=llGetPos();
pos=start_pos;
llSetStatus(STATUS_PHYSICS,TRUE);
llMoveToTarget(start_pos,1.5);
}
touch_start(integer num_detected)
{
key id = llDetectedKey(0);
ShowMenu(id);
}
timer()
{
CancelListen();
}
listen(integer channel, string name, key id, string message)
{
CancelListen();
integer index = llListFindList(Floors,[message]);
if (index >= 0)
{
integer x = llList2Integer(Offsets,index);
move_pos=start_pos;
move_pos.z += x;
if (pos != move_pos)
{
llRequestPermissions(id, PERMISSION_TRIGGER_ANIMATION);
}
}
}
run_time_permissions(integer perm)
{
llStartAnimation("impatient");
targetID = llTarget( move_pos, 0.1 );
llMoveToTarget(move_pos,5);
}
at_target( integer number, vector targetpos, vector ourpos )
{
llStopMoveToTarget();
//llSetStatus(STATUS_PHYSICS,FALSE); //hn line
if(targetID)
{
llStopAnimation("impatient");
llTargetRemove(targetID);
targetID = 0;
}
pos = llGetPos();
}
}
thanks for any helps!