-->

FoxSan's 3D Tools and LSL Script Repository

Tons of LSL scripts, examples and 3D tools, free for all. There are currently 207 scripts and articles in this database.

Pay To Teleport

//Pay 2 Teleport by Haplo Voss
//Greetings! Thanks be to all that helped me along the way with answers to questions!
//Without further ado... here it is!!
 
//Please pay attention to notes following script!!
 
//-------------------------
 
vector gTargetPos;
integer cost;
string desc;
string hovertext;
key agent;
key gAvatarID=NULL_KEY;
integer gReturnToStartPos=TRUE;
vector gStartPos;
integer paid = 1;
integer access=0;
integer public_access;
integer origin_access;
float elapsed;
key gID;
 
warpPos( vector destpos)
{ //R&D by Keknehv Psaltery, 05/25/2006
//Additions by Strife, Talarus Luan
//and final cleanup by Keknehv Psaltery
integer jumps = (integer)(llVecDist(destpos, llGetPos()) / 10.0) + 1;
if (jumps > 100 )
jumps = 100;
list rules = [ PRIM_POSITION, destpos ];
integer count = 1;
while ( ( count = count << 1 ) < jumps)
rules = (rules=[]) + rules + rules;
llSetPrimitiveParams( rules + llList2List( rules, (count - jumps) << 1, count) );
}
 
default
{
 
dataserver(key query_id, string desc){
list desc_list = llParseString2List(desc, [";"], []);
gTargetPos = (vector)llList2String(desc_list, 0);
cost = (integer)llList2String(desc_list, 1);
hovertext = llList2String(desc_list, 2) + "\n" +
llList2String(desc_list, 3) + "\n" +
llList2String(desc_list, 4) + "\n" +
llList2String(desc_list, 5) + "\n" +
llList2String(desc_list, 6);
public_access = (integer)llList2String(desc_list, 7);
origin_access = public_access;
}
 
money (key id, integer amount){
paid=amount;
 
if (paid < cost && public_access == 0){
llSay(0,"Sorry, but this class costs " + (string)cost + ". Full amount is required before access.");
llGiveMoney(id,paid);
llUnSit(llAvatarOnSitTarget());
}
else if (paid > cost && public_access == 0){
integer refund = paid - cost;
llSay(0,"This class only costs " + (string)cost + "! Refunding you L$" + (string)refund );
llSay(0,"Access Granted!");
llSetSitText("Teleport");
llGiveMoney(id,refund);
gID = id;
public_access = 1;
}
else if (paid != 0 && origin_access == 1){
integer refund = paid;
llSay(0,"This teleporter is public access!");
llSay(0,"Access Granted!");
llSetSitText("Teleport");
llGiveMoney(id,refund);
public_access = 1;
}
else{
llSay(0,"Access Granted!");
llSetSitText("Teleport");
gID = id;
public_access = 1;
 
}
 
}
 
on_rez(integer rez){
llResetScript();
}
 
state_entry(){
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT );
desc = llGetNotecardLine("TPInfo",0);
llSitTarget(<0,0,1>,ZERO_ROTATION);
gStartPos = llGetPos();
}
 
touch_start(integer touched){
llSetSitText("\n");
llSetText(hovertext, <0,1,0>, 1);
if (public_access == 1){llSetSitText("Teleport");}
elapsed = llGetAndResetTime();
}
touch(integer num_detected) {
if (llDetectedKey(0) == llGetOwner()){
elapsed = llGetTime();
if (elapsed > 2.0) {
llOwnerSay("Description has changed - resetting script");
llSetTimerEvent(120);
llResetScript();
}
 
}}
touch_end(integer num_detected)
{}
 
timer()
{
llSetTimerEvent(0.0);
}
 
