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.
}
}
}
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.