Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

elevator help

Bill Stirling
SL Architect
Join date: 4 Aug 2004
Posts: 105
08-25-2004 16:17
I need help building an elevator. I've tried with some simple and example elevator packages but could not get it to work. Could some one please contact me and help me with this? I can pay $L for the job. Thanks.
Goshua Lament
Registered User
Join date: 25 Dec 2003
Posts: 703
08-25-2004 22:31
I've build a ton of custom elevators. I did one in a themed lighthouse, a skydiving elevator, enclosed elevator in a building, and many others. Most of my scripts are loosly based on the USL(University of Second Life) basic elevator in a box package, created by resident Hank Ramos. I am on vacation with a underpowered Powerbook /G4 and can't login until Saturday. In the meantime, search for USL or ask Hank Ramos and you should be able to get help or a script that way. Good luck!
_____________________
Flickr Second Life Photo Gallery

I no longer regularly login to SecondLife, but please contact me if an issue arises that needs my attention.
Bill Stirling
SL Architect
Join date: 4 Aug 2004
Posts: 105
08-25-2004 23:56
Goshua, thx for the reply. i ahve tried an "elevator in the box" pacage but could not figure it out. I'll go have a look at USL to see if there is any more recources. if i can't do it myself, will you be able to help me? The weekend and after is fine, i am not in that big of rush.
Bill Stirling
SL Architect
Join date: 4 Aug 2004
Posts: 105
08-27-2004 16:43
ok, i got a low prim elevator to work. but now i am having a 2nd problem. how do i make the call bottons to function so that the elevator car will come to the floor you call it? please advise anyone. THX.
Goshua Lament
Registered User
Join date: 25 Dec 2003
Posts: 703
Call Buttons
08-27-2004 20:17
How to make call buttons for the elevator in a box. Basically, the elevator uses chat commands, right?

All you really need in a call button is a script that says the command on the same channel as the car. To change the channel of the script, I belive that you modify a variable at the top of the script, and one near line 99.

My call button for floor one works as follows:

CODE
default
{
touch_start()
{
llShout(<channel>, "goto floor 1");
}
}


Note my use of Shout instead of Say. This way, the car can hear the command when it is way above the call button that holds the script. If you have a taller elevator, I recomend using a relay device, positioned about halfway up the shaft, that repeats the command. Often, a easier method for large heights is to send an email. But that is a little beyond me at this point. For a short elevator, no relays or emails are needed.

I will be back in world in about 2 days if you still need help. Good luck!
_____________________
Flickr Second Life Photo Gallery

I no longer regularly login to SecondLife, but please contact me if an issue arises that needs my attention.
Bill Stirling
SL Architect
Join date: 4 Aug 2004
Posts: 105
08-28-2004 06:02
this is what my call button floor 1's script looks like:
-------------------------------------------------

integer floor = 1;

default
{
state_entry()
{
}

touch_start(integer total_number)
{
llWhisper(0, "Calling elevator to F1-Boat Deck" + (string)floor);
llMessageLinked(LINK_SET, -1, "goto floor " + (string)floor, NULL_KEY);
}
}

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

not sure if it is chat command and not sure where to make the change...
Jake Cellardoor
CHM builder
Join date: 27 Mar 2003
Posts: 528
08-28-2004 10:51
Your call button is probably not linked to the elevator car itself, so that llMessageLinked call won't bring it.

If the elevator car is listening for messages from the call buttons on a specific channel, your call buttons should be using llSay or llShout on that channel, as in Goshua's previous post. (I presume the llWhisper is to provide feedback to whoever pushed the button.)
Goshua Lament
Registered User
Join date: 25 Dec 2003
Posts: 703
08-28-2004 11:07
Is this a button that is linked to the elevator itself, or one that calls the elevator to a specific floor. Message Linked only sends the message to a prim that is linked to the script container. Also, the receiving script needs to have a link message event to handle it. I think that the elevator command is goto floor <floor number>. Just llSay that on the same channel of the script when the button is clicked and you should be fine. Also, I don't use a variable in my calll button script. It doesn't really need the added complexity.

