Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Short Range Teleport?

AzKay Devanter
Registered User
Join date: 10 Aug 2006
Posts: 16
08-24-2006 09:21
Okay, Im wanting to make a short range teleporter. Ive found this script.
CODE

vector targetPos = <26,169,-10>; //The target location

reset()
{
vector target;

target = (targetPos- llGetPos()) * (ZERO_ROTATION / llGetRot());
llSitTarget(target, ZERO_ROTATION);
llSetSitText(llGetObjectName());
}
default
{
state_entry()
{
reset();
}

on_rez(integer startup_param)
{
reset();
}

changed(integer change)
{
llUnSit(llAvatarOnSitTarget());
reset();
}
}

Okay, I see the top, which has the coodinates to teleport to. But, how would I make it, so, it teleports, from my position? Like, instead of having it set, something like, x,y,x are always at my position, so, if ive the object attached, it would always have my position, so, I could set it as <mypos,mypos,50> so, it would always teleport to the Z 10 meter point. Did that make sense?
Kayla Stonecutter
Scripting Oncalupen
Join date: 9 Sep 2005
Posts: 224
08-24-2006 13:03
That type of teleporter requires you to sit on it to work, and you can't sit on attachments so it won't work as you want it.
_____________________
AzKay Devanter
Registered User
Join date: 10 Aug 2006
Posts: 16
08-24-2006 14:41
Any suggestions?
Hoshi Kiama
Registered User
Join date: 9 May 2006
Posts: 15
08-24-2006 15:05
There's something in the LSL Wiki that you may want to look at which also links to a related forum thread:

http://secondlife.com/badgeo/wakka.php?wakka=LibraryWarpPos
AzKay Devanter
Registered User
Join date: 10 Aug 2006
Posts: 16
08-24-2006 23:40
From: Hoshi Kiama
There's something in the LSL Wiki that you may want to look at which also links to a related forum thread:

http://secondlife.com/badgeo/wakka.php?wakka=LibraryWarpPos

Yeah, I read about that. I try this:
CODE

default
{
warpPos( vector destpos )
{ //R&D by Keknehv Psaltery, 05/25/2006
//with a little pokeing by Strife, and a bit more
//some more munging by Talarus Luan
//Final cleanup by Keknehv Psaltery
// Compute the number of jumps necessary
integer jumps = (integer)(llVecDist(destpos, llGetPos()) / 10.0) + 1;
// Try and avoid stack/heap collisions
if (jumps > 100 )
jumps = 100; // 1km should be plenty
list rules = [ PRIM_POSITION, destpos ]; //The start for the rules list
integer count = 1;
while ( ( count = count << 1 ) < jumps)
rules = (rules=[]) + rules + rules; //should tighten memory use.
llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, count) );
}
touch_start(integer total_number)
{
warpPos(<207,93,610>);
}

}

Syntax error @ 2,4. Well, Seeing as im trying to "learn" LSL, Someone mind pointing out what I did wrong?
Kayla Stonecutter
Scripting Oncalupen
Join date: 9 Sep 2005
Posts: 224
08-25-2006 00:34
First of all, you need to put the warpPos part before the default state, as it's a function. Second, this won't work for an attachment either, warpPos is made for you to sit on the object, then it very quickly moves it to another location. To move an avatar with an attachment, you need to look at either llApplyImpulse(), or llMoveToTarget() and llStopMoveToTarget(). Note: If you edit a script in an attachment with llMoveToTarget(), the function will not work until you detach and reattach the object.
_____________________
AzKay Devanter
Registered User
Join date: 10 Aug 2006
Posts: 16
08-25-2006 00:40
Hmm, Okay, I tryed putting that in the front of the script, but the same error.
And, The basic reason I was posting this, was about,
When I say the command or whatever, It will check my position, and then teleport to my position + 10 x,y or z.
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
08-25-2006 00:55
You're sending a user function call with warpPos();, but you've not defined the function. That would have to go above the default line, global variables and user defined functions go up there.
_____________________
Eloise's MiniMall
Visit Eloise's Minimall
New, smaller footprint, same great materials.

Check out the new blog
Kayla Stonecutter
Scripting Oncalupen
Join date: 9 Sep 2005
Posts: 224
08-25-2006 01:01
Here you go, simple avatar offsetter using llMoveToTarget(). Note though, that you can't to through prims like this, so it won't work to get to another level of a building.
CODE
vector      Offset = <0,0,10>;

vector Target;
integer TargetNum;

default
{
touch_start(integer total_number)
{
Target = llGetPos() + Offset; //Sets the target var to your current position + Offset
TargetNum = llTarget(Target, 0.1); //Activates the target so the script knows when it gets there
llMoveToTarget(Target, 0.1); //Starts the move
llSetTimerEvent(2); //sets a timer incase movement is blocked (won't reach target then)
}

at_target(integer targetnum, vector targetpos, vector pos)
{
llStopMoveToTarget();
llTargetRemove(TargetNum);
llSetTimerEvent(0);
}

timer()
{
llStopMoveToTarget();
llTargetRemove(TargetNum);
llSetTimerEvent(0);
}
}
_____________________
AzKay Devanter
Registered User
Join date: 10 Aug 2006
Posts: 16
08-25-2006 01:20
Thanks ^^
Argent Stonecutter
Emergency Mustelid
Join date: 20 Sep 2005
Posts: 20,263
Open source sit-teleport script...
08-25-2006 07:45
You can get a copy of my open source teleport script from my store in LostFurest dAlliez or in the Coonspiracy Store (check my picks), or from anyone who already has a copy if you want to save the token price. It's good up to 512 meters, but you can't get further than that with this scheme.