osTeleport Agent

Creating scripts
User avatar
Mykyl Nordwind
Posts: 22
Joined: Sat Dec 29, 2012 11:05 am
Has thanked: 24 times
Been thanked: 16 times

osTeleport Agent

Post by Mykyl Nordwind »

I have been wrestling with this script for a week, but I am not a great scripter and cannot figure out what is going on. It is gleaned from osgrid script resources. It seems to only work once after the object is rezzed, then nothing, and even resetting does not seem to work. I have worked with it both in Simonastick on my local machine and here in Kitely, thinking that my local machine was a bit overwhelmed by the effort. The idea is to have someone able to walk through a gate and be teleported elsewhere in the sim. The prim containing it is unlinked and not in contact with the actual gate ( you can see it inworld at http://www.kitely.com/virtual-world/Myk ... ind/Faeria right next to the landing point), and I have tried it both phantom and normal. If I make a copy (shift-drag) of the prim the copy works once too. What am I doing wrong?

Code: Select all

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 = <186, 189, 71>;  //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.
        llSetTimerEvent(1);
        llVolumeDetect( 0 );
        llVolumeDetect( 1 );
        
    }
   
    //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.
        }
    }
}
Note that I added the "llvolumedetect(0) & (1)" near the beginning as I had seen a comment about some issues with this.

Also, can anyone explain to me how to figure out the vector for "vector direction = <0,0,0>; " - how do I figure out how to make the avatar face a particular direction?

Much thanks in advance for any help with this.
These users thanked the author Mykyl Nordwind for the post:
Carlos Loff
User avatar
Marstol Nitely
Posts: 480
Joined: Mon Dec 24, 2012 1:42 am
Has thanked: 1019 times
Been thanked: 432 times

Re: osTeleport Agent

Post by Marstol Nitely »

Hi Mykyl,

I can't tell you what (if anything) you are doing wrong, but I do have a different blam on collision script that works nicely for me. If you'd like a copy, let me know and I'll drop it to you.

Not sure if this is what you're looking for, but when the script is working properly your avatar should be facing <0,0,0> when you arrive at your destination. The script I have is set to look at <1,1,1> on arrival.
Dot Macchi
Posts: 219
Joined: Sun Dec 23, 2012 12:15 pm
Has thanked: 75 times
Been thanked: 207 times

Re: osTeleport Agent

Post by Dot Macchi »

From what I've heard there's a bug in the underlying OpenSim code that requires you to avoid facing true north on arrival. So changing

Code: Select all

vector direction = <0,0,0>;             //Direction you will face when arriving
to

Code: Select all

vector direction = <1,1,1>;             //Direction you will face when arriving
could well do the trick, as Marstol suggests. That's also the case in the teleport scripts we use in the Devokan regions, whether triggered by touch or collision.
User avatar
Mykyl Nordwind
Posts: 22
Joined: Sat Dec 29, 2012 11:05 am
Has thanked: 24 times
Been thanked: 16 times

Re: osTeleport Agent

Post by Mykyl Nordwind »

Thank you, Marstol - I would love to look at another way to do this if you don't mind - perhaps a different perspective will show me what I am doing wrong here.

And thank you too, Dot - I will try that mod tomorrow and see if it makes a difference. If <0,0,0> is north, what is <1,1,1>? (South?) How do you find the other directions? (perhaps I should go look at the lsl wiki and read, funny how that often clears things up :)
User avatar
Marstol Nitely
Posts: 480
Joined: Mon Dec 24, 2012 1:42 am
Has thanked: 1019 times
Been thanked: 432 times

Re: osTeleport Agent

Post by Marstol Nitely »

It should be there next time you sign on. I seem to land facing NE, but I messed with the numbers a bit and still was facing NE. Guess I'll have to check out the wiki too. :)
Ohn Lang
Posts: 142
Joined: Sun Dec 23, 2012 5:11 pm
Has thanked: 38 times
Been thanked: 67 times

