Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Variation on an elevator...

Ryder Spearmann
Early Adopter
Join date: 1 May 2006
Posts: 216
05-12-2006 22:11
Hi all...

New type of elevator here..

I want to attach a script to a set of linked objects, that form a container... such that they can be made to go up an down, like an elevator.

I need for it to go up and down regardless of if there is someone inside.

I need for any objects of avatars to go up and down with it, and not fall out.

I have tried attaching the simple elevator scripts I've found around here... but they never work...

(either they don't go up... or they eject the contents)


What are the considerations in such a script? Can it be done?


I am stunned at how hard it is to get an object to move up and down, and not cause all sorts of problems. (especially dumping contents)

Nothing fancy... just up 2 meters... then down... spilling nothing...

Thx,

Ryder
Shack Dougall
self become: Object new
Join date: 9 Aug 2004
Posts: 1,028
05-12-2006 23:34
From: Ryder Spearmann

I need for any objects of avatars to go up and down with it, and not fall out.


I'm not completely sure what you mean by this. Could you give an example?
_____________________
Prim Composer for 3dsMax
-- complete offline builder for prims and sculpties in 3ds Max
http://liferain.com/downloads/primcomposer/

Hierarchical Prim Archive (HPA)
-- HPA is is a fully-documented, platform-independent specification for storing and transferring builds between Second Life-compatible platforms and tools.
https://liferain.com/projects/hpa
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
05-12-2006 23:43
It should be possible - using physics.

That might mean your lift capsule has to be rebuilt a bit - no interpenetrating prims can be rather fussy.

Then use llSetStatus(STATUS_PHYSICS, TRUE).

You'll almost certainly want to clamp rotations (at least some of them) with
llSetStatus(STATUS_ROTATE_X | STATUS_ROTATE_Y | STATUS_ROTATE_Y, FALSE).

Then llMoveToTarget with a suitable tau should work - for a 2m move I'd have thought something around a 5s journey might be nice, so that would be llMoveToTarget("target vector", 5.0) I think - you'll have to play here to make it look and feel right.

The at_target() event will let you reset the target, put in a sleep phase and so forth as you want.
ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
Very simple elevator script
05-13-2006 00:13
Here is a very very simple elevator script that you can run in any prim or linked prim set. It uses the llSetPos () call so is non physical. It will pass through anything, but I think that depends on what material your prims are made of.

It uses a HUD to go fixed distances mostly up and down. You could adapt the script so that you can call the car from different positions by clicking on prims set up as call buttons.

You must sit on it for it to take you. It will not update your position if you only stand on it, iow it will go through you.

As it is, can be operated by anyone who touches it through a hud menu.

Feel free to use or adapt.

CODE

integer gChannel;
vector gPos;
key gOpKey;

string miUp = "Up";
string miDn = "Down";
string miUp10 = "Up 10";
string miDn10 = "Down 10";
string miUp50 = "Up 50";
string miDn50 = "Down 50";
string miE = "East";
string miW = "West";
string miN = "North";
string miS = "South";



// vector to string
string v2s (vector v) {

string s1 = f2s (v.x, 0);
string s2 = f2s (v.y, 0);
string s3 = f2s (v.z, 1);

return "(" + s1 + "," + s2 + "," + s3 + ")";
}



// float to string

string f2s (float f, integer n) {
integer m = n;
integer div = 1;
while (m > 0) {
div *= 10;
f *= 10.0;
--m;
}
integer i = llRound (f);
string lhs = (string) (i / div);
string rhs = (string) (i % div);

string ans;

if (n > 0)
ans = lhs + "." + rhs;
else
ans = lhs;
return ans;
}




string getDialogPrompt () {
string mes = "";
float ground = llGround (<0,0,0>);
float height = gPos.z - ground;
mes = "height = " + f2s (height, 1) + "M, Pos = " + v2s (gPos);
return mes;
}


goN () {
//llOwnerSay (miDn);
vector newPos = <gPos.x, gPos.y + 1.0, gPos.z>;
llSetPos (newPos);
gPos = newPos;
}

goS () {
//llOwnerSay (miDn);
vector newPos = <gPos.x, gPos.y - 1.0, gPos.z>;
llSetPos (newPos);
gPos = newPos;
}

goE () {
//llOwnerSay (miDn);
vector newPos = <gPos.x + 1.0, gPos.y, gPos.z>;
llSetPos (newPos);
gPos = newPos;
}

goW () {
//llOwnerSay (miDn);
vector newPos = <gPos.x - 1.0, gPos.y, gPos.z>;
llSetPos (newPos);
gPos = newPos;
}

goDn () {
//llOwnerSay (miDn);
vector newPos = <gPos.x, gPos.y, gPos.z - 1.0>;
llSetPos (newPos);
gPos = newPos;
}




goDn10 () {
//llOwnerSay (miDn10);
integer i;
for (i = 0; i < 10; i++)
goDn ();
}


goDn50 () {
//llOwnerSay (miDn10);
integer i;
for (i = 0; i < 50; i++)
goDn ();
}





goUp () {
//llOwnerSay (miUp10);
vector newPos = <gPos.x, gPos.y, gPos.z + 1.0>;
llSetPos (newPos);
gPos = newPos;
}




goUp10 () {
//llOwnerSay (miUp10);
integer i;
for (i = 0; i < 10; i++)
goUp ();
}



goUp50 () {
//llOwnerSay (miUp10);
integer i;
for (i = 0; i < 50; i++)
goUp ();
}





list menuListMove = [miDn, miDn10, miDn50, miUp, miUp10, miUp50, miE, miW, miN, miS];
setDialog () {
llDialog (gOpKey, getDialogPrompt (), menuListMove, gChannel);
}


actionDialogCommand (string message) {
if (message == miUp) {goUp (); return;}
if (message == miDn) {goDn (); return;}
if (message == miUp10) {goUp10 (); return;}
if (message == miDn10) {goDn10 (); return;}
if (message == miUp50) {goUp50 (); return;}
if (message == miDn50) {goDn50 (); return;}
if (message == miN) {goN (); return;}
if (message == miS) {goS (); return;}
if (message == miE) {goE (); return;}
if (message == miW) {goW (); return;}

}




default
{
on_rez (integer x) {
// llResetScript ();
llSetText ("Touch me for menu when not moving", <1.0,1.0,1.0>, 1.0);
gChannel = -(integer)llFrand(0x7FFFFF00) - 255;

}




state_entry() {
// gOwnerKey = llGetOwner();
// llOwnerSay("Simple Elevator starting at " + v2s (gPos));
}



listen( integer rchannel, string name, key id, string message ) {
// llOwnerSay ("name=" + name + " message=" + message);
actionDialogCommand (message);
setDialog ();
}

touch_start(integer total_number)
{
key op = llDetectedKey(0);
if (op != NULL_KEY) {
gOpKey = op;
llListen( gChannel, "", "", "" );
gPos = llGetPos ();
setDialog ();
} else
llOwnerSay ("detected null key in touch start");
}
}
Ryder Spearmann
Early Adopter
Join date: 1 May 2006
Posts: 216
05-14-2006 17:46
From: Shack Dougall
I'm not completely sure what you mean by this. Could you give an example?


Sorry... typeo... "objects or avatars"

take a big box... place objects into it... vehicles into it, or yourself (not sitting)... and then press "UP", and the elevator does the rest...

thx Ryder
Ryder Spearmann
Early Adopter
Join date: 1 May 2006
Posts: 216
05-14-2006 17:51
Thx for the script... but it seems to openly violate my basic need... it spills objects (passes through them).

-Ryder-


From: ed44 Gupte
Here is a very very simple elevator script that you can run in any prim or linked prim set. It uses the llSetPos () call so is non physical. It will pass through anything, but I think that depends on what material your prims are made of.

It uses a HUD to go fixed distances mostly up and down. You could adapt the script so that you can call the car from different positions by clicking on prims set up as call buttons.

You must sit on it for it to take you. It will not update your position if you only stand on it, iow it will go through you.

As it is, can be operated by anyone who touches it through a hud menu.

Feel free to use or adapt.

ed44 Gupte
Explorer (Retired)
Join date: 7 Oct 2005
Posts: 638
05-14-2006 18:21
Hi Ryder

You could make a path (say a shaft) for the elevator to move up and down in. That shaft in your structure might give clear passage way to the elevator box, so it does not neem to contravene any physical rules. Just remove and sideway movement commands and place limits on how far up and down it can move by checking llPos ().z

You may also be able to give a physical elevator some little push up or down. Someone else might have a script for that.

hth

Ed
Shack Dougall
self become: Object new
Join date: 9 Aug 2004
Posts: 1,028
05-14-2006 20:25
From: Ryder Spearmann
Sorry... typeo... "objects or avatars"

take a big box... place objects into it... vehicles into it, or yourself (not sitting)... and then press "UP", and the elevator does the rest...

thx Ryder


Okay, I'll take a shot at describing some of the principles.

Eloise makes some good points, but I'll just give them some context.

There are two types of objects in SL: those with physics enabled and those without. Physics is one of the checkboxes in the edit window and can also be enabled via script. For convenience, I'll describe them as physical and non-physical objects.

Physical objects can be influenced by outside forces such as gravity or pushes. Non-physical objects cannot be moved by outside forces. Objects are non-physical by default. Vehicles are usually physical.

This leads immediately to an interesting point. Non-physical objects cannot be moved by any elevator. They can't be moved by anything outside of them except the edit dialog or a script inside of them.

Be careful not to confuse non-physical with phantom. Non-physical objects are not phantom by default. You can't walk through them. A physical object cannot move through a non-physical object unless the non-physical object has been made phantom.

So, if you rez a new cube on any elevator, the elevator will not be able to move it. If the elevator is non-physical, the elevator will pass through the cube. If the elevator is physical, it will bump against the cube and the elevator will be unable to move. The physical elevator can't move the non-physical cube, nor can it pass through it, so the cube becomes an unmovable barrier to the elevator.

So, if it is important for your elevator to move objects, then you'll need a physical elevator. But it will only be able to move physical objects or avatars.

How do you know if an elevator script is physical or not?

If the script says that people must sit on the elevator, then it is non-physical.

A script for a physical elevator will probably have
CODE
llSetStatus(STATUS_PHYSICS, TRUE);

in it.
_____________________
Prim Composer for 3dsMax
-- complete offline builder for prims and sculpties in 3ds Max
http://liferain.com/downloads/primcomposer/

Hierarchical Prim Archive (HPA)
-- HPA is is a fully-documented, platform-independent specification for storing and transferring builds between Second Life-compatible platforms and tools.
https://liferain.com/projects/hpa
Ryder Spearmann
Early Adopter
Join date: 1 May 2006
Posts: 216
05-17-2006 12:19
Thanks for the info Shack...

Certainly I understand the basic issues... but still, it seems that there may not be a clear way to make an elevator that works well with different types of objects...

For example...

what would happen if I placed three types of things in an elevator box...

An avatar (standing or sitting)
A vehicle
A physical object...


All in the same elevator at the same time.

I find that the Avatar will stay onboard... while physical objects fall through. (perhaps vehicles as well). Question: must vehicles be physical objects? If they are not... can they be linked to objects that are (like a platform) that can then ride the elevator?

Is there a good approach to making an elevator that works for this situation?

Finally... why do Avatars seem to successfully ride elevators... while physical objects often do not?

Thx...