Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Making an elevator useable to all?

Tetrae Turner
Registered User
Join date: 14 Sep 2005
Posts: 36
02-13-2008 20:43
Hi all. I have an object I have set to rise and fall at the press of a button. It works fine when I do it, but I'd like it to be publicly useable. Any suggestions on what change I need to make in the script?
Below is the elevator script, followed by the control button script.
---------------------------


vector door_offset = <0,0,2>; // distance to move from start popsition(closed) to open.

float steps = 14.0; // number of steps to take to get there

// Variables
vector closed;
vector opened;

// Functions
moveit(vector target)
{
vector offset = (target - llGetPos()) / steps;
while ( llVecDist(llGetPos(), target) > 0.1 )
{
llSetPos(llGetPos() + offset);
}
llSetPos(target);
llSleep(1);
llStopSound();
}

// States

default
{
state_entry()
{
closed = llGetPos();
opened = closed + door_offset;
llSay(0, "Reset!";);
state close;
}

on_rez(integer n)
{
llResetScript();
}
}

state close
{
state_entry()
{
moveit(closed);
llListen(90902, "", NULL_KEY, "";);
}

on_rez(integer n)
{
llResetScript();
}

listen(integer chan, string name, key id, string msg)
{
if ( msg == "sesame" && llGetOwnerKey(id) == llGetOwner() )
{
state open;
}
else if ( msg == "reset" && id == llGetOwner() )
{
llResetScript();
}
}
}

state open
{
state_entry()
{
moveit(opened);
llListen(90902, "", NULL_KEY, "";);
}

on_rez(integer n)
{
llResetScript();
}

listen(integer chan, string name, key id, string msg)
{
if ( msg == "sesame" && llGetOwnerKey(id) == llGetOwner() )
{
state close;
}
else if ( msg == "reset" && id == llGetOwner() )
{
llResetScript();
}
}
}

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

default
{
touch_start(integer total_number)
{
if( llGetOwner() == llDetectedKey(0) )
{
llShout(90902, "sesame";);
}
}
}
Zolen Giano
Free the Shmeats!
Join date: 31 Dec 2007
Posts: 146
02-13-2008 21:07
Change the following lines of code:
if ( msg == "sesame" && llGetOwnerKey(id) == llGetOwner() )


Take out the bits that say:

&& llGetOwnerKey(id) == llGetOwner()



The code should look like this:

if ( msg == "sesame" )


- Cheers!
Zolen Giano
Free the Shmeats!
Join date: 31 Dec 2007
Posts: 146
02-13-2008 21:09
And your control script will look like this:



default
{
touch_start(integer total_number)
{
llShout(90902, "sesame";);

}
}
Tetrae Turner
Registered User
Join date: 14 Sep 2005
Posts: 36
02-13-2008 21:56
My hero. Thanks!
Dioxide DeSantis
Registered User
Join date: 2 Feb 2007
Posts: 63
03-13-2008 09:44
This script works great but if I am standing on the platform and move it it just passes though me on its way to the desired location.

If I start to walk on it while its moving there seems to be no issue. But I have to do this to go up and down. Is there any way to get this to make anyone standing on the platform go up without having to briefly walk on the platform as its going up?

Thanks