Are you trying to make buttons that sit on the elevator car itself? The code for the button is essentially the same. The buttons are just linked to the elevator. Message linked is not nesecarry. If you do this, make sure to have the prim with the main elevator script set as the master prim.

We might have a different script in mind. Could you post the code of the elevator script itelf for me to read? Use the PHP button at the vB Code section of the page to insert the code.
_____________________
Flickr Second Life Photo Gallery

I no longer regularly login to SecondLife, but please contact me if an issue arises that needs my attention.
Bill Stirling
SL Architect
Join date: 4 Aug 2004
Posts: 105
08-28-2004 14:25
thx for all your posts. yes, i am trying to set a call button on a floor, not attached in the elevator car. so that when it is pressed, the elevator car would go to that floor. i am not good with scripts so I will try to follow all your comments.

here are the scripts. please have a look and see where i can make the changes.

elevator script
------------------
vector alignment;
vector targetVector;
integer travelDistance;
integer numListen;
integer targetFloor = -1;
list floorHeights = [21.112, 25.923, 34.963, 39.932];
float fixedFloorHeight = -1; //Set to floor heights, or set to -1 to use floorHeights list
float speed = 0.25; //Valid values are 0.01 to 1.0, a Percentage of maxSpeed;
float maxSpeed = 16;
float precision = 0.1;
integer autoSpeed = TRUE;
integer initialDistance;
integer counter = 0;

elevate (vector end)
{
vector current = llGetPos();
travelDistance = llRound(current.z-end.z);
travelDistance = llAbs(travelDistance);

if (autoSpeed)
{
if (travelDistance < (initialDistance / 2))
{
speed -= (precision * 2 / 25);
if (speed < 0.25)
speed = 0.25;
}
else
{
speed += (precision / 20);
if (speed > 1)
speed = 1;
}
}
if (travelDistance > 30)
{
travelDistance = 30;
if (end.z > current.z)
{
end.z = current.z + 30;
}
else
{
end.z = current.z - 30;
}
}
float i = travelDistance/(maxSpeed*speed);
llMoveToTarget(end,i);
}

GotoFloor (integer floor)
{
if (targetFloor != 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;
}

llShout(0, "Heading for Floor #" + (string)(targetFloor+1) + " [" + (string)((integer)targetVector.z) + "m]";);
elevate(targetVector);
llSetTimerEvent(precision);
}
}

reset()
{
llSay(0, "Resetting Elevator...";);
llSetStatus(STATUS_ROTATE_X| STATUS_ROTATE_Y| STATUS_ROTATE_Z, FALSE);

alignment = llGetPos();
llSetStatus(STATUS_PHYSICS, FALSE);
llStopSound();
llListenRemove(numListen);
numListen = llListen( 0, "", NULL_KEY, "";);
llSay(0, "Elevator Reset";);
}
checkM(key id, string m)
{
vector pos;
integer Floor;
float tempFloat;

m = llToLower(m);

if (m == "kill keep";)
{
llSleep(5);
llDie();
}
if (llSubStringIndex(m, "goto floor";) == 0)
{
Floor = (integer)llGetSubString(m, 10, llStringLength(m)) - 1;
GotoFloor(Floor);
}
if (llSubStringIndex(m, "go to floor";) == 0)
{
Floor = (integer)llGetSubString(m, 11, llStringLength(m)) - 1;
GotoFloor(Floor);
}
if (llSubStringIndex(m, "floor";) == 0)
{
Floor = (integer)llGetSubString(m, 5, llStringLength(m)) - 1;
GotoFloor(Floor);
}
if (llSubStringIndex(m, "speed";) == 0)
{
tempFloat = (float)llGetSubString(m, 5, llStringLength(m));
if ((tempFloat > 16) && (tempFloat <= 128))
{
maxSpeed = tempFloat;
}
}
}

