Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

How to teleport on touch

Kayaker Magic
low carbonated footprint
Join date: 11 Sep 2008
Posts: 109
11-30-2008 17:31
I could swear I saw a script here on how to teleport (locally) an avatar when they touch a prim, but I cannot find it now. Can someone point me to a sample? Or give me a hint about how it works. Is there some way to sit an avatar on the prim when they touch it? I know how to teleport a seated avatar.
Anti Antonelli
Deranged Toymaker
Join date: 25 Apr 2006
Posts: 1,091
11-30-2008 17:46
From: Kayaker Magic
Is there some way to sit an avatar on the prim when they touch it?

Yep, this is in the properties of the prim in the edit window - the default click action. It's normally "touch" but you can also set it to "sit", "open" or "buy".
_____________________
Designer of sensual, tasteful couple's animations - for residents who take their leisure time seriously. ;)

http://slurl.com/secondlife/Brownlee/203/110/109/

Klug Kuhn
Registered User
Join date: 7 Sep 2007
Posts: 126
11-30-2008 17:51
From: Kayaker Magic
I could swear I saw a script here on how to teleport (locally) an avatar when they touch a prim, but I cannot find it now. Can someone point me to a sample? Or give me a hint about how it works. Is there some way to sit an avatar on the prim when they touch it? I know how to teleport a seated avatar.


Check this out when you have time :) L$1 full perm script

http://www.xstreetsl.com/modules.php?name=Marketplace&file=item&ItemID=973776
Laurence Corleone
Registered User
Join date: 12 Oct 2006
Posts: 126
12-01-2008 02:58
Nothing quite like promoting your L$1 scripts so you still get a bit of cash instead of just posting the script........

The following are not my scripts but ARE sold as full perms.

Single Location....

CODE

vector destination = <128,128,3800>; // the destination coordinate
string text = "Touch To Teleport"; // optional floating text on the teleporter, input a space if not used
vector text_color = <1.0,1.0,1.0>; // the floating text's color
integer touch2sit = TRUE; // TRUE - left click to sit; FALSE - left click to touch
integer access_mode = 1; // 1 - public; 2 - owner; 3 - group;

//=================================================
posJump( vector target_position )
{// Trickery discovered by Uchi Desmoulins and Gonta Maltz. More exact value provided by Fake Fitzgerald.
llSetPrimitiveParams([PRIM_POSITION, <1.304382E+19, 1.304382E+19, 0.0>, PRIM_POSITION, target_position ]);
}
//=================================================
warpPos( vector destpos )
{ //R&D by Keknehv Psaltery, 05/25/2006; unlimited modified by Klug Kuhn 10/01/2008

// Change this safety range depends on your script memory
// The larger the range, the quicker (and less "flashes") to get to the destination, however, the more to eat up script memory.
float safety_range = 1000.0;


integer arrived = FALSE;
integer within_range = FALSE;
vector inter_pos = ZERO_VECTOR;
vector current_pos = llGetPos();
vector checking_pos = destpos;
integer jumps = 0;
list rules = [];
integer count = 0;

if (llVecDist(destpos, current_pos) <= safety_range)
{
jumps = (integer)(llVecDist(destpos, current_pos) / 10.0) + 1;
rules = [ PRIM_POSITION, destpos ]; //The start for the rules list
count = 1;
while ( ( count = count << 1 ) < jumps)
rules = (rules=[]) + rules + rules; //should tighten memory use.
llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, count) );
}
else
{
while (!arrived)
{
current_pos = llGetPos();
checking_pos = destpos;

within_range = FALSE;
while (!within_range)
{
if (llVecDist(checking_pos,current_pos) > safety_range)
{
checking_pos = <(current_pos.x + checking_pos.x) / 2.0,(current_pos.y + checking_pos.y) / 2.0,(current_pos.z + checking_pos.z) / 2.0>;
}
else
{
within_range = TRUE;

if (llVecDist(destpos, current_pos) <= safety_range)
{
jumps = (integer)(llVecDist(destpos, current_pos) / 10.0) + 1;
rules = [ PRIM_POSITION, destpos ]; //The start for the rules list
count = 1;
while ( ( count = count << 1 ) < jumps)
rules = (rules=[]) + rules + rules; //should tighten memory use.
llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, count) );

arrived = TRUE;
}
}
}

