Change font size
It is currently Sat Feb 16, 2019 9:15 am

Forum rules


{L_IMAGE}



Post a new topicPost a reply Page 1 of 1   [ 3 posts ]
Author Message
 Post subject: Improved Linking Teleport Scripts
PostPosted: Thu Nov 20, 2014 1:49 pm 
Furious Typer

Joined: Mon Apr 22, 2013 11:41 am
Posts: 87
Location: Texas
I use these to transport around my sim. The basic idea is that my teleport network updates itself automatically to take into account newly added destinations.

So, I create a disk, and change it's description to the name of the location, for example "Library". I then put the "check pad" and "teleporter" scripts into it. When I walk onto the pad a menu pops up listing all the destinations. The key here is that every time I add a new pad the entire network updates and the new destination appears in the menus of every other teleporter. I don't have to edit each individual one or however most people do it.

I never did get deleting pads to work right in automatically removing them from the menus, so I have a hidden "reset switch" object that forces all pads to resync and get a new listing with only the active telporters.

The scripts:

Check Pad
{L_CODE}:
default
{
    collision_start(integer num_detected)
    {
        llMessageLinked(LINK_ROOT,1,"yes",llDetectedKey(0));
        llSetLinkPrimitiveParams(LINK_ALL_OTHERS, [PRIM_FULLBRIGHT,ALL_SIDES,TRUE,PRIM_GLOW,ALL_SIDES,0.05]);
        llSetTimerEvent(1);
    }

    collision_end(integer num_detected)
    {
        llMessageLinked(LINK_ROOT,0,"no",NULL_KEY);
        llSetLinkPrimitiveParams(LINK_SET, [PRIM_FULLBRIGHT,ALL_SIDES,FALSE,PRIM_GLOW,ALL_SIDES,0.0]);
        llResetScript();
    }
}


Teleport Script
{L_CODE}:
integer exchange = -275639;
integer raised = FALSE;
integer padID;
list menuChoices = ["-"];
string dialogInfo;
key ToucherID = NULL_KEY;
integer channelDialog;
integer listenID;

list ListUnique( list lAll ) {
    integer i;
    list lFiltered = llList2List(lAll, 0, 0);
    integer iAll = llGetListLength( lAll );
    for (i = 1; i < iAll; ++i) {
        if ( llListFindList(lFiltered, llList2List(lAll, i, i) ) == -1 ) {
            lFiltered += llList2List(lAll, i, i);
        }
    }
    return lFiltered;
}

integer strIsDecimal(string str)
{
    str = llStringTrim(str, STRING_TRIM);
   
    integer strLen = llStringLength(str);
    if(!strLen){return FALSE;}
   
    integer i;
    if(llGetSubString(str,0,0) == "-" && strLen > 1)
        i = 1;
    else
        i = 0;

    integer decimalPointFlag = FALSE;
   
    for(; i < strLen; i++)
    {
        string currentChar = llGetSubString(str, i, i);
       
        if(currentChar == ".") {
            if(decimalPointFlag)
                return FALSE;
            else
                decimalPointFlag = TRUE;
        }
        else if(currentChar != "3" && currentChar != "6" && currentChar != "9" &&
                currentChar != "2" && currentChar != "5" && currentChar != "8" &&
                currentChar != "1" && currentChar != "4" && currentChar != "7" && currentChar != "0")
            return FALSE;
    }
   
    return TRUE;
}

integer strIsVector(string str)
{
    str = llStringTrim(str, STRING_TRIM);
   
    if(llGetSubString(str, 0, 0) != "<" || llGetSubString(str, -1, -1) != ">")
        return FALSE;
   
    integer commaIndex = llSubStringIndex(str, ",");
   
    if(commaIndex == -1 || commaIndex == 1)
        return FALSE;
       
    if( !strIsDecimal(llGetSubString(str, 1, commaIndex - 1)) || llGetSubString(str, commaIndex - 1, commaIndex - 1) == " " )
        return FALSE;
   
    str = llDeleteSubString(str, 1, commaIndex);

    commaIndex = llSubStringIndex(str, ",");
   
    if(commaIndex == -1 || commaIndex == 1 || commaIndex == llStringLength(str) - 2 ||
       !strIsDecimal(llGetSubString(str, 1, commaIndex - 1)) || llGetSubString(str, commaIndex - 1, commaIndex - 1) == " " ||
       !strIsDecimal(llGetSubString(str, commaIndex + 1, -2)) ||  llGetSubString(str, -2, -2) == " ")
        return FALSE;
       
    return TRUE;
}

