Teleport Scripts

Moderator: OpenSim Hypergrid Managers

Post Reply
User avatar
Nalates
Member
Posts: 437
Joined: Mon Dec 22, 2008 7:50 pm

Teleport Scripts

Post by Nalates » Mon May 31, 2010 3:15 pm

In OSGrid there is an advanced teleport command not available in Second Life, osTeleportAgent().

This command has to be enabled in a SIM's INI file before it will work because of the potential for griefing.

The physics processing in OSGrid is much more collision intense than in SL. This new script for us in OSGrid handles the problem of multiple transports from a single AV collision with the device. It has a better 'de-bounce' filter than the previous version. This problem of the script registering multiple collisions from a single AV shows up as the AV teleporting then a few seconds later the system attempts to teleport the AV again. If one TP'd to another region the following tp results in an error (AV not found at the previous location) and forced logout.

The original script has particle effects. I've added a section to turn off the particles. Change the comments to use particles or not. In LSLEditor highlight the section to change to comments and press Ctrl-K or press Ctrl-L to remove the '//' comment marks.

The current destination is my work area in North Restoration. Please change that before using :)

Code: Select all

//XEngine;lsl
// UPDATED MAY-22-2010 
// working on: OpenSim 0.6.9 (Post_Fixes) 3bd2ec7-r12858 (interface version 6)

// original script by Tiffany Sicling @ OSGrid / Hypergrid Project team
// Revised extensively by WhiteStar Magic @ HyperGrid-Supply-Centre OSGrid 
// =======================================================================
// The SHENGATE sysem is a single Point to Point mechanism and therefore much simpler than any other mechanism
// it uses osTeleportAgent to accomplish this TP process
// this must be enabled in your OpenSim.ini file
//
//
// =======================================================================
// MODFIFY following Fields
string HoverTitle = "LBSA Plaza\nLocal Teleport"; // for Hovertext over Portal
//
integer DEFAULTstate = TRUE;            // TRUE = ON & Ready at Startup. FALSE = OFF @ Startup
//
vector LandingPoint = <128,130,506.5>;     		// Where you want the Avatar to arrive at
vector LookAt       = <1.0,1.0,-1.0>;           // which way you want them facing. Avoid True North at ALL times (BUG THERE IN OS CODE)
//
string TargetAddress = "North Restoration";                                 // In-Grid Teleport (Region Name as defined in region.xml OR region.ini)
//string TargetAddress = "9996,9974";                                       // In-Grid Teleport (Grid Map Locations XXXX,YYYYY)
//string TargetAddress = "first-star.dyndns.org:9000:FirstStar_Station";    //HyperGrid Example (using DNSname:Port:RegionName)
//string TargetAddress = "IPaddress:Port:RegionName";                       // Hypergrid TP are also valid (IPaddress:Port:RegionName)
//
// =======================================================================
//
// DO NOT MODIFY BELOW Unless you KNOW LSL Scripting
// =================================================
// Global variables
//list visitor_list;
float range = 1.5; // in meters
float rate = 1.0; // in seconds
string EventHorizonLoopSound = "Event Horizon Loop";                        // Sound looped while the event horizon exists
//
list LastFewAgents;
//
PerformTeleport( key AgentToTP )
{
    integer CurrentTime = llGetUnixTime();
    integer AgentIndex = llListFindList( LastFewAgents, [ AgentToTP ] );           // Is the agent we're teleporting already in the list?
    if (AgentIndex != -1)                                                          // If yes, check to make sure it's been > 5 seconds
    {
        integer PreviousTime = llList2Integer( LastFewAgents, AgentIndex+1 );      // Get the last time they were teleported
        if (PreviousTime >= (CurrentTime - 5)) return;                             // Less than five seconds ago? Exit without teleporting
        LastFewAgents = llDeleteSubList( LastFewAgents, AgentIndex, AgentIndex+1); // Delete the agent from the list
    }
    LastFewAgents += [ AgentToTP, CurrentTime ];                                   // Add the agent and current time to the list
    osTeleportAgent( AgentToTP, TargetAddress, LandingPoint, LookAt );             // Teleport agent to their target
    llSleep(1.0);
    llResetScript();
}
// PARTICLE EMMISSIONS EFFECTS
PARTICLES()
{
    // Particles Off Section
    llParticleSystem([]);        //Stop making particles
    // Particles ON Section
    //    llParticleSystem(  [
    //    PSYS_SRC_TEXTURE, llGetInventoryName(INVENTORY_TEXTURE, 0),
    //    PSYS_PART_START_SCALE, < 0.1, 0.6, 0 >,
    //    PSYS_PART_END_SCALE, < 0.1, 0.6, 0 >,
    //    PSYS_PART_START_COLOR, <.2,.2,1>,
    //    PSYS_PART_END_COLOR, <.7,.7,1>,
    //    PSYS_PART_START_ALPHA, 0.7,
    //    PSYS_PART_END_ALPHA, 0.0,
    //
    //    PSYS_SRC_BURST_PART_COUNT, 20,
    //    PSYS_SRC_BURST_RATE,  0.01,
    //    PSYS_PART_MAX_AGE, 1.3,
    //    PSYS_SRC_MAX_AGE, 0.0,
    //
    //    PSYS_SRC_PATTERN, 4,    // 1=DROP, 2=EXPLODE, 4=ANGLE, 8=ANGLE_CONE,
    //    PSYS_SRC_ACCEL, <0.0,0.0,0.0>,
    //
    //    PSYS_SRC_BURST_RADIUS, 1.8,
    //    PSYS_SRC_BURST_SPEED_MIN, 0,
    //    PSYS_SRC_BURST_SPEED_MAX, 0.00,
    //
    //    PSYS_SRC_ANGLE_BEGIN,  0.0,
    //    PSYS_SRC_ANGLE_END, 180*DEG_TO_RAD,
    //    PSYS_SRC_OMEGA, <0,0,0>,
    //
    //    PSYS_SRC_TARGET_KEY,  llGetKey(),    //llGetLinkKey(llGetLinkNum() + 1),
    //
    //    PSYS_PART_FLAGS, ( 0
    //    | PSYS_PART_INTERP_COLOR_MASK
    //    | PSYS_PART_INTERP_SCALE_MASK
    //    | PSYS_PART_EMISSIVE_MASK
    //    | PSYS_PART_FOLLOW_VELOCITY_MASK
    //    // | PSYS_PART_WIND_MASK
    //    // | PSYS_PART_BOUNCE_MASK
    //    // | PSYS_PART_FOLLOW_SRC_MASK
    //    | PSYS_PART_TARGET_POS_MASK
    //    // | PSYS_PART_TARGET_LINEAR_MASK
    //    ) ] );
}

