lang="en-US"> SecondLife Tutorial: Working Elevator –  Design1online.com, LLC

SecondLife Tutorial: Working Elevator

I found code from another person in the SL wiki and tweaked it to my liking. It had some issues with coming back down after the SL avatar was on top of the elevator platform. I’ve also changed it so you can touch the elevator to move it and once the elevator is has moved to it’s new position you can move the avatar around instead of being glued to the center of it.

// lift script, v 1.0 by timeless montreal
// modified by Jade Battery
//put it in any object to transform it into an elevator
//touch the object to move it up/downinteger

liftAmount = 4;//how far to move up

integer isUp = FALSE; //current position of the object

movePlatform()
{
//makes you appear to be standing
llStartAnimation("stand");

if(!isUp)
{
//move the elevator up
llSetPos(llGetPos() + <0, 0, liftAmount>);
llSay(0, "Going up!");
isUp = TRUE;
key avataronsittarget = llAvatarOnSitTarget();
llUnSit(avataronsittarget);
}
else
{
//move the elevator back down
llSetPos(llGetPos() + <0, 0, -1*(liftAmount)>);
llSay(0, "Going down!");
isUp = FALSE;
key avataronsittarget = llAvatarOnSitTarget();
llUnSit(avataronsittarget);
}
}

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

//touch to move the elevator
touch_start(integer num)
{
key avataronsittarget = llAvatarOnSitTarget();

if( avataronsittarget != NULL_KEY )
{
if ((llGetPermissions() & PERMISSION_TRIGGER_ANIMATION)
&& llGetPermissionsKey() == avataronsittarget)
{
llStopAnimation("sit");
movePlatform();
}
else
llRequestPermissions(avataronsittarget, PERMISSION_TRIGGER_ANIMATION);
}
} //end touch

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);
}
}
}
}

//request the permissions if need be
run_time_permissions(integer perm)
{
if(perm)
{
llStopAnimation("sit");
movePlatform();
}
} //end runtime permission
} //end default

You may also like...

9 Responses

  1. bigdoggt32 mubble says:

    Hi does this work if u link it to something,im looking for a elivator for my spaceship i am creating,thanks 🙂

  2. bigdoggt32 mubble says:

    i got a syntax error while trying to use this code 🙁

  3. Jade says:

    Did you forget a end curly brace? Make sure you copied everything from the blue section, this is exactly what I had in my elevator object.

  4. Ro says:

    This just doesn’t work.. you get a syntax error.
    It says the following

    (16, 15) : ERROR : Syntax error.

    Line 16 reads as
    llSay(0, “Going up!”);

    No idea what is wrong.. as I don’t do scripts myself.
    I copied everything from this page.. (cut/paste)
    It just doesn’t work.
    Suggest you check your script to ensure you haven’t left anything out.
    As this is open source I am posting this on LSLWiki to see if anyone there can resolve the problem

  5. A Scripter says:

    You’re not using plain-text quotes in the example, Jade. Replace the “ and ” symbols with plain old ” symbols.

  6. A Scripter says:

    …and your declaration of liftAmount is messed up – need another line break at line 4.

  7. Jade says:

    Yeah, sorry about that sometimes I get wonky stuff like that when I copy/paste from places on one of my laptops.

  8. codemax says:

    There is only one real error in the script. The liftAmount wasn’t declared as an integer. Should be written integer liftAmount = 4;
    or whatever the amount of distance you want the elevator to move. The other errors are because the result of copy and paste.
    I surmised it has something about the text format on this site
    I notice all the errors are associated with string errors concerning the following Linden Language functions:
    llSetSitText(“Move”);
    llStopAnimation(“sit”);
    liftAmount = 4;//how far to move up should be integer liftAmount = 4;
    llStartAnimation(“stand”);

    llSay(0, “Going up!”);

    The solution is to delete all the functions from the script inword,and to manually type them in the script. To operate the elevator t, placed yourself on the prim, right click , and select “move “from the pie chat in your view.

  9. codemax says:

    correction: Only delete the functions that are associated with strings (” “) strings that I mentioned in my last post. Then manually typed them back in the script where they belong. Below is the list of functions that should be corrected:
    llSetSitText(“Move”);
    llStopAnimation(“sit”);

    llStartAnimation(“stand”);

    llSay(0, “Going up!”);

    Also, don’t forget to correct the iiftAmount variable. It should be
    interger liftAmount = 4;

Leave a Reply