getMenu() {
        llRegionSay(exchange,"sound off");
}

default
{
    changed(integer change)
  {
    if(change & CHANGED_OWNER)
      llResetScript();
    else if (change & 256)
      llResetScript();
  }
    state_entry()
    {   
        llSetTouchText( "Teleport" );
        channelDialog = -1 - (integer)("0x" + llGetSubString( (string)llGetKey(), -7, -1) );
        getMenu();
        llListen(exchange, "", "", "");
        llSetTimerEvent(30);
    }
   
    timer() {
        getMenu();
    }
 
    listen( integer channel, string name, key id, string message )
    {
        if (channel == exchange) {
            if (message == "sound off") {
                llRegionSay(exchange,llGetObjectDesc());
            } else if (message == "resync" ) {
                llResetScript();
            } else if (message == llGetObjectDesc()) {
                vector position = llGetPos() + <0,0,1>;
                llRegionSay(exchange, (string)position);
            } else if (strIsVector(message)) {
                osTeleportAgent(ToucherID, llGetRegionName(), (vector)message, <1,1,1>);       
            } else {
                menuChoices = menuChoices + [message];
                menuChoices = ListUnique(menuChoices);
            }
           
        } else if (channel == channelDialog) {
            if (message == "-") {
                llDialog(ToucherID, llGetObjectDesc(), menuChoices, channelDialog);
            } else {
                llRegionSay(exchange,message);
            }
        }
       
    }
   
      link_message(integer sender_num, integer num, string str, key id)
      {
        ToucherID = id;
        padID = sender_num;
        getMenu();
        if (ToucherID != NULL_KEY) {
            llDialog(ToucherID, "Choose Destination:", menuChoices, channelDialog);
            listenID = llListen(channelDialog, "", ToucherID, "");
        }
        else
        {
            //llSay(0,"Stand inside ring and touch to teleport.");
            raised = FALSE;
        }
      }

    touch_start(integer num_detected) {
       
        getMenu();
        if (ToucherID != NULL_KEY) {
            llDialog(ToucherID, "Choose Destination:", menuChoices, channelDialog);
            listenID = llListen(channelDialog, "", ToucherID, "");
        }
        else
        {
            llSay(0,"Stand inside ring and touch to teleport.");
            raised = FALSE;
        }
       
    }

}


Reset Switch
{L_CODE}:
integer exchange = -275639;

default
{
    state_entry()
    {
    }
   
    touch_start(integer num_detected) {
        llSay(0,"Resetting all telegates.");
        llRegionSay(exchange,"resync");
    }
}


Top
 Profile  
 
 Post subject: Re: Improved Linking Teleport Scripts
PostPosted: Fri Nov 25, 2016 1:48 pm 

Joined: Fri Nov 25, 2016 1:45 pm
Posts: 1
I know I'm a couple of years late to the conversation, so not sure if anyone will even see this, but...

I've seen a system with similar effects in SL where the lookup happened via a Google Doc. When a new pad was added to the system, its location and name were added to the table at Google. All the other pads were automatically updated. I'm not clever enough to make it work, but it might be an idea for someone who is.


Top
 Profile  
 
 Post subject: Re: Improved Linking Teleport Scripts
PostPosted: Fri Jan 27, 2017 1:59 pm 
Furious Typer
User avatar

Joined: Fri Mar 26, 2010 12:11 pm
Posts: 158
Location: Belgium / Brussels
Note the recent implementation of HTTP_BODY_MAXLENGTH in Open Simulator.

_________________
Webmaster @ digitalconcepts.free.fr & digigrids.free.fr


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


Who is online

Users browsing this forum: No registered users and 1 guest


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:  
cron


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