Jump to content

Notecard reader to menu


Tattooshop
 Share

You are about to reply to a thread that has been inactive for 1133 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Take a very good look at the tutorial on setting up a notecard reader for creating configuration parameters at http://wiki.secondlife.com/wiki/Read_Note_Card_Configuration .  As you look through it, understand that it is reading a single string (data) and passing it through filters to be sure that it is in a readable form and, ultimately, to see whether it contains subunits of information (name and value) within it.  It stops short of saying what to do with the information.  In your case, you want to load the information into global lists, so for example

lAllNames += [name];    // where lAllNames is your global list and you are adding each new name to it as is is read.

Then it's a matter of taking that list, later, and searching it for a specific name that you might be interested in.  You do that with llListFindList.  I recommend reading examples in the wiki entry for that function, as well as studying the longer wiki article on lists, at http://wiki.secondlife.com/wiki/Category:LSL_List .  Once you understand how LSL handles lists, you will have unlocked a powerful tool for storing, retrieving, and sorting information.  

EDIT:  Aha!  I just noticed that you found the Generic Whitelist script that I put in the LSL Library a few years ago.  So,  you've already seen exactly how llListFindList can be used to look for a match between a name and a previously created whitelist.  Look at the line that says

integer idx = llListFindList(gWhiteList,[llDetectedName(0)]);
Edited by Rolig Loon
  • Like 1
  • Thanks 1
Link to comment
Share on other sites

just a quicky example, however you prolly don't need a NC unless you have large amounts of data? easier to use a list in the script.


key query_id;
integer count;
string Curr;
key kQuery;
list people;

default
{
    state_entry()
    { Curr =  llGetInventoryName(INVENTORY_NOTECARD,0);
      if( Curr != "" )
      {  kQuery = llGetNotecardLine(Curr, count); 
      }
    }   
    dataserver(key query_id, string data)
    {   if (query_id == kQuery)
        {              
            if (data == EOF) 
            {  count = 0;
               llOwnerSay("DONE");
               llSay(0,"NC info : \n" + llDumpList2String( people,"\n"));
            }
            else 
            {   people += data;  
                ++count;      
                kQuery = llGetNotecardLine(Curr, count);  
             }
        } 
    }
    changed(integer change)
    {
        if (change & CHANGED_INVENTORY)         
        { llOwnerSay("The inventory has changed.");
          llResetScript();
        }
    }
}

 

  • Thanks 1
Link to comment
Share on other sites

On 11/7/2020 at 5:17 PM, Rolig Loon said:

Take a very good look at the tutorial on setting up a notecard reader for creating configuration parameters at http://wiki.secondlife.com/wiki/Read_Note_Card_Configuration .

 

On 11/7/2020 at 8:59 PM, Xiija said:

just a quicky example, however you prolly don't need a NC unless you have large amounts of data? easier to use a list in the script.

 

I thank you very much for your answers! Now everything is just perfect! :D

 

Link to comment
Share on other sites

  • 4 months later...

Something like this may be what you're looking for.

string gNotecardName = "urls";
integer gChannelToSendUrls = 0;

key gNotecardQueryId;
integer gNotecardLine;

integer gScriptReady;
integer gListenHandle;
integer gDialogChannel;

list gItemsList;
list gLabelsList;

stopListener()
{
    llListenRemove(gListenHandle);
    llSetTimerEvent(0);
}
 
default
{

    on_rez(integer sp)
    {
        llResetScript();
    }

    state_entry()
    {
        if (llGetInventoryKey(gNotecardName) == NULL_KEY)
        {
            llOwnerSay("Notecard '" + gNotecardName + "' missing or unwritten.");
            return;
        }
        gDialogChannel = (integer)(llFrand(-10000000)-10000000);
        gNotecardQueryId = llGetNotecardLine(gNotecardName, 0);
    }

    dataserver(key query_id, string data)
    {
        if (query_id == gNotecardQueryId)
        {
            if (data == EOF)
            {
                gScriptReady = TRUE;
                llOwnerSay("Ready.");
            }
            else
            {
                list itemParts = llParseString2List(data, ["|"], []);
                gLabelsList += llBase64ToString(llGetSubString(llStringToBase64(llList2String(itemParts, 0)), 0, 31));
                gItemsList += llList2String(itemParts, 1);
                ++gNotecardLine;
                if (gNotecardLine > 11)
                {
                    gScriptReady = TRUE;
                    llOwnerSay("Ready, but only with first 12 items.");
                    return;
                }
                gNotecardQueryId = llGetNotecardLine(gNotecardName, gNotecardLine);
            }
        }
    }

    touch_start(integer tn)
    {

        key clickerKey = llDetectedKey(0);

        if (!gScriptReady)
        {
            llRegionSayTo(clickerKey, 0, "Script is not ready yet, please wait.");
            return;
        }
        else if (llVecDist(llDetectedPos(0), llGetPos()) > 20)
        {
            llRegionSayTo(clickerKey, 0, "You need to come closer.");
            return;
        }

        gListenHandle = llListen(gDialogChannel, "", clickerKey, "");
        llDialog(clickerKey, "Select an option", gLabelsList, gDialogChannel);
        llSetTimerEvent(60);

    }

    listen(integer channel, string name, key id, string message)
    {
        stopListener();
        integer listPos = llListFindList(gLabelsList, (list)message);
        if (listPos != -1)
        {
            llRegionSay(gChannelToSendUrls, llList2String(gItemsList, listPos));
            return;
        }
        llRegionSayTo(id, 0, "Menu option not found, try again.");
    }

    timer()
    {
        stopListener();
    }

    changed(integer change)
    {
        if (change & CHANGED_INVENTORY)         
        {
            llResetScript();
        }
    }

}

 

Edited by panterapolnocy
  • Thanks 1
Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 1133 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...