Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Teleporter script question

Bcreative Wilde
Registered User
Join date: 9 Aug 2004
Posts: 30
02-13-2007 09:13
I edited a script for a teleporter which works great accept it sets the prim the script is to all zeros on roation and well I can't put it flat on the wall because of it. I'm not sure where to begin on changing it any clues? I assume it has to do with where it says rotate_to_zero but I've been messing with it for awhile now and no luck. Any help would be great.
Thanks
Bcreative

********
integer currentDestNum = 1;
vector currentDest;
string currentDestName;
string currentDestDesc;


rotate_to_zero()
{
llSetRot(<0,0,0,0>;);
}

setDestination()
{
if (currentDestNum == 1)
{
currentDest = dest1;
currentDestName = dest1_name;
currentDestDesc = dest1_desc;
}
else if (currentDestNum == 2)
{
currentDest = dest2;
currentDestName = dest2_name;
currentDestDesc = dest2_desc;
}
else if (currentDestNum == 3)
{
currentDest = dest3;
currentDestName = dest3_name;
currentDestDesc = dest3_desc;
}
else if (currentDestNum == 4)
{
currentDest = dest4;
currentDestName = dest4_name;
currentDestDesc = dest4_desc;
}
else if (currentDestNum == 5)
{
currentDest = dest5;
currentDestName = dest5_name;
currentDestDesc = dest5_desc;
}
else if (currentDestNum == 6)
{
currentDest = dest6;
currentDestName = dest6_name;
currentDestDesc = dest6_desc;
}
else if (currentDestNum == 7)
{
currentDest = dest7;
currentDestName = dest7_name;
currentDestDesc = dest7_desc;
}
else if (currentDestNum == 8)
{
currentDest = dest8;
currentDestName = dest8_name;
currentDestDesc = dest8_desc;
}
else if (currentDestNum == 9)
{
currentDest = dest9;
currentDestName = dest9_name;
currentDestDesc = dest9_desc;
}
else if (currentDestNum == 10)
{
currentDest = dest10;
currentDestName = dest10_name;
currentDestDesc = dest10_desc;
}

vector pos = llGetPos();
vector offset = currentDest - pos;

llSitTarget(offset, ZERO_ROTATION);

string hoverText = "TELEPORT TO: "+currentDestName+"\n"+currentDestDesc+"\n\ Left Click To Change Destination\n Right Click To Teleport";
llSetText(hoverText,<0,1,0>,1);
}

default
{
state_entry()
{
rotate_to_zero();
setDestination();
llSetSitText("Teleport";);
}
on_rez(integer num)
{
llResetScript();
}
changed(integer change)
{
if (change & CHANGED_LINK)
{
if (llAvatarOnSitTarget() != NULL_KEY)
{
llMessageLinked(LINK_SET, 0, "teleporting", "";);
llUnSit(llAvatarOnSitTarget());
}
}
}
touch_start(integer total_number)
{
currentDestNum += 1;
if (currentDestNum > totalDest) currentDestNum = 1;
rotate_to_zero();
setDestination();
}
}
Travis Lambert
White dog, red collar
Join date: 3 Jun 2004
Posts: 2,819
02-13-2007 09:48
Teleporter scripts are actually a 'sit hack' script. Essentially, you 'sit' on your teleporter, and the script sets the sit position to be somewhere far away. That's how it works.

Problem is, that sit position is relative to the position of the object that holds the script. If you rotate your object, your final sit position (teleport destination) gets rotated as well.

To make the script newbie-friendly, the version you have forces the object rotation to (0,0,0,0) for you. However, there's another way of doing it, where the script automatically compensates for however the object is rotated.

Try Till Sterling's script here from the script library. It should overcome your rotation problems.

Good Luck! :)
_____________________
------------------
The Shelter

The Shelter is a non-profit recreation center for new residents, and supporters of new residents. Our goal is to provide a positive & supportive social environment for those looking for one in our overwhelming world.
Newgate Ludd
Out of Chesse Error
Join date: 8 Apr 2005
Posts: 2,103
02-13-2007 09:48
Please post using php tags, makes it much easier for every one!

To get rid of the zero rotation take out the calls to rotate_to_zero()

The code you have is rather long winded, it could be improved quite a bit using lists.
Bcreative Wilde
Registered User
Join date: 9 Aug 2004
Posts: 30
02-13-2007 10:34
Thanks Newgate your tip worked!