Hillary Davi

LSL Experience Teleporter

Recommended Posts

The first post just wanted to share some code to create an experience teleporter. If you feel you can make it better please post it here.

The variables on top

teleportme is where you want to go on the sim

textdefault is the title over head which will automatically be changed and reset 

I used and read the following articles, Please read the following to understand the code

  1. http://wiki.secondlife.com/wiki/LlAgentInExperience
  2. https://wiki.secondlife.com/wiki/LlRequestExperiencePermissions
  3. https://wiki.secondlife.com/wiki/LlGetExperienceErrorMessage
vector teleportme = <212,150,1000>;
string MyObjectName;
string textdefault = "Teleport to platform!";
//Begin code
string theerror;
integer error;
key agent;
integer type;
default
{
    state_entry()
    {
        MyObjectName = llGetObjectName();
        llVolumeDetect(TRUE);
        llSetText(textdefault, <1.0, 1.0, 1.0>, 1.0);
    }
    collision_start(integer num)
    { 
       agent = llDetectedKey(0); type = llDetectedType(0);
       if (type == (AGENT | ACTIVE) ) // 1 + 2
        {
            llRequestExperiencePermissions(agent, "");
        }   
    } 
    experience_permissions(key agent) {
            llSetText(llKey2Name(agent) + " is using the teleporter please wait...", <1.0, 1.0, 1.0>, 1.0);
            llTeleportAgent(agent, "", teleportme, teleportme);
            llSleep(1);
             llSetText(textdefault, <1.0, 1.0, 1.0>, 1.0);   
    }
    
    experience_permissions_denied(key agent, integer reason){
        string theerror = llGetExperienceErrorMessage((integer)reason);
        if(reason = XP_ERROR_THROTTLED) {
         llSleep(2);
        } else if (reason = XP_ERROR_REQUEST_PERM_TIMEOUT || reason = XP_ERROR_NOT_PERMITTED || reason = XP_ERROR_NOT_FOUND) {
             llInstantMessage(agent, "Please accept the experience or bad things may happen!"); 
            } 
        if(!llAgentInExperience(agent)) {
         llRequestExperiencePermissions(agent, "");  
         //llRequestExperiencePermissions(llDetectedKey(0), "");
        }
       
    }
    
    touch_start(integer total_number)
    {
     agent = llDetectedKey(0);  type = llDetectedType(0);
       if (type == (AGENT | ACTIVE) ) // 1 + 2
        {
            llRequestExperiencePermissions(agent, "");
        } 
    }
     
}
    

 

  • Thanks 1

Share this post


Link to post
Share on other sites
Innula Zenovka    1,784

Looks good, but one question -- why are you using the same vector, teleportme, for both the destination and the look_at vector?   In which direction does <212,150,1000> mean you should look?   

Share this post


Link to post
Share on other sites

Not sure did not look into that function deeply but I know it works. 

Edit- I remember now I think one vector is the location and the other is the offset. I set it this way because if i wanted i can make another variable and change it up quickly. Not sure it's the proper but a nice placeholder. ;)

Edit2: The other is vector look at. http://wiki.secondlife.com/wiki/LlTeleportAgent

Function: llTeleportAgent( key avatar, string landmark, vector position, vector look_at );

Edited by Hillary Davi
update

Share this post


Link to post
Share on other sites
Rolig Loon    14,282

That vector is the position that your teleportee is intended to be facing as she arrives.  It's a global vector, not local relative to the avatar. The Z component is ignored, since an avatar is always vertical. If you use the same vector for both the destination and the LookAt position, I think the default is that you end up facing east. Frankly, I've never tried doing that, but it makes sense.

Elsewhere in the script, I can't think of a situation where it's necessary to specify that an AGENT is also ACTIVE.  Certainly not in teleportation.  You could simplify the script by removing that condition.

Edited by Rolig Loon

Share this post


Link to post
Share on other sites
if(reason = XP_ERROR_THROTTLED) {
         llSleep(2);
        } else if (reason = XP_ERROR_REQUEST_PERM_TIMEOUT || reason = XP_ERROR_NOT_PERMITTED || reason = XP_ERROR_NOT_FOUND)

You're assigning (=) constants instead of evaluating (==) them. And in regards to the errors you're checking,

XP_ERROR_THROTTLED is a KVP throttle error, not a teleport throttle error. The tp throttle is in the form of a script error.

XP_ERROR_REQUEST_PERM_TIMEOUT occurs after 5 minutes of no acknowledgement from the user for perms request.

XP_ERROR_NOT_FOUND is an experience not found server error, not an agent not found error.

The most common errors to occur are XP_ERROR_NOT_PERMITTED with agents blocking or already having blocked the experience and XP_ERROR_NOT_PERMITTED_LAND where the target agent or host object is not over land that has the experience allowed.

 

        if(!llAgentInExperience(agent)) {
         llRequestExperiencePermissions(agent, "");  
         //llRequestExperiencePermissions(llDetectedKey(0), "");
        }

You shouldn't re-request perms inside the exp perms denied event or you will most likely just end up continuously triggering it regardless of the error.

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now