Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Elevator script with call/floor buttons

Ingie Bach
Registered User
Join date: 17 Dec 2002
Posts: 254
08-01-2004 19:47
Ok, here is my elevator script, built on bits of other people's work where I learned it... so long ago, I don't remember who. In fact this script is pretty old (I think over a year?)


Button script, make two buttons per floor, one attached to the elevator itself, the other as a call button on the outside of the elevator on the floor it represents:

First Floor:
CODE

default
{
touch_start(integer total_number)
{
llSay(3,"one"); //Triggers the elevator
llSay(0, "Welcome to the First Floor"); //the welcome message.
}
}


Second Floor:
CODE

default
{
touch_start(integer total_number)
{
llSay(3,"two"); //Triggers the elevator
llSay(0, "Welcome to the Second Floor"); //the welcome message.
}
}

Third Floor:
CODE

default
{
touch_start(integer total_number)
{
llSay(3,"three"); //Triggers the elevator
llSay(0, "Welcome to the Third Floor"); //the welcome message.
}
}


Then there is the elevator scrpt:

CODE

//Elevator Script

vector start_pos;
default
{
state_entry()
{
llSetStatus (STATUS_ROTATE_X|STATUS_ROTATE_Y|STATUS_ROTATE_Z, FALSE);
start_pos=llGetPos();
llSetStatus(STATUS_PHYSICS,TRUE);
llMoveToTarget(start_pos,1.5);
key id ="";
llListen(3,"",id,"");//choose a different channel for your elevator to listen to other than 0, which would be "audiable" I chose 3 here
}

listen(integer a, string n, key id, string m)
{
vector move_pos;
if (m=="two")//This is for the second floor level
{
move_pos=start_pos+<0,0,1>;//exparament to set the hight just right, usually around 6 meters per floor, but of course that can very, plus you want to get it just right.
llMoveToTarget(move_pos,0.2);//this is set so that the elevator does not colide with the floor (and cause it to wiggle, giggle and jerk)
}
if (m=="three")//this is the third floor
{
move_pos=start_pos+<0,0,2>;//This would normally be set around 12 meters. The settings could also be set for sideways elevators, like on the Enterprise ;P go to exact locations!
llMoveToTarget(move_pos,0.2);
}
if (m=="one")
{
llMoveToTarget(start_pos,0.2);//we go home here to where the elevator was created or the script was started.
}

}
}


I sure hope people like that... I have a sample elevator you can come by and copy at Sistiana 132, 114 (pardon my dust) I really will get back to that Bradbury building, I promise!!!

Love Ingie

edit- edited to make it a little more readable, and fixed one line that would have broken it on a copy paste. ne
_____________________
I love modeling in Blender, if you want to check out a fantastic package for modeling and game developement (great for Architectural Walkthroughs), go to my site: http://www.ingiebee.com
Ingie Bach
Registered User
Join date: 17 Dec 2002
Posts: 254
Original Thread
08-06-2004 11:35
/15/2c/19094/1.html

----------------------------------

use llShout instead of llSay if your elevator doesn't hear your call buttons on the outside due to distance.

Also, increase the second factor in:
llMoveToTarget(move_pos,0.2);

Change the 0.2 to something more like 3 for a better speed. You may like a larger number too, but then the decelleration is so slow it can become annoying.

Ingie
_____________________
I love modeling in Blender, if you want to check out a fantastic package for modeling and game developement (great for Architectural Walkthroughs), go to my site: http://www.ingiebee.com
Cazzj Brearly
Look! A UFO!
Join date: 21 Mar 2005
Posts: 113
08-08-2005 14:25
From: Ingie Bach
use llShout instead of llSay if your elevator doesn't hear your call buttons on the outside due to distance.

I have an elevator that goes from 42.5-Z to 470.75-Z....far beyond shout distance for my call buttons on those floors. I've heard of ppl using email to call the elevator, but haven't seen any sample code on how to do that. By the way, I'm using Hank Ramos's free "Elevator in a Box" with a modified elevator car and no shaft. Thank you Hank for making that available. My elevator works fine with the buttons inside the elevator, I just want to be able to call it with email from beyond shout range.

Thank you!
a lost user
Join date: ?
Posts: ?
cannot stand on elevator
08-19-2005 22:30
Hi,
I used Ingie Bach's script to build a beautiful elevator - thanks Ingie ~ it works!!
/15/2c/19094/1.html


