Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Elevator that can be called...

Slayora DeSantis
Registered User
Join date: 29 Dec 2006
Posts: 66
06-27-2008 21:08
Ok, I have this freebie elevator script. It works, but I would like it to be able to be 'called' to go up or down. When I right click on the prim, I go up, then I have to Stand Up to get off the prim. When I want to go down, I do the same thing again. What I would like it to do, is have it work to where two people can get on it, go up, and when it stays up, that it can be called down, instead of having to right click and lift to make it go down..meaning, I would have to sit on the prim again to get it to go down..ick.
What do I have to modify, in order for the script to work where I can just click on it to send it down or up and have more than just one person going up and down? Here's the script:

// lift script, v 1.0 by timeless montreal
//
// This script will allow you to make any prim a lift or an elevator.
// You should only have to change the liftAmount to the distance
// you want the lift to move. Of course, if you rather it move
// side to side, it shouldn't be too hard to tweak.
//
// enjoy!

integer liftAmount = 100; // change this to the amount you
// want to go up/down

integer isUp = FALSE; // Stores whether the object is up


movePlatform(){
llStartAnimation("stand";);
if(isUp == FALSE){
llSetPos(llGetPos() + <0, 0, liftAmount>;);
isUp = TRUE;
} else {
llSetPos(llGetPos() + <0, 0, -1*(liftAmount)>;);
isUp = FALSE;
}
}

default
{
state_entry()
{
llSitTarget(<0,0,1>,<0,0,0,1>;);
llSetSitText("Lift";);
}


changed(integer change)
{
if(change & CHANGED_LINK)
{
key avataronsittarget = llAvatarOnSitTarget();
if( avataronsittarget != NULL_KEY )
{
if ((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION) && llGetPermissionsKey() == avataronsittarget) {
llStopAnimation("sit";);
movePlatform();
} else {
llRequestPermissions(avataronsittarget, PERMISSION_TRIGGER_ANIMATION);
}
}
}
}


run_time_permissions(integer perm)
{
if(perm)
{
// Place the code here!
llStopAnimation("sit";);
movePlatform();
}
}
}
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
06-27-2008 21:26
you would need to create some kind of list and have it acculy detect where it is at and where it should go
Zozo Plympton
Registered User
Join date: 26 Oct 2006
Posts: 26
06-28-2008 20:09
Hm.. let me see... it would not be to hard to implement strictly what you have asked for and keep as much as possible of the code you have. But first of all
If you want to have multiple persons use the elevator you have to add more prims to the platform with each prim having a script in it setting the sit position in the default state_entry() to something like llSetSit(<0,0,0.5>, ZERO_ROTATION);
If the avatars are not sitting then the elevator will change position (go up/down) withouth moving the avatars!

The rest of the code change is simple:
1) Because you don't want to trigger the movePlatform() with the avatar sit event you have to delete the the changed() and the run_time_permission() event handlers.
2) Add the up/down trigger to the touch_start(integer dParam) event handler. It will look like:

touch_start(integer dParam)
{
movePlatform();
}

That's it :) So simple :) But consider that I am writing all this while I am not in world and I had no way to test it.
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
06-28-2008 23:21
From: Mrc Homewood
you would need to create some kind of list and have it acculy detect where it is at and where it should go



No you don't, you simply need to make a toggle flag in the elevator, and use a script like this:

CODE

default
{
state_entry()
{
llSay(0, "button ready");
}

touch_start(integer total_number)
{
llRegionSay (-99999,"elevator");
}
}


then, in the elevator, setup a listen event on the same channel (-99999 in this case), and use a flag as a toggle... i.e.

CODE


listen (integer channel, string name, key id, string message)

{
if (message == "elevator")
{
if (flag)
{
// send elevator up
flag = FALSE;
}
else
{
// send elevator down
flag = TRUE;
}
}
}



http://www.secondscripter.com
_____________________
My tutes
http://www.youtube.com/johanlaurasia
Mrc Homewood
Mentor of Randomness
Join date: 24 Feb 2007
Posts: 779
06-29-2008 10:26
hehe ui was thinking of something completly diffrent oops