changed(integer change){
if(change & CHANGED_LINK)
gAvatarID = llAvatarOnSitTarget();
if(public_access == 0){llSetSitText("\n");llUnSit(gAvatarID);}
if(gAvatarID != NULL_KEY & public_access == 1 & gID == gAvatarID) {
warpPos(gTargetPos);
llSleep(.25);
llUnSit(gAvatarID);
llSleep(.25);
 
if (gReturnToStartPos) {
warpPos(gStartPos);
}
if(origin_access == 0){llSetSitText("\n");public_access = 0;}
if(origin_access == 1){llSetSitText("Teleport");}
}
}
}
 
//------------------------------
 
//As you can see in the script, you will need to create a notecard called "TPInfo" (no quotes). It must contain the following information, IN THE FOLLOING ORDER.
 
//<destination vector>;price to charge;text line1;line2;line3;line4;line5;public access switch
 
//EXAMPLE:
 
//<1,2,3>;100;WELCOME!;Right Click And;Pay L$100 to;Teleport to Island!; ; ;0
 
//vector = <1,2,3>
//price = 100
//text =
//WELCOME!
//Right Click And
//Pay L$100 to
//Teleport to Island!

Teleport On Click

//  Teleport Sit Hack
//  Created by Water Rogers for IBM/Opensource
 
//  Purpose
//  --------------------------------------------------------------
//  This is a quick example of how you can make a teleporter type
//  object using the "Sit Hack".
 
//  Requirements
//  --------------------------------------------------------------
//  A single prim is all that is necessary for this example.
 
//  Usage
//  --------------------------------------------------------------
//  We set up this object to "Sit on object when left clicked" making
//  it easier on the user.  Otherwise, you could right click and chose
//  "sit" from the pie menu.
 
//  GLOBALS
//  --------------------------------------------------------------
string      g_SitText   =  "Teleport";          //  This changes the text on the pie menue when rightclicked on the object
vector      g_SitOffset =  <0.0, 0.0, 10.0>;    //  This is the sit offset, also considered the teleport location from the object
 
//  EVENTS
//  --------------------------------------------------------------
default
{
    state_entry()
    {
        //  Set up the llSitTarget() and sit text first
        llSetSitText(g_SitText);
        llSitTarget(g_SitOffset, ZERO_ROTATION);
    }
 
    changed(integer change)
    {
        key id = llAvatarOnSitTarget();
        if(change & CHANGED_LINK)
        {
            //  We detect that the avatar sat on the object, so we
            //  unsit them right away thus giving the illusion of a
            //  teleport.
 
            //  Adjust the sleep time depending on the distance of
            //  the teleport.  The further the teleport, the higher
            //  the sleep value should be.  Note that the furtherst
            //  'teleport' distance is 300 meters.
            llSleep(1);
            llUnSit(id);
        }
    }
}

Long Distance Teleporting

// Long distance teleport version 1.1
// ----------------------------------
// This script is based on other public domain free scripts, so I don't
// take credit for any of the work here.
// Bits and pieces combined by Lisbeth Cohen - plus added show/hide.
//
// The basics of the script is based on Till Sterling's simple teleport
// script, with cross sim transportation routine developed by
// Keknehv Psaltery, modified by Strife Onizuka, Talarus Luan and
// Keknehv Psaltery.
// The transportation functionality is based upon Nepenthes Ixchel's
// 1000m Menu-driven Intra-Sim Teleporter
//
// Thank you to authors who have given me permission to publish this script.
// A special thank you to Keknehv Psaltery for suggesting small improvements!
//
// Realeased as public domain - you are NOT allowed to sell it without the
// permissions of all the authors I've credited above (except those who
// may have left sl at the time)!
// Feel free to use it in freebies and to give it to your friends :-)
//
// Please do not take credit for the work of all those great authors
// mentioned above!
// If you edit the script, please do not change the lines above - thanks!
// ------------------------------------------------------------------------
 
//The target location .. change this to where you want to end up (x, y, z)
vector gTargetPos = <246, 181, 415>;
// Text for the "pie menu"
string gSitText="Teleport";
// Define channel number to listen to user commands from
integer myChannel = 123;
 
// No need to edit the global variables below
 