default
{
    on_rez(integer int)
    {
        llResetScript();
    }
    state_entry()
    {
        // run this code when entering the default state
        llParticleSystem([]);
        llStopSound();    // Turn off the loop sound
        llSetText("",<1,0,0>,1);
        //  DEFAULTS based on DEFAULTstate, TRUE = ON, FALSE = OFF on Startup
        if (DEFAULTstate) state on;
        else state off;
    }
}
state off
{
    state_entry()
    {
        // run this code when entering the default state
        llParticleSystem([]);
        llStopSound();    // Turn off the loop sound
        llSay(0, "Deactivated." );
        llSetText("Portal Inactive",<1,0,0>,1);
    }
    changed(integer change) // something changed, take action
    {
        if(change & CHANGED_OWNER)
        {
            llOwnerSay("Owner Changed, Resetting Script");
            llResetScript();
        }
        else if (change & 256) // that bit is set during a region restart
        {
            llResetScript();
        }
    }
    touch_start(integer num_detected)
    {
        state on;        // when touched, switch to state named 'on'
    }
}
state on
{
    state_entry()
    {
        PARTICLES();
        llLoopSound( EventHorizonLoopSound, 0.5 );    // Start the sound looping
        llWhisper(0,"Activated.");
        llSetText("Walk here to\nteleport to "+HoverTitle,<1,0,0>,1);
    }
    //
    touch_start(integer num_detected)
    {
        state off;        // when touched, switch to the OFF state
    }
    //
    collision_start(integer total_number)  // total_number is the number of avatars detected.
    {
        llWhisper(0, "Teleporting to "+HoverTitle );
        PerformTeleport( llDetectedKey( 0 ));
    }
    //
    changed(integer change) // something changed, take action
    {
        if(change & CHANGED_OWNER)
        {
            llOwnerSay("Owner Changed, Resetting Script");
            llResetScript();
        }
        else if (change & 256) // that bit is set during a region restart
        {
            llResetScript();
        }
    }
}
Nalates
GoW, GoMa and GoA apprentice - Guildmaster GoC - SL = Nalates Urriah

User avatar
Dot
Member
Posts: 222
Joined: Sat Dec 13, 2008 7:42 am

Re: Teleport Scripts

Post by Dot » Tue Jun 01, 2010 8:55 am

Thanks, Nalates!

Post Reply

Return to “Modeling, Animation and Programming”

Who is online

Users browsing this forum: No registered users and 1 guest