GridTalk.de
Teleport-Script mit Menue - Druckversion

+- GridTalk.de (https://www.gridtalk.de)
+-- Forum: Werkstatt (https://www.gridtalk.de/forumdisplay.php?fid=4)
+--- Forum: Scripting (https://www.gridtalk.de/forumdisplay.php?fid=23)
+--- Thema: Teleport-Script mit Menue (/showthread.php?tid=1708)



Teleport-Script mit Menue - Uwe Furse - 01.08.2015

Das Script:

PHP-Code:
// 12/01/08 List command doesn't work. Useless anyways hehe!
string  _notecard = "hyperjumps";
key avatar;

integer chatChannel = 212;
integer channel=155;
string HELP_MSG = "Wuuschhhhhhhhhh ...";


list    
_teleporterURLs;
list    
_teleporterStatons;
list    
theStatons;

integer _linenum = 0;
integer curStatonOffset = 0;
integer statonChunk = 6;
integer curStatonEnd = 5;
integer totalStatons = 0;
integer dialogActive = 0;
integer curIdx  = -1;
string dispStatonStr = "";

string NEXT_MSG = "Next >>";
string PREV_MSG = "<< Prev";
string LIST_MSG = "List";

string CUR_SET  = "c";
string ALL_SET  = "a";

list 
cmdNextChunk = [">>", "next", "Next"];
list 
cmdPrevChunk = ["<<", "prev", "Prev"];
list 
cmdLsCur     = ["ls", "list"];
list 
cmdLsAll     = ["la", "listall"];
list 
cmdSearch    = ["s", "search"];

string newURL;
string newDesc;

//-----------------------

reset_teleporter()
{
    
llSetText("starting teleporter....",<1,1,1>,1.0 );
    
llListen(77, "", "", "");
    
curStatonOffset = 0;
    
curStatonEnd = 5;
    
_linenum = 0;
    
dialogActive = 0;
    
_teleporterURLs = [];
    
_teleporterStatons = [];
    
totalStatons = 0;
    
curIdx = -1;
    
dispStatonStr = "";
    
llGetNotecardLine(_notecard, _linenum);
}

add_staton(string line)
{
  
//  list words = llParseString2List(line, [" ", " ", "="], []);
    
list words = llParseString2List(line, ["="], []);
    if (
llGetListLength(words) < 2)
    {
        return;
    }
    
string url = llList2String(words, llGetListLength(words) - 1);
    
string staton = "";
    
integer i;

    for (
i=0; i<llGetListLength(words) - 1; i++)
    {
        if (
llStringLength(staton) > 0)
        {
            
staton += " ";
        }
        
staton += llList2String(words, i);
    }

    
_teleporterURLs += [url];
    
_teleporterStatons += [staton];
}


curStatons()
{
    
theStatons = [PREV_MSG, LIST_MSG, NEXT_MSG];

    
integer i;
    
dispStatonStr = "";

    for (
i = curStatonOffset; i <= curStatonEnd; i++)
    {
        if (
curIdx == i)
        {
            
dispStatonStr += "*";
        } else {
                
dispStatonStr += "  ";
        }
        
dispStatonStr += (string) (i + 1) + ") ";
        
dispStatonStr += llList2String(_teleporterStatons, i);
        
dispStatonStr += "\n";

        
theStatons += (string)(i + 1);
    }
}


doNextSet()
{
    
curStatonOffset += statonChunk;
    
curStatonEnd = curStatonOffset + (statonChunk - 1);

    if (
curStatonOffset >= totalStatons)
    {
        
curStatonOffset = 0;
        
curStatonEnd = curStatonOffset + (statonChunk - 1);
    }

    if (
curStatonEnd >= totalStatons)
    {
        
curStatonEnd = totalStatons - 1;
    }
}


doPrevSet()
{
    if (
curStatonOffset > 1  && ((curStatonOffset - statonChunk) < 1))
    {
        
curStatonOffset = 0;
    } else {
            
curStatonOffset -= statonChunk;
    }

    
curStatonEnd = curStatonOffset + (statonChunk - 1);

    if (
curStatonEnd >= totalStatons)
    {
        
curStatonEnd = totalStatons - 1;
    }

    if (
curStatonOffset < 0)
    {
        
curStatonEnd = totalStatons - 1;
        
curStatonOffset = totalStatons - (statonChunk - 1);
    }
}

doListStatons(string mode)
{
    
integer i;
    
integer startPos;
    
integer endPos;

    if (
mode == "a")
    {
        
startPos = 0;
        
endPos = totalStatons - 1;
    }
    else
    {
            
startPos = curStatonOffset;
        
endPos = curStatonEnd;
    }

    for (
i = startPos; i <= endPos; i++)
    {
        
string newURL = llList2String(_teleporterURLs, i);
        
string newDesc = llList2String(_teleporterStatons, i);
         
//llSay(0, (string)(i + 1) + ": " + newDesc + " = " + newURL);
    
}
}


doSearch(list theTerms)
{
    
integer i;
    
string thePhrase = llToLower(llDumpList2String(theTerms, " "));
    
llSay(0, "the term is " + thePhrase);

    for (
i = 0; i < totalStatons; i++)
    {
        
string curString = llList2String(_teleporterStatons, i);
        if (
llSubStringIndex(llToLower(curString), thePhrase) != -1)
        {
            
string newURL = llList2String(_teleporterURLs, i);
            
llSay(0, (string)(i + 1) + ": " + curString + " = " + newURL);
        }
    }
}

//-----------------------

default
{
  
state_entry()  //on_rez(integer start_param)
   
{
       
reset_teleporter();
    }




    
dataserver(key query_id, string data)
    {
        if (
data != EOF)
        {
            
add_staton(data);
            
_linenum++;

            if (
_linenum % 3 == 0)
            {
                
llSetText("starting: \n" + (string)_linenum + " statons ...",
                    <
1,1,1>,1.0 );
            }
            
llGetNotecardLine(_notecard, _linenum);
            return;
        }
        
llListen(channel, "", NULL_KEY, "");

        
totalStatons = llGetListLength(_teleporterURLs);
        
llSay(0, HELP_MSG);
        
dialogActive = 1;
        
llSetText("SoA 2015 - Teleporter", <1,1,1>, 1.0 );
    }

    
touch_start(integer touchNumber)
    {

         
curStatons();

       
llDialog(llDetectedKey(0),
           
dispStatonStr,
           
theStatons, channel);
    
avatar = llDetectedKey(0);
      }

    
listen(integer channel, string name, key id, string message)
    {

        if (
dialogActive == 0)
        {
            
llWhisper(0, " ... still loading statons ...");
            return;
        }

        if (
message == "")
        {
            
message = "cur";
        }


    
//    list words = llParseString2List(message, [" ", "="], []);
       
list words = llParseString2List(message, [" ", " ", "="], []);
         list 
testFind = llList2List(words, 0, 0);

        if (
llListFindList(cmdNextChunk, testFind) != -1)
        {
            
doNextSet();
            
curStatons();
            if (
channel == chatChannel)
            {
                
doListStatons(CUR_SET);
            }
            else
            {
                    
llDialog(id, dispStatonStr,theStatons, channel);
            }
            return;
        }

        else if (
llListFindList(cmdPrevChunk, testFind) != -1)
        {
            
doPrevSet();
            
curStatons();
            if (
channel == chatChannel)
            {
                
doListStatons(CUR_SET);
            }
            else
            {
                    
llDialog(id, dispStatonStr, theStatons, channel);
            }
            return;
        }

        else if (
llListFindList(cmdSearch, testFind) != -1)
        {
            
doSearch(llList2List(words, 1, -1));
            return;
        }

        else if (
llListFindList(cmdLsAll, testFind) != -1)
        {
            
doListStatons(ALL_SET);
            return;
        }


        else if (
llListFindList(cmdLsCur, testFind) != -1)
        {
            
doListStatons(CUR_SET);
            return;
        }


        else if ((integer)
message > 0 && (integer)message < 256)
        {

             
curIdx = (integer)message - 1;

            
string newURL = llList2String(_teleporterURLs, curIdx);
           
// string newDesc = llList2String(_teleporterStatons, curIdx);
vector LookAt = <1,1,1>;

    
integer u= llSubStringIndex(newURL, "<");
integer v=llStringLength(newURL);
newDesc=llGetSubString(newURL,0,u-1);
newURL=llGetSubString(newURL,u,v);
 
// llSay(0, newDesc);


  //llSay(0, newURL);


     
vector dings =(vector)newURL;
    
osTeleportAgent(avatar, newDesc, dings, LookAt);
       
// llMapDestination(newDesc,dings, LookAt);
          
llResetScript(); // llSetParcelMusicURL(newURL);
        
}
    }
} 

Beispiel-Notecard für hyperjumps:


PHP-Code:
menue-punkt1=region1<125, 203, 22)>
menue-punkt2=region2<37, 19, 22)> 


Das Script läuft stabil ! Für Event-Regionen, die Channel anpassen.


RE: Teleport-Script mit Menue - Gubbly - 01.08.2015

Ich würde das auf fehlendes vertrauen in die Technik schließen. Das sehe ich auch sehr oft im RL.
Man traut dem drahtlosen Autoschlüssel nicht, dass das Auto zu ist, man zieht nochmal an der Tür.
Wenn man es normal zuschließt, macht man dies nicht.

Hier ist es halt, das es nicht ausreicht zu wissen das ein Script neu gestartet wird. Man muss sichergehen und es doppelt machen.


RE: Teleport-Script mit Menue - Gubbly - 01.08.2015

Jedesmal wenn ich OpenSim im Debugger habe, und auf die Region teleporte, darf ich 3 exceptions wegklicken die von llResetScript ausgelöst wurden.
Woran es genau liegt kann ich aber nicht sagen, hab ich mir nicht genau angeschaut ^^
Scheint aber ein Tieferes Problem zu sein das man nicht mal eben so weg patchen kann.