// Return position for tp object - no need to edit
vector gStartPos=<0,0,0>;
// Key for avatar sitting on object, if any
key gAvatarID=NULL_KEY;
// If you don't enable this the teleport object will be left at the destination.
integer gReturnToStartPos=TRUE;
 
// This routine do the actual transport
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) );
}
 
default
{
        state_entry()
        {
                // Put the teleport text in place of the Sit in the pie menu
                llSetSitText(gSitText);
                // Read the objects position so it can return to it after teleporting
                gStartPos = llGetPos();
                // Sit the avatar on the object
                llSitTarget(<0,0,1>,ZERO_ROTATION);
                // Define commands to listen for
                llListen(myChannel,"","","");
        }
 
        on_rez(integer startup_param)
        {
                llResetScript();
        }
 
        listen(integer chan, string name, key id, string cmd)
        {
                if (cmd == "show")
                {
                        llSetAlpha( 1, ALL_SIDES );
                }
                else if (cmd == "hide")
                {
                        llSetAlpha( 0, ALL_SIDES );
                }
                else if (cmd == "reset")
                {
                        llResetScript();
                }
                else if (cmd == "help")
                {
                        llSay(0, "Usage:");
                        llSay(0, "");
                        llSay(0, "show      Make teleporter visible");
                        llSay(0, "hide      Make teleporter invisible");
                        llSay(0, "reset     Resets teleporter script");
                        llSay(0, "help      This text");
                }
        }
 
        changed(integer change){
                if(change & CHANGED_LINK)
                {
                        // Find id for avatar sitting on the object
                        gAvatarID = llAvatarOnSitTarget();
                        // If someone sits on it...
                        if(gAvatarID != NULL_KEY)
                        {
                                // Move avatar to destination
                                warpPos(gTargetPos);
                                // Pause for 1 second
                                llSleep(1);
                                // Unsit avatar
                                llUnSit(gAvatarID);
                                // Wait 1 second more
                                llSleep(1);
                                // If teleporter should return to original position....
                                if (gReturnToStartPos)
                                {
                                        // ... send object to its start position
                                        warpPos(gStartPos);
                                }
                        }
                }
        }
 
}

Warp Cross Sim

