Jump to content

Reading 2 Notecards, Line 0 Borked


Bloodsong Termagant
 Share

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

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

Recommended Posts

heyas, guys!

 

i'm doing a biped/quad swapping AO, and i'm using 2 notecards... the biped and the quad.  so i'm reading first one, then the other.  it's all good, except when it switches to the 2nd notecard, line 0 always returns... actually, i'm not sure, but this is what the debug says (the period at the end is a string added to the end of the notecard line report):

Quote

 Could not recognize token on line 0: 


i couldnt find this by matching three spaces to index 0, so it could be tabs or something?  i dunno.  it doesn't really matter, it's clearly borked.  it looks like something stuck in its craw from the end of file of notecard 1?  

but i couldn't find a way to clear it.

it's definitely NOT reading line 0 of notecard 2 at all.  it just skips to line 1.

 

okay, so the code.  you may recognize this from the franimation/zhao/tao2 animation overriders.

my loadNotecard() function:

loadNoteCard() 
{
    if(0 == MODE)  Notecard = NCb;
    else if (1 == MODE)  Notecard = NCq;
    else { llOwnerSay("Error: exceeded number of notecards to read."); return; }
    
    if ( llGetInventoryKey(Notecard) == NULL_KEY ) 
    {
        llOwnerSay( "Notecard '" + Notecard + "' does not exist, or does not have full permissions.  ");
        
        return;
    }

    llOwnerSay( "Loading notecard '" + Notecard + "'.  Please wait...." );

    // Faster events while processing our notecard
    llMinEventDelay( 0.0 );

    // Start reading the data
    notecardIndex = 0;
    notecardLineKey = llGetNotecardLine( Notecard, notecardIndex );
}

the mondo data server event:

    dataserver( key _query_id, string _data )
    {
        if ( _query_id != notecardLineKey )
        { //--just leave it, it might be for another script.  just not us.  move along.
           // llOwnerSay( "Error in reading notecard. Please try again." );
            return;
        }

        if ( _data == EOF || _data == "---END---")
        {
            // Now the read ends when we hit EOF

            llOwnerSay( "Finished reading notecard '" + Notecard + "'." );
            
            MODE++;
            if(MODE <= 1) loadNoteCard();
            else //--done with both cards
            {
                MODE = 0; //--start biped
                state running;
            }
        }
        // We ignore blank lines and lines which start with a #
        if (( _data == EMPTY ) || ( llGetSubString(_data, 0, 0) == "#" ))
        {
            notecardLineKey = llGetNotecardLine( Notecard, ++notecardIndex );
            return;
        }
        
        // Check for a valid token
        integer i;
        integer found = FALSE;
        for ( i=0; i<numOverrides; i++ )
        {
            string token = llList2String( tokens, i );
            // We have some blank entries in 'tokens' to get it to line up with animState... make
            // sure we don't match on a blank.
            if (( token != EMPTY ) && ( llGetSubString( _data, 0, llStringLength(token) - 1 ) == token ))
            {
                // We found a token on this line, so we don't have to throw an error or keep
                // trying to match tokens
                found = TRUE;
                // Make sure the line has data after the token, or our sub-string calculation goes off        
                if ( _data != token )
                {
                    string animPart = llGetSubString( _data, llStringLength(token), -1 );           

                     //DW
                  //-- but FIRST!  is it the ground sit list?
                      if(0 == i) //--0 is ground sit index
                      {  //--this is only ever what's on that notecard line.  no adding. no merging.  just it.
                          Gsits = llParseString2List(animPart, [SEPARATOR], []);
                          nGsits = llGetListLength(Gsits);
                          integer j;
                        for ( j=0; j<nGsits; j++ )
                        {
                            checkAnimInInventory( llList2String(Gsits,j) );
                        }  
                          llOwnerSay((string)nGsits+" Ground Sits registered.");
                         jump done; //--can we return here?  i hope.  no wait...
                      }
                      
                    // See if this is a token for which we allow multiple animations
                   else if ( llListFindList( multiAnimTokenIndexes, [i] ) != -1 )
                    {
                        list anims2Add = llParseString2List(animPart, [SEPARATOR], [] );
                        // Make sure the anims exist
                        integer j;
                        for ( j=0; j<llGetListLength(anims2Add); j++ )
                        {//llOwnerSay("checking anim #"+(string)j);
                            checkAnimInInventory( llList2String(anims2Add,j) );
                        }
                        
                        addToOverride(i, anims2Add);

                     }
                     else
                     {
                        // This is an animation for which we only allow one override
                        if ( llSubStringIndex( animPart, SEPARATOR ) != -1 )
                        {
                            llOwnerSay( "Cannot have multiple entries for " + token + ".   If you are trying to play multiple animations at once, separate them with commas.");
                            return;
                        }

                        // Inventory check
                        checkAnimInInventory( animPart );
                        // We're good
                        addToOverride(i, [animPart]);
                    } // End if-else for multi-anim vs. single-anim
                } // End if line has more than just a token
                
                // Break, no need to continue the search loop
                jump done;                
            } // End if token matched
        } // End search for tokens

        @done;
                
        if ( !found )
        {
            llOwnerSay( "Could not recognize token on line " + (string)notecardIndex + ": " + _data + ". ");
           // return;  //--jump down anyway
        }     
             
        // Wow, after all that, we read one line of the notecard
        notecardLineKey = llGetNotecardLine( Notecard, ++notecardIndex );
        return; 
}    

 

Edited by Bloodsong Termagant
Link to comment
Share on other sites

Something has gone wrong in this block of code for that to happen:

// Check for a valid token
        integer i;
        integer found = FALSE;
        for ( i=0; i<numOverrides; i++ )
        {
            string token = llList2String( tokens, i );
            // We have some blank entries in 'tokens' to get it to line up with animState... make
            // sure we don't match on a blank.
            if (( token != EMPTY ) && ( llGetSubString( _data, 0, llStringLength(token) - 1 ) == token ))
            {
                // We found a token on this line, so we don't have to throw an error or keep
                // trying to match tokens
                found = TRUE;
                

You should probably post a copy of the notecard(s) you're trying to read to help debug further.

Link to comment
Share on other sites

I expect you have the name of the second notecard wrong in your script. The token you're script seems to not recognise (your first quote) looks a lot like an EOF; three newlines together which is what LSL uses to represent the End Of a File.

ETA: Sorry, skimmed and didn't see the fact that it does indeed read you second notecard past line 0, ignore me :P

Edited by Quistess Alpha
Link to comment
Share on other sites

Seems to me the EOF condition for the first notecard will increment MODE to 1 and call the loadNoteCard user function but won't return from the dataserver event, so that EOF _data will go through the rest of the logic and eventually throw that error message.

I'm not sure what would silently consume the 0th line of the 2nd notecard, though. May need some more debugging output in dataserver to track that one down.

  • Like 1
Link to comment
Share on other sites

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