Difference between revisions of "User:Toy Wylie/RLV Documentation/tpto"

From Second Life Wiki
Jump to navigation Jump to search
(first draft, source code missing)
 
(added source code, fixed syntax)
 
Line 1: Line 1:
{{Template:RLV_Documentation/Command
{{Template:RLV_Documentation/Command
|command=@tpto|type=General
|command=@tpto|type=General
|usage=@tpto:x/y/z=force
|usage=@tpto:<location>=force
|purpose=Teleports the user to the destination immediately, without questions. @tploc=n and @unsit=n will block this attempt. The x,y and z coordinates are in grid coordinates, so you need to calculate them first before attempting to teleport the user anywhere.
|purpose=Teleports the user to the destination immediately, without questions. @tploc=n and @unsit=n will block this attempt. The location format is:
* X/Y/Z
The X, Y and Z coordinates are in grid coordinates, so you need to calculate them from the region coordinates first before attempting to teleport the user anywhere.
|version=1.12
|version=1.12
|seealso=tplure tplure_sec tploc tplm
|seealso=tplure tplure_sec tploc tplm
|seealsoalso=
|seealsoalso=
|example=To Be Done
|example=<lsl>// simple example with a fixed, pre-calculated destination
 
default
{
    state_entry()
    {
        llOwnerSay("Touch this box to teleport to Toy's Toys.");
    }
 
    touch_start(integer num)
    {
        if(llDetectedKey(0)==llGetOwner())
        {
            llOwnerSay("@tpto:179068/254564/24=force");
        }
    }
}
</lsl>
|example_2=<lsl>// a more complex example to teleport to any location on the grid
 
integer listener;
integer channel;
 
key regionRequest;
 
string location;
vector position;
 
removeListener()
{
    if(listener!=0)
    {
        llListenRemove(listener);
        listener=0;
    }
    llSetTimerEvent(0.0);
}
 
init()
{
    listener=0;
    regionRequest=NULL_KEY;
    llOwnerSay("Touch this box to set your teleport location.");
}
 
default
{
    on_rez(integer num)
    {
        llResetScript();
    }
 
    state_entry()
    {
        init();
    }
 
    touch_start(integer num)
    {
        if(llDetectedKey(0)!=llGetOwner())
            return;
 
        if(location!="")
        {
            llOwnerSay("@tpto:"+location+"=force");
            init();
            return;
        }
 
        if(listener!=0)
        {
            llOwnerSay("We are still waiting for a location to be teleported to.");
            return;
        }
 
        if(regionRequest!=NULL_KEY)
        {
            llOwnerSay("We are still waiting for the region data to arrive.");
            return;
        }
 
        channel=(integer) (llFrand(100)+10);
        listener=llListen(channel,"",llDetectedKey(0),"");
        llSetTimerEvent(30.0);
 
        llOwnerSay("Please say your teleport location on channel "+(string) channel+" within the next 30 seconds. For example: /"+(string) channel+" Mode/124/100/24");
    }
 
    listen(integer channel,string name,key sender,string message)
    {
        list params=llParseString2List(message,["/"],[]);
        if(llGetListLength(params)!=4)
        {
            llOwnerSay("Please make sure to say your destination in the following format: Region/X/Y/Z where X, Y and Z are the coordinates in the region you want to teleport to.");
            return;
        }
 
        removeListener();
 
        position.x=llList2Float(params,1);
        position.y=llList2Float(params,2);
        position.z=llList2Float(params,3);
 
        string region=llList2String(params,0);
        regionRequest=llRequestSimulatorData(region,DATA_SIM_POS);
    }
 
    dataserver(key k,string data)
    {
        if(k==regionRequest)
        {
            regionRequest=NULL_KEY;
            if(data=="" || data==EOF)
            {
                llOwnerSay("Could not request region data. Please try again.");
                return;
            }
            data=(string) ((vector) data+position);
            list params=llParseString2List(data,["<",","," ",">"],[]);
            location=llDumpList2String(params,"/");
            llOwnerSay("Location set. Touch the prim to teleport.");
        }
    }
 
    timer()
    {
        removeListener();
        llOwnerSay("Listener timeout. Please touch this box again to start over.");
    }
}
</lsl>
}}
}}

Latest revision as of 03:42, 9 July 2010


@tpto

Type

General

Implemented

Implemented since RLV version 1.12

Usage

@tpto:<location>=force

Purpose

Teleports the user to the destination immediately, without questions. @tploc=n and @unsit=n will block this attempt. The location format is:
  • X/Y/Z
The X, Y and Z coordinates are in grid coordinates, so you need to calculate them from the region coordinates first before attempting to teleport the user anywhere.


Example 1

<lsl>// simple example with a fixed, pre-calculated destination

default {

   state_entry()
   {
       llOwnerSay("Touch this box to teleport to Toy's Toys.");
   }
   touch_start(integer num)
   {
       if(llDetectedKey(0)==llGetOwner())
       {
           llOwnerSay("@tpto:179068/254564/24=force");
       }
   }

}

</lsl>

Example 2

<lsl>// a more complex example to teleport to any location on the grid

integer listener; integer channel;

key regionRequest;

string location; vector position;

removeListener() {

   if(listener!=0)
   {
       llListenRemove(listener);
       listener=0;
   }
   llSetTimerEvent(0.0);

}

init() {

   listener=0;
   regionRequest=NULL_KEY;
   llOwnerSay("Touch this box to set your teleport location.");

}

default {

   on_rez(integer num)
   {
       llResetScript();
   }
   state_entry()
   {
       init();
   }
   touch_start(integer num)
   {
       if(llDetectedKey(0)!=llGetOwner())
           return;
       if(location!="")
       {
           llOwnerSay("@tpto:"+location+"=force");
           init();
           return;
       }
       if(listener!=0)
       {
           llOwnerSay("We are still waiting for a location to be teleported to.");
           return;
       }
       if(regionRequest!=NULL_KEY)
       {
           llOwnerSay("We are still waiting for the region data to arrive.");
           return;
       }
       channel=(integer) (llFrand(100)+10);
       listener=llListen(channel,"",llDetectedKey(0),"");
       llSetTimerEvent(30.0);
       llOwnerSay("Please say your teleport location on channel "+(string) channel+" within the next 30 seconds. For example: /"+(string) channel+" Mode/124/100/24");
   }
   listen(integer channel,string name,key sender,string message)
   {
       list params=llParseString2List(message,["/"],[]);
       if(llGetListLength(params)!=4)
       {
           llOwnerSay("Please make sure to say your destination in the following format: Region/X/Y/Z where X, Y and Z are the coordinates in the region you want to teleport to.");
           return;
       }
       removeListener();
       position.x=llList2Float(params,1);
       position.y=llList2Float(params,2);
       position.z=llList2Float(params,3);
       string region=llList2String(params,0);
       regionRequest=llRequestSimulatorData(region,DATA_SIM_POS);
   }
   dataserver(key k,string data)
   {
       if(k==regionRequest)
       {
           regionRequest=NULL_KEY;
if(data==""