//Warp Cross-Sim Teleportation
//Warp from warpPos script by Keknehv Psaltery
//Full Script by Khalek Trescothick
//This Script is classified as open-source
//Do not remove this header
vector pos;
vector my_pos;
vector g_target;
vector save;
string sim;
string dest_sim;
integer c = 92805;
integer NeedToCrossSim = FALSE;
integer near_check = FALSE;
integer target = FALSE;
llWarp2Pos( vector d )
{
        if ( d.z > 768 )
        d.z = 768;
        integer s = (integer)(llVecMag(d-llGetPos())/10)+1;
        if ( s > 100 )
        s = 100;
        integer e = (integer)( llLog( s ) / llLog( 2 ) );
        list rules = [ PRIM_POSITION, d ];
        integer i;
        for ( i = 0 ; i < e ; ++i )
        rules += rules;
        integer r = s - (integer)llPow( 2, e );
        if ( r > 0 )
        rules += llList2List( rules, 0, r * 2 + 1 );
        llSetPrimitiveParams( rules );
}
default
{
        on_rez(integer rez)
        {
                llResetScript();
        }
        state_entry()
        {
                llListen(92805, "", "", "");
                llSitTarget(<0,0,0>,ZERO_ROTATION);
        }
        dataserver(key TID, string data)
        {
                g_target += (vector)data;
                vector G2 = g_target;
                G2.z = 200;
                save = llVecNorm(G2 - llGetRegionCorner());
                if(llRound(save.y*2)>0)
                save = <127,255,200>;
                else if(llRound(save.y*2)<0)
                save = <128,0,200>;
                else if(llRound(save.x*2)>0)
                save = <255,128,200>;
                else if(llRound(save.x*2)<0)
                save = <0,128,200>;
                if(llEdgeOfWorld(llGetPos(), llVecNorm(save - llGetPos())))
                {
                        save = llVecNorm(g_target - llGetRegionCorner());
                        if(llRound(save.x*2)>0)
                        save = <255,128,200>;
                        else if(llRound(save.x*2)<0)
                        save = <0,128,200>;
                        else if(llRound(save.y*2)>0)
                        save = <128,255,200>;
                        else if(llRound(save.y*2)<0)
                        save = <128,1,200>;
                        if(llEdgeOfWorld(llGetPos(), llVecNorm(save - llGetPos())))
                        {
                                llWhisper(0,"Pinpoint Error");
                                llUnSit(llAvatarOnSitTarget());
                                llSleep(1.0);
                                llDie();
                        }
                }
                NeedToCrossSim=TRUE;
                llWarp2Pos(save);
                llMessageLinked(-1,0,"done","");
        }
        link_message(integer prim,integer chan,string m, key id)
        {
                if(m == "done")
                {
                        if(NeedToCrossSim)
                        {
                                vector P = llGetPos();
                                if(P.x==0)
                                P.x = -3;
                                else if(P.x==255)
                                P.x = 258;
                                if(P.y==0)
                                P.y = -3;
                                else if(P.y==255)
                                P.y = 258;
                                llSleep(3.5);//Needed delay so you do not crash over sim borders!
                                llSetPos(P);
                                NeedToCrossSim = FALSE;
                                llSleep(4);
                        }
                        sim = llGetRegionName();
                        if(sim != dest_sim)
                        {
                                g_target.z = 200;
                                save = llVecNorm(g_target - llGetRegionCorner());
                                if(llRound(save.y*2)>0)
                                save = <128,255,200>;
                                else if(llRound(save.y*2)<0)
                                save = <128,0,200>;
                                else if(llRound(save.x*2)>0)
                                save = <255,128,200>;
                                else if(llRound(save.x*2)<0)
                                save = <0,128,200>;
                                if(llEdgeOfWorld(llGetPos(), llVecNorm(save - llGetPos())))
                                {
                                        save = llVecNorm(g_target - llGetRegionCorner());
                                        if(llRound(save.x*2)>0)
                                        save = <255,128,200>;
                                        else if(llRound(save.x*2)<0)
                                        save = <0,128,200>;
                                        else if(llRound(save.y*2)>0)
                                        save = <128,255,200>;
                                        else if(llRound(save.y*2)<0)
                                        save = <128,0,200>;
                                }
                                NeedToCrossSim = TRUE;
                                llWarp2Pos(save);
                                llMessageLinked(-1,0,"done","");
                        }
                        else if(sim == dest_sim)
                        {
                                NeedToCrossSim = FALSE;
                                llWarp2Pos(my_pos);
                                llSay(0,"Luccyy im hoomee");
                                llUnSit(llAvatarOnSitTarget());
                                llDie();
                        }
                }
                else
                {
                        pos = g_target - llGetRegionCorner();
                }
        }
        changed(integer change)
        {
                if(change & CHANGED_REGION)
                {
                        llMessageLinked(LINK_SET, 0, "done", "");
                }
        }
        listen(integer channel,string name,key id,string message)
        {
                if(message == message)
                {
                        list d = llParseString2List(message,["*"],[]);
                        list p = llCSV2List(llList2String(d,0));
                        float x = llList2Float(p,0);
                        float y = llList2Float(p,1);
                        float z = llList2Float(p,2);
                        pos = <x,y,z>;
                        my_pos = <x,y,z>;
                        llMessageLinked(LINK_SET, 0, "bu", NULL_KEY);
                        dest_sim = llList2String(d,1);
                        if(llGetSubString(dest_sim,0,0) == " ")
                        {
                                dest_sim = llGetSubString(dest_sim,1,-1);
                        }
                        if(llGetRegionName() == dest_sim)
                        {
                                llWarp2Pos(my_pos);
                        }
                        else
                        {
                                llRequestSimulatorData(dest_sim, DATA_SIM_POS);
                        }
                }
        }
}