Thursday, November 20, 2008
USERLOGIN PASSWORD Remember?
You are here » Learning Center ยป Forums

Openlife Forums

 Openlife Grid Forums
Minimize
 
  Openlife Forums  Scripting  Openlife LSL Ex...  Newest Teleport System
Previous Previous
 
Next Next
New Post 8/24/2008 6:55 AM
Online now... Osiris
52 posts
Openlife Apprentice




Newest Teleport System 
Modified By Osiris  on 11/1/2008 7:17:58 AM)

Here is my newest teleport system....

IT WAS BROUGHT TO MY ATTENTION THAT THE LAST ONE DIDNT WORK... THERE WAS A COMPILER CHANGE.  THIS ONE FIXES THAT AND ADDS A COUPLE OF FEATURES.

Its designed to read a notecard of locations in the following format:

Otherwhere Main Platform:<128,128,81>
Otherwhere Cafe:<128,216,96>
...
...
and so on...

Its probably limited to 12 entries as there is no code to extend to more dialog menus... As always this is code is contributed freely to the public domain and is "AS-IS" I am not resposnsible for any damage that it may do to your regions or avatars.

ENJOY!

----------------------------------------------------------------------------------------------------------------

//Hud for testing Gitfinger Hotspur 26/04/08
// when hud is touched it presents a dialog with choices
// 

vector targetPos = <1,1,1>; //The x, y, z coordinates to teleport.
string fltText = "Please Touch for Menu";

integer CHANNEL = 42; // dialog channel
list MENU_MAIN = []; // the main menu
list MENU_DEST = [];


string gName = "Teleport List";    // name of a notecard in the object's inventory
integer gLine = 0;        // current line number
key gQueryID; // id used to identify dataserver queries
string cardline;
integer gNoteLines;

integer noOfLines;
integer i;

key lineID;
 
reset_pad()
{
    vector target;
   
    target = (targetPos- llGetPos()) * (ZERO_ROTATION / llGetRot());
    llSitTarget(target, ZERO_ROTATION);
    llSetSitText("Teleport");
    llSetText(fltText, <1,1,1>, 1);
}

default {
   
    state_entry()
    {
       
        // gLine = 1;
       
        //gName = llGetInventoryName(INVENTORY_NOTECARD, 0); // select the first notecard in the object's inventor
       
       
        //gQueryID = (key)llGetNumberOfNotecardLines(gName);
        gNoteLines = llGetNumberOfNotecardLines(gName);
       
        //integer noOfLines = (integer)llGetNotecardLine(gName,1);
       
        llSay(0,"Loading " + (string)gNoteLines + " entries." );
       
        for(i = 1; i <= gNoteLines; i++)
        {     
            cardline = llGetNotecardLine(gName, i);
            
            // string test = llGetNotecardLine(gName,1);
            // llSay(0, test);
           
            integer p = llSubStringIndex(cardline,"|");
            integer s = llStringLength(cardline);
               
            string place = llGetSubString(cardline, 0, (p-1));
            string dest = llGetSubString(cardline, p+1, s);
           
            list place2 = llParseString2List(place,[","],[]);
            list dest2 = llParseString2List(dest,[" "],[]);
           
            MENU_MAIN = llListInsertList(MENU_MAIN, place2, 1);
            MENU_DEST = llListInsertList(MENU_DEST,  dest2, 1);
           
           llSay(0, place+":"+dest);
           
        }
              
        llListen(CHANNEL, "", NULL_KEY, ""); // listen for dialog answers (from multiple users)
         
        reset_pad();
   
    }
   

   
    dataserver(key queryid, string data)
    {
        if (queryid == gQueryID)
        {
            noOfLines = (integer)data;
           
            llSay (0,(string)noOfLines);
        }
       
        if (queryid == lineID)
        {
            cardline = data;
        }
    }
       
         
    on_rez(integer startup_param)
    {
        reset_pad();
    }
      
    changed(integer change)
    {
        if (change & 0x20)
        {
            llSleep(0.15);
            llUnSit(llAvatarOnSitTarget());
        }
    }    
   
    touch_start(integer total_number)
    {
        llDialog(llDetectedKey(0), "Where do you want to go?", MENU_MAIN, CHANNEL); // present dialog on click
    }
 
 
    listen(integer channel, string name, key id, string message)
    {
        // string response_string;
       
       
        list message2 = llParseString2List(message,[","],[]);
                  
        integer menuindex = llListFindList( MENU_MAIN, message2 );
        integer menuindex2 = llListFindList( MENU_DEST, message2 );
       
       
     if (menuindex != -1)  // verify dialog choice
        {
            string response_string = " You picked the option '" + message + "'.";
           
               
            vector targetPos = llList2Vector(MENU_DEST,menuindex);
   
            string targetString = llList2String(MENU_DEST,menuindex);
           
            fltText = "Teleport set for: " + message + " @ Position: " + targetString;
               
            vector target = (targetPos- llGetPos()) * (ZERO_ROTATION / llGetRot());
            llSitTarget(target, ZERO_ROTATION);
            llSetSitText("Teleport");
            llSetText(fltText, <1,1,1>, 1);

           
           
        }
        else
        {
            string response_string = (string)menuindex + ":" + name + " picked invalid option '" + llToLower(message) + "'.\n";
            response_string = response_string + "Click HUD for dialog of options";
           
            llSetText(response_string, <1,0,0>, 1.0);
        }
       
        // Set text to display in bright red


    }
}

 
New Post 8/24/2008 11:56 AM
User is offline Bri
7 posts
Openlife Newbie


Re: Newest Teleport System 
Modified By Bri  on 8/24/2008 11:57:03 AM)

I have noticed in OL that care must be paid to notecard scripts.

An issue can occur when making a copy for another location. If  you add or subtract locations the script may act as if it is in original configuration.

 

The Workaround:

create a new notecard in inventory with a new name then edit the call to it in your script and drag both to the prim.

Great script btw Osiris :)

 

 

 


RL..now with 100% less lag!
 
Previous Previous
 
Next Next
  Openlife Forums  Scripting  Openlife LSL Ex...  Newest Teleport System
 Popular Forum Threads
Minimize
In the past 1 week, we have 70 new thread(s) and 275 new post(s)
The most popular thread has been GLBT Region?
The most active thread has been GLBT Region?
Privacy Statement | Terms Of UseAll Rights Reserved 2007,2008 3DX - Openlifegrid.com