Change font size
It is currently Thu Mar 22, 2018 1:24 am

Forum rules


Post a new topicPost a reply Page 1 of 1   [ 1 post ]
Author Message
 Post subject: New Teleport Script
PostPosted: Tue May 26, 2009 11:08 am 
User avatar

Joined: Wed Feb 25, 2009 4:59 pm
Posts: 38
Location: Mishawaka, IN
Sometimes with teleport scripts, if you're using collision_start to trigger the teleport, lag might cause delay before the teleport occurs. During this time, you could collide multiple times with the scripted object, resulting in multiple teleports going off every few seconds. This new script below is designed to prevent that problem, by refusing to teleport an agent if one teleport was already triggered within the last 3 seconds.

Here's how it works:
When an avatar collides with the script, it checks a list to see if that avatar's UUID is already present. If not, the UUID is added and a countdown starts. At the same time, it sends a linked message to itself to trigger a teleport. As well, a timer event runs once per second. It checks if the countdown for the avatar (stored in another list) is greater than or equal to 3. If so it will remove the avatar UUID and its countdown from the list. If not, it will increment the countdown and check each second. By using a list, this will allow for multiple avatars to use the teleporter at once.

Three values near the top of the list (region, position, direction) control where the avatar is teleported. If the region value is left blank, the avatar is teleported to a location within the same sim.

list agents = [];   //List of agent UUID's who have walked into portal
list times = [];    //List of the times at which an agent first walked into portal

                                        //Modify these values to set your destination
vector destination = <128, 149, 1012>;  //Arrival Coordinates
vector direction = <0,0,0>;             //Direction you will face when arriving
string region = "";                     //Region you will teleport to.  Leave blank to TP to location in same region.

default {
    state_entry() {
        //Setting timer event.  Will check each second to see if timeout for teleport blocking on each agent has been lifted.
    //Teleport agent when message is received.
    link_message(integer sender_num, integer i, string str, key id) {
        //If more than 2 seconds have passed since the message was received, TP will not activate.
        if (((integer)(str)) - llGetTime() < 2) {
            //Checks if a region is specified.
            if (region == "") {
                //No region specified, teleporting agent to location within the same region.
                osTeleportAgent(llList2Key(agents, i), destination, direction);
            } else {
                //A region was specified, teleporting agent to location within indicated region.
                osTeleportAgent(llList2Key(agents, i), region, destination, direction);         
    //Checks each second to see if timeout has been reached.
    timer() {
        integer i = 0;
        //Abort if list length is equal to zero
        if (llGetListLength(agents) > 0) {
            for (i = 0; i < llGetListLength(agents); i++) {
                //Checking if it has been 3 seconds or more since agent was teleported.
                if(llList2Integer(times, i) >= 3) {
                    //Removing agent UUID from list
                    agents = llDeleteSubList(agents, i, i);
                    //Removing time of collision from list
                    times = llDeleteSubList(times, i, i);
                } else {
                    times = llListReplaceList(times, [(llList2Integer(times, i) + 1)], i, i);
    collision_start(integer num) {
        integer i = 0;
        integer discard = FALSE;    //If set to true, will not add agent UUID to list
        key agent = llDetectedKey(0);
        //Check to see if agent UUID is already in the list, but will skip the check if the list's length is zero
        if (llGetListLength(agents) > 0) {
            for (i = 0; i < llGetListLength(agents); i++) {
                if (llList2Key(agents, i) == agent) {
                    discard = TRUE;       //Agent UUID is in the list, will not add.
        if (discard == FALSE) {
            agents = agents + [agent];          //Adding Agent UUID to the list
            times = times + [0];      //Adding time of Agent collision with portal to list
            llMessageLinked(LINK_THIS, (llGetListLength(agents) - 1), (string)llGetTime(), agent);    //Sending message to activate teleport.

I'm a geek and proud of it. I do dungeons & dragons, linux, opensimulator, etc. I also build desktop computers when paid to do so.

Display posts from previous:  Sort by  
Post a new topicPost a reply Page 1 of 1   [ 1 post ]

Who is online

Users browsing this forum: No registered users and 4 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
610nm Style by Daniel St. Jules of