The thing is, avatar cannot stand on it.
Can sit on it, but when approach to stand on it it moves away.
Cannot jump on it either ~

wierd.
Anyone had this issue?
thanks for your help!!
_____________________
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
08-20-2005 12:13
/15/2c/19094/1.html
_____________________
i've got nothing. ;)
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
08-20-2005 12:17
jsut moved from the scripting library so you guys can get your discussion on. :)
_____________________
i've got nothing. ;)
Seagel Neville
Far East User
Join date: 2 Jan 2005
Posts: 1,476
09-02-2005 23:04
I had a chance to make an elevator. I saw avatars run when the lift moved. Maybe it is because of SL logic. Moving normal is walking and fast is running. Then you can't stand still on it. The rest is relevant priority. Sitting priority seems to be higher than running. It might help that you can replace the animation by sitll standing like AO.
_____________________
:) Seagel Neville :)
a lost user
Join date: ?
Posts: ?
09-03-2005 04:53
Email is basically the same, just using emails to communicate, here's a very rough example of it. The first two scripts go in the elevator, and teh call button script goes in a seperate object for the call button.

Email part of elevator:
CODE

default
{
on_rez(integer p)
{
llResetScript();
}
state_entry()
{
llSay(0, (string)llGetKey());
llSetTimerEvent(5.0);
}

timer()
{
llGetNextEmail("","");
}

email(string time, string address, string subj, string msg, integer num_left)
{
integer floor_num;
if(llGetSubString(subj,0,9) == "goto floor")
{
floor_num = (integer)llGetSubString(subj,10,-1);
llMessageLinked(LINK_THIS,floor_num,"","");
}
}
}


Just the email relevant portion of the script of someone's elevator script (not mine):
CODE

GotoFloor (integer floor, key id)
{
llWhisper(0, "Moving to floor#" + (string)floor);
llSetStatus(STATUS_PHYSICS, TRUE);

targetFloor = floor;

if (fixedFloorHeight > 0)
{
targetVector = alignment;
targetVector.z = alignment.z + (fixedFloorHeight * floor);
}
else
{
targetVector = alignment;
targetVector.z = llList2Float(floorHeights, floor);
}


vector current = llGetPos();
initialDistance = llRound(current.z-targetVector.z);
initialDistance = llAbs(initialDistance);

if (autoSpeed)
{
speed = 0.01;
}

elevate(targetVector);
llSetTimerEvent(precision);
}

default
{
link_message(integer sender, integer number, string message, key data)
{
GotoFloor(number, NULL_KEY);
}
}



The call button:
CODE

// floor number goes here.
string floor_num = "floor1";

// This is the key of the object that the email will be sent to
key email_dest= "8148361f-0c74-6569-f4f4-9c3f4fcb6c29";
default
{
touch_start(integer num)
{
llSay(0, "Calling Elevator");
llEmail((string)email_dest + "@lsl.secondlife.com", "goto " + floor_num, "");
}
}


This is just an example that I pulled from a script I had to modify for someone so they could have a very high floor.
Phil Moore
Sweet Piece
Join date: 30 Apr 2006
Posts: 32
. .and then a year later some newb comes along . . .
06-04-2006 09:10
I'm trying to use Ingie's elevator in my new building. I figured out how to get close to the speed and movement I want, which is a step in the right direction!

The issue I'm having is with the return to start position aspect. No matter where I start the elevator, it sems to return to a point just far enough above the floor that I can't step onto it. I made 2 small ramps to attempt a workaround, but the el just stops above them now - even though they are beside it and not directly below it.

I've played with the numbers and I can't get it to come back to the original starting point. What the heck am I doing wrong? Any suggestions would be appreciated.

Thx.
Ayden Sivocci
Adjunct of Unimatrix zero
Join date: 6 Sep 2006
Posts: 25
09-12-2006 05:33
From: someone
Hi,
I used Ingie Bach's script to build a beautiful elevator - thanks Ingie ~ it works!!
/15/2c/19094/1.html


The thing is, avatar cannot stand on it.
Can sit on it, but when approach to stand on it it moves away.
Cannot jump on it either ~

wierd.
Anyone had this issue?
thanks for your help!!



I'm having the same issue, as well as, well, it doesn' t move. I'm getting the 'Welcome to the X floor' message, but no movement. Ideas?
Chaz Longstaff
Registered User
Join date: 11 Oct 2006
Posts: 685
07-13-2007 23:39
rough examples alright, lol, couldn't get either to even compile, too many basic syntax errors (ducks!)