default
{
state_entry()
{
reset();
}
on_rez(integer start_param)
{
llResetScript();
}
listen(integer a, string n, key id, string m)
{
if ((m=="elevator reset";) && (id==llGetOwner()))
{
reset();
}
}
link_message(integer sender_num, integer num, string str, key id)
{
checkM(id, str);
}
timer()
{
vector CurrentPos;
float tempfloat;

CurrentPos = llGetPos();
tempfloat = (CurrentPos.z - targetVector.z);

counter++;
if (counter > (2/precision))
{
llMessageLinked(LINK_SET, -1, "dis", (string)llGetTimeOfDay() + ",Elevator at " + (string)((integer)CurrentPos.z) + "m";);
counter = 0;
}
if (llFabs(tempfloat) < 2)
{
if (llFabs(tempfloat) < 0.05)
{
//Arrived at Floor
llWhisper(0, "Arrived at floor #" + (string)(targetFloor+1));
llSetTimerEvent(0);
llSetStatus(STATUS_PHYSICS, FALSE);
llStopSound();
}
else
{
llMoveToTarget(targetVector,1.0);
}
}
else
{
if (fixedFloorHeight > 0)
{
targetVector = alignment;
targetVector.z = alignment.z + (fixedFloorHeight * targetFloor);
}
else
{
targetVector = alignment;
targetVector.z = llList2Float(floorHeights, targetFloor);
}
elevate(targetVector);
}
}
}




1st floor call button script
------------------------------------
integer floor = 1;

default
{
state_entry()
{
}

touch_start(integer total_number)
{
llShout(0, "Calling elevator to F1-Boat Deck" + (string)floor);
llMessageLinked(LINK_SET, -1, "goto floor " + (string)floor, NULL_KEY);
}
}



network script
--------------------------------
//*********************************
//Generic Networking Script
//by Hank Ramos
//Version 2.3.3
//*********************************

//Options
integer ID = -1; //ID# of this node. Set to -1 to be unadressable repeater.
float TTL = 20; //Time to Live, how long a packet may survive on the network
integer size = 32; //Number of commands to remember that were previously received
integer commCH = 5524741; //Channel used for communication, 0 means don't use for now
//We will receive value later from other scripts in this object
//or we will receive the channel on_rez.

//Variables
list buffer;
integer numPriv;
key myKey;

setupCH(integer ch)
{
if (ch != 0)
{
commCH = ch;
llListenRemove(numPriv);
numPriv = llListen(commCH, "", NULL_KEY, "";);
}
}

default
{
state_entry()
{
myKey = llGetKey();
setupCH(commCH);
}
on_rez(integer s)
{
setupCH(s);
}
listen(integer ch, string n, key id, string m)
{
//Separate out incoming data
list L = llCSV2List(m);
float time = llList2Float(L, 0);
//Only Process Data if under TTL
if ((llGetTimeOfDay() - time) < TTL)
{
key skey = llList2Key (L, 1);
integer idn = llList2Integer(L, 2);
string command = llList2String (L, 3);
string data = llList2String (L, 4);
string packetID = (string)((integer)(time*10000)) + (string)skey;
if (command == "idn";)
{
//Receiving ID number for this prim
ID = idn;
setupCH((integer)data);
}
//Only repeat data that we haven't repeated before
else if(llListFindList(buffer, [packetID]) < 0)
{
if ((idn == ID) || (idn == -1))
{
//Send Message to Scripts in this Object
llMessageLinked(LINK_SET, -2, command, data);
}
if ((idn != ID) || (idn == -1))
{
//Reduce Buffer Size if too large
integer listLength = llGetListLength(buffer);
if (listLength >= (size*2))
buffer = llList2List(buffer, size, listLength);
//Add data to buffer
buffer += packetID;
//Repeat Data
llShout(commCH, m);
}
}
}
}
link_message(integer s, integer n, string m, key id)
{
//Don't process messages we sent ourselves using llMessageLinked
if (n != -2)
{
if (m == "sch";)
{
setupCH(n);
}
else if (m == "sid";)
{
ID = n;
}
else if (commCH != 0)
{
llShout(commCH, (string)llGetTimeOfDay() + "," + (string)myKey + "," + (string)n + "," + m + "," + (string)id);
}
}
}
}




Thank you all for helping again :)