if (!arrived)
{
jumps = (integer)(llVecDist(checking_pos, current_pos) / 10.0) + 1;
rules = [ PRIM_POSITION, checking_pos ]; //The start for the rules list
count = 1;
while ( ( count = count << 1 ) < jumps)
rules = (rules=[]) + rules + rules; //should tighten memory use.
llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, count) );
}
}
}
}
//=================================================
default
{
state_entry()
{
llSitTarget(<0.0, 0.0, 0.01>, ZERO_ROTATION);
llSetText(text,text_color,1.0);
if (touch2sit)
llSetClickAction(CLICK_ACTION_SIT);
else
llSetClickAction(CLICK_ACTION_NONE);
}
changed(integer change)
{
if (change & CHANGED_LINK)
{
key user = llAvatarOnSitTarget();
if (llGetAgentSize(user) != ZERO_VECTOR)
{
integer access_granted = FALSE;
if (access_mode == 1)
access_granted = TRUE;
else if (access_mode == 2)
{
if (user == llGetOwner())
access_granted = TRUE;
else
{
llUnSit(user);
llSay(0," sorry, owner access only.");
}
}
else if (access_mode == 3)
{
if (llSameGroup(user))
access_granted = TRUE;
else
{
llUnSit(user);
llSay(0," sorry, group memeber access only.");
}
}

if (access_granted)
{
vector init_pos = llGetPos();
// warpPos(destination); // use warPos() function
posJump(destination); // use posJump() function
llUnSit(user);
llSleep(0.2);
// warpPos(init_pos); // use warPos() function
posJump(init_pos); // use posJump() function
}
}
}
}
}


Multiple locations....

CODE

string text = "Touch To Teleport"; // optional floating text on the teleporter, input a space if not used
vector text_color = <1.0,1.0,1.0>; // the floating text's color
integer access_mode = 1; // 1 - public; 2 - owner; 3 - group;

string menu_message = "Select location:"; // the message on the location selection menu

list location_list = [ // the data of the locations' name and their coordinates
"Location 1",<10,10,1000>, // 1st location, maximum of 12 locations allowed
"Location 2",<20,20,2000>, // 2nd location, maximum of 12 locations allowed
"Location 3",<30,30,3000> // *** IMPORTANT *** there is no , (comma) at the end of the last location
];

//=================================================
posJump( vector target_position )
{// Trickery discovered by Uchi Desmoulins and Gonta Maltz. More exact value provided by Fake Fitzgerald.
llSetPrimitiveParams([PRIM_POSITION, <1.304382E+19, 1.304382E+19, 0.0>, PRIM_POSITION, target_position ]);
}
//=================================================
warpPos( vector destpos )
{ //R&D by Keknehv Psaltery, 05/25/2006; unlimited modified by Klug Kuhn 10/01/2008

// Change this safety range depends on your script memory
// The larger the range, the quicker (and less "flashes") to get to the destination, however, the more to eat up script memory.
float safety_range = 1000.0;


integer arrived = FALSE;
integer within_range = FALSE;
vector inter_pos = ZERO_VECTOR;
vector current_pos = llGetPos();
vector checking_pos = destpos;
integer jumps = 0;
list rules = [];
integer count = 0;

if (llVecDist(destpos, current_pos) <= safety_range)
{
jumps = (integer)(llVecDist(destpos, current_pos) / 10.0) + 1;
rules = [ PRIM_POSITION, destpos ]; //The start for the rules list
count = 1;
while ( ( count = count << 1 ) < jumps)
rules = (rules=[]) + rules + rules; //should tighten memory use.
llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, count) );
}
else
{
while (!arrived)
{
current_pos = llGetPos();
checking_pos = destpos;

within_range = FALSE;
while (!within_range)
{
if (llVecDist(checking_pos,current_pos) > safety_range)
{
checking_pos = <(current_pos.x + checking_pos.x) / 2.0,(current_pos.y + checking_pos.y) / 2.0,(current_pos.z + checking_pos.z) / 2.0>;
}
else
{
within_range = TRUE;

if (llVecDist(destpos, current_pos) <= safety_range)
{
jumps = (integer)(llVecDist(destpos, current_pos) / 10.0) + 1;
rules = [ PRIM_POSITION, destpos ]; //The start for the rules list
count = 1;
while ( ( count = count << 1 ) < jumps)
rules = (rules=[]) + rules + rules; //should tighten memory use.
llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, count) );

arrived = TRUE;
}
}
}