Re: osTeleport Agent

Post by Ohn Lang »

I can't go inworld right now to check, and I might be totally wrong, but I thought that last vector was the exact coordinates of where you want someone to look. like 128,128,25 would be to tell them to look at a point dead center of a region 25 meters up from the bottom. Not sure what happens when the person has camera not at default though.
User avatar
Marstol Nitely
Posts: 480
Joined: Mon Dec 24, 2012 1:42 am
Has thanked: 1019 times
Been thanked: 432 times

Re: osTeleport Agent

Post by Marstol Nitely »

Ohn Lang wrote:I can't go inworld right now to check, and I might be totally wrong, but I thought that last vector was the exact coordinates of where you want someone to look. like 128,128,25 would be to tell them to look at a point dead center of a region 25 meters up from the bottom. Not sure what happens when the person has camera not at default though.
Hi Ohn - If you say that's what it's supposed to do, I believe you. But I tried it in my single and 4x4 and was still looking NE after changing it to <128,128,25>.

P.S. Took my airship for a ride today and found my greeter NPC (who is set up near the landing point on the third floor) down on the second floor when I got back. How cool is that! :lol:
Ohn Lang
Posts: 142
Joined: Sun Dec 23, 2012 5:11 pm
Has thanked: 38 times
Been thanked: 67 times

Re: osTeleport Agent

Post by Ohn Lang »

Marstol Nitely wrote:...Hi Ohn - If you say that's what it's supposed to do, I believe you. But I tried it in my single and 4x4 and was still looking NE after changing it to <128,128,25>.
LOL. Just so you know, when I say something like "I might be totally wrong" I really do mean it, rather than to convey a false sense of modesty, :D When I can catch some time to spend inworld again, I'm going to play around with that some and see.
Marstol Nitely wrote:...P.S. Took my airship for a ride today and found my greeter NPC (who is set up near the landing point on the third floor) down on the second floor when I got back. How cool is that! :lol:
[/quote][/quote]

Haha, well, only cool if that's what you want it to do. In the script of the prim that rezzes her, search for npcPos (I think). Where ever it is first set, maybe looks something like npcPos = llGetPos() + some vector value, try changing the vector to something like <0.0,0.0,1.0>. Rezzes it up 1m above the prim. Increase that z value until she doesn't fall through the floor when she rezzes.

Later: Edited out squirly quote brackets.
These users thanked the author Ohn Lang for the post:
Marstol Nitely
User avatar
Marstol Nitely
Posts: 480
Joined: Mon Dec 24, 2012 1:42 am
Has thanked: 1019 times
Been thanked: 432 times

Re: osTeleport Agent

Post by Marstol Nitely »

Thanks Ohn. :D I did edit it a bit when I first put her up. She stays where I want her most of the time and get a kick out of it when she wanders on occasion. I might have pushed her off the edge with the airship by accident.
Ohn Lang wrote:LOL. Just so you know, when I say something like "I might be totally wrong" I really do mean it, rather than to convey a false sense of modesty, When I can catch some time to spend inworld again, I'm going to play around with that some and see.
I know I was just being falsely modest when I said I believed you. :lol:

I'll send you a copy of the script I'm using. I'm totally happy with it, so I swear I'm not asking for help (again), but in case your script does one thing and this one does something else. Dump it if you have no use for it.
These users thanked the author Marstol Nitely for the post:
Ohn Lang
Ohn Lang
Posts: 142
Joined: Sun Dec 23, 2012 5:11 pm
Has thanked: 38 times
Been thanked: 67 times

Re: osTeleport Agent

Post by Ohn Lang »

Marstol Nitely wrote:....
I know I was just being falsely modest when I said I believed you. :lol:
LMAO.

shame on you! I sprayed tea on the monitor!!!
These users thanked the author Ohn Lang for the post (total 2):
Marstol NitelyAdagio Greenwood
Post Reply