Jump to content

Starting a reader


Braun Ulrik
 Share

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

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

Recommended Posts

I have been learning lots from reading topics on the forums. I have also been starting my new project with the help of the lsl portal on notecard readers. I have minimally modified the example script for llGetNotecardLine and come up with this:

 

key color;
integer myLine = 0;
default
{
    state_entry ()  //when script starts
    {
        llSay(0, "Reading notecard");
        color = llGetNotecardLine("Color", myLine); //read notecard
    }
    dataserver (key query_id, string data)
    {
        if (query_id == color)  //was I called to read the notecard?
        {
            if (data == EOF)    //if there are no more lines to read
            {
                llSay(0, "Read " + (string) myLine + " lines.");
            }
            else    //else there are still lines to read
            {
                llSay(0, "Line " + (string) myLine + ": " + data);
                myLine ++;
                color = llGetNotecardLine("Color", myLine);
            }
        }
    }
}

 

Now that I fully understand the entire code, I want to be able to put a touch_start on it so that I can just click the object and it will display the results. At the moment it only reads the card and displays what's in the notecard once. I need help on figuring out where to put the touch_start in it to read it whenever I click it. Any help would be greatly appreciated.

Link to comment
Share on other sites

The frist notecardline gets called for in state_entry(). The others are read and called for in the dataserver event.

As you do´t realy need state_entry you can just replace the line:

          state_entry() //when script starts

with:

          touch_end(integer num)  // when object has been touched. 

 

Or you can use touch_start()





Link to comment
Share on other sites

Haha! Just as I post that, I figured that the end of the script is basically where it has the if (data == EOF) because that means there are no more lines to read. So I just put a reset script at the end of that if statement and it works just the way I hoped it to. Thanks for the touch help again.

Link to comment
Share on other sites

Well, that's actually a cumbersome way to handle things.  Reading a notecard is slow.  There's a delay of 0.1 seconds every time your script reads a line.  If your card has any length at all, that delay adds up, so you don't want to read the card more than once if you can get away with it.  Unless it's a really long card, therefore, just save the lines in a global list that you can parrot back or search later when you need it.  For example, if you stored every line as it was read into a list named gTextLines, you could spit them back in a touch_start event with

 

touch_start(integer num){    llSay(0, llDumpList2String(gTextLines," \n ");}

 

 

       

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4606 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...