if (!arrived)
{
jumps = (integer)(llVecDist(checking_pos, current_pos) / 10.0) + 1;
rules = [ PRIM_POSITION, checking_pos ]; //The start for the rules list
count = 1;
while ( ( count = count << 1 ) < jumps)
rules = (rules=[]) + rules + rules; //should tighten memory use.
llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, count) );
}
}
}
}
//=================================================
integer listen_num = -1;
vector destination = ZERO_VECTOR;
integer selected = FALSE;
default
{
state_entry()
{
llSitTarget(<0.0, 0.0, 0.01>, ZERO_ROTATION);
llSetText(text,text_color,1.0);
llSetSitText("Teleport");
}
touch_start(integer int)
{
key user = llDetectedKey(0);
integer access_granted = FALSE;
if (access_mode == 1)
access_granted = TRUE;
else if (access_mode == 2)
{
if (user == llGetOwner())
access_granted = TRUE;
else
llSay(0," sorry, owner access only.");
}
else if (access_mode == 3)
{
if (llSameGroup(user))
access_granted = TRUE;
else
llSay(0," sorry, group memeber access only.");
}

if (access_granted)
{
list button_list = [];
integer i = 0;
for (i = 0; i <= llGetListLength(location_list) - 1; i++)
{
if (i < 23)
button_list += llList2String(location_list,i);

i += 1;
}

integer menu_chan = 0 - (integer)llFrand(2147483647);
listen_num = llListen(menu_chan,"", user,"");
llDialog(user, menu_message, button_list, menu_chan);
llSetTimerEvent(60.0);
}
}
timer()
{
llListenRemove(listen_num);
llSetTimerEvent(0.0);
}
listen(integer channel, string name, key id, string message)
{
llListenRemove(listen_num);
llSetTimerEvent(0.0);
integer choice_index = llListFindList(location_list, (list)message);
if (choice_index != -1)
{
destination = llList2Vector(location_list,choice_index + 1);
selected = TRUE;
llSay(0," location [ "+message+" ] @ "+(string)((integer)destination.x)+", "+(string)((integer)destination.y)+", "+(string)((integer)destination.z)+" selected, right click > Teleport.");
}
}
changed(integer change)
{
if (change & CHANGED_LINK)
{
key user = llAvatarOnSitTarget();
if ( (!selected) && (user != NULL_KEY) )
{
llUnSit(user);
llSay(0," sorry, please touch and select location before teleport.");
}
else
{
if (llGetAgentSize(user) != ZERO_VECTOR)
{
vector init_pos = llGetPos();
warpPos(destination); // use warPos() function
// posJump(destination); // use posJump() function
llUnSit(user);
llSleep(0.2);
warpPos(init_pos); // use warPos() function
// posJump(init_pos); // use posJump() function
selected = FALSE;
}
}
}
}
}
_____________________
There are no stupid questions, just stupid people.
Kayaker Magic
low carbonated footprint
Join date: 11 Sep 2008
Posts: 109
12-01-2008 11:15
Thanks Anti! The hint that "sit-on-touch" is a property you can set in the build dialog was all I needed to get my script working just the way I wanted. Since I had debugged my script by sitting on the prim, I didn't have to change the script at all.
Kayaker Magic
low carbonated footprint
Join date: 11 Sep 2008
Posts: 109
what is posJump()?
12-03-2008 00:55
OK Laurence, you posted that teleport script with warPos, which I have seen before, and an alternate version called posJump. Where did that come from? I don't find any discussion of it elsewhere on this forum. It breaks the 10m limit on setpos, but cannot jump into another region. Why does this work in region? Where did you get this? Who is Uchi Desmoulins?
Laurence Corleone
Registered User
Join date: 12 Oct 2006
Posts: 126
12-03-2008 01:10
Like I posted earlier, neither of those are my scripts, they are just full perms, so I posted them here for you to see so you or others reading this later wouldn't have to pay to see a full perm script.

The PosJump comes from the following Wiki entry.

http://wiki.secondlife.com/wiki/PosJump
_____________________
There are no stupid questions, just stupid people.
Tyrehl Byk
Registered User
Join date: 4 Dec 2008
Posts: 24
05-08-2009 07:37
From: Laurence Corleone
Nothing quite like promoting your L$1 scripts so you still get a bit of cash instead of just posting the script........

The following are not my scripts but ARE sold as full perms.

Single Location....


Lawrence--

All the solutions to the touch-sit I've seen change the object left click to "sit on Object" That's fine, but the only problem is that there is the "show" of the chair icon when hovering over the object that spoils what I would like to be a surprise.

Is there any way to do a left-click sit without the "show" spoiler?
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
05-08-2009 14:24
From: Tyrehl Byk
Is there any way to do a left-click sit without the "show" spoiler?

nope, not unless you change it back to touch and make them use the pie menu to choose sit (which you can customize the text for)
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -