Jump to content

llGetNotecardLine - note card permissions


SmacemanSpiff Grau
 Share

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

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

Recommended Posts

I think I answered my own question, but am hoping for some confirmation to the contrary.  Using the data server event and llGetNotecardLine, can the note card in the object's inventory be NO MOD?  The SL wiki says "The notecard read can be no modify, or no modify/no copy.",  however,  my testing says otherwise.

http://wiki.secondlife.com/wiki/LlGetNotecardLine

When testing with my original account, the script will work fine and return the requested information.  When I send the exact same object with the exact same note card (set to no copy / no mod) to my testing alt, it returns "Notecard 'BingoWords' does not exist or has no saved data" in general chat.  When the note card is FULL PERM - it works as it should for the test account.

Before I dumb down the script to post for trouble shooting, SHOULD it be working as no copy / no mod?  Or am I just wishing way too hard for something that I've already proven is not possible?

Thanks for any insight.

 

Smace

Edited by SmacemanSpiff Grau
Link to comment
Share on other sites

Well, something in my script is causing an issue then.  I tried it with the script below and it would only read the note card if the card is full perm.  Again - this is testing after giving the objects to a second avatar.

 

(hopefully the gyazo link will work...)

I named the 5 test prims according to the note card permissions.  The object and script are all full perm in each case.   And, yes, the note card is named correctly in all objects.  I have also tried on different sims, sandboxes and my own land.

https://gyazo.com/3305b5e3680fc8a4162a8ccb32c9bd53

 

 

 

// Check for a valid existant notecard, and read it into a list
// On touch, say the total number of lines, number of lines containing data, and say each line
// Omei Qunhua  7-Jan-2013
 
string  gNotecard = "BingoWords";       // Name of notecard to be examined
key     gLineRequestID;             // Identity of expected line count dataserver event
key     gReadRequestID;             // Identity of expected data read dataserver event
integer gLineTotal;                 // The number of lines in the NC, as determined by this script
integer gLineIndex;                 // Index for data read requests
list    gDataLines;                 // List containing all data lines from notecard, excluding blank and comment lines
string  gStatus;                    // Will contain EOF when notecard reading has finished
integer notecardLine; 




default
{
    state_entry()
    {
        
    }
    
    changed(integer change)
    {
        if (change & CHANGED_INVENTORY) llResetScript();
    }
    
    dataserver(key query_id, string data) // NOTE: Each dataserver request generates a new unique ID Key
    {
        if (query_id == gLineRequestID)  // if the requested key is for the number of total lines
        {
            gLineTotal = (integer) data;           // Cast the data string to an integer to get the number of lines
            gReadRequestID = llGetNotecardLine(gNotecard, gLineIndex);      // Request a read of the first notecard line
             llOwnerSay(gNotecard + " had a total of  " + (string) gLineTotal + " lines." );
             llOwnerSay("Please stand by while the notecard is being read..." );
            
            
        }
        
        else if (query_id == gReadRequestID)  // if the requested key is for the data for a line
        {
            if (data == EOF)
            {
                integer x = 0;
                integer count = (gDataLines != [] );  
                for ( ; x < count; ++x)                    // Loop through the data list
                {
                    llOwnerSay( llList2String(gDataLines, x) );
                }
                llOwnerSay(gNotecard + " had a total of  " + (string) gLineTotal + " lines, of which " + (string) count + " contained data." );
            }
 
            else
            {
                gDataLines += data;                        // Add this data line to our global list
                // bump line number for reporting purposes and in preparation for reading next line
                ++gLineIndex;
                if (data == "" || llGetSubString(data, 0, 0) == "#")   ++gLineIndex;   // ignore blank or comment lines
                gReadRequestID = llGetNotecardLine(gNotecard, gLineIndex);
            }
        }
    }
    
    touch_start(integer total_number)
    {
        
        gDataLines = [];
        gLineIndex = 0;
        
        if (llGetInventoryKey(gNotecard) )         // Test if notecard exists and has been saved (returned key will be NULL_KEY otherwise)
        {
            gLineRequestID = llGetNumberOfNotecardLines(gNotecard);       // Kick off a request for the total number of lines that the notecard contains
        }   
        else llOwnerSay("Notecard '" + gNotecard + "' does not exist or has no saved data");
        
    }
}

 

Thanks,

 

Smace

Link to comment
Share on other sites

You don't want to use llGetInventoryKey() in touch_start because it will return NULL_KEY for non full-perm items. If you want to test for the existence of the notecard, I'd try matching INVENTORY_NOTECARD with the return value of llGetInventoryType(gNotecard) or something like that.

Link to comment
Share on other sites

Qie - THANK YOU SO MUCH!!!   I did not know that, and will most likely forget about it the next time... but I was able to put a work around in place and BINGO!

 

I put the  llGetInventoryKey()  in the state_entry to return a value.  That will save a lot of broken keyboards and mice on my side!

 

// Check for a valid existant notecard, and read it into a list
// On touch, say the total number of lines, number of lines containing data, and say each line
// Omei Qunhua  7-Jan-2013
 
string  gNotecard = "BingoWords";       // Name of notecard to be examined
key     gLineRequestID;             // Identity of expected line count dataserver event
key     gReadRequestID;             // Identity of expected data read dataserver event
integer gLineTotal;                 // The number of lines in the NC, as determined by this script
integer gLineIndex;                 // Index for data read requests
list    gDataLines;                 // List containing all data lines from notecard, excluding blank and comment lines
string  gStatus;                    // Will contain EOF when notecard reading has finished
integer notecardLine; 



integer activeCard = FALSE;

default
{
    state_entry()
    {
        if (llGetInventoryKey(gNotecard) ) activeCard = TRUE;
    }
    
    changed(integer change)
    {
        if (change & CHANGED_INVENTORY) llResetScript();
    }
    
    dataserver(key query_id, string data) // NOTE: Each dataserver request generates a new unique ID Key
    {
        if (query_id == gLineRequestID)  // if the requested key is for the number of total lines
        {
            gLineTotal = (integer) data;           // Cast the data string to an integer to get the number of lines
            gReadRequestID = llGetNotecardLine(gNotecard, gLineIndex);      // Request a read of the first notecard line
             llOwnerSay(gNotecard + " had a total of  " + (string) gLineTotal + " lines." );
             llOwnerSay("Please stand by while the notecard is being read..." );
            
            
        }
        
        else if (query_id == gReadRequestID)  // if the requested key is for the data for a line
        {
            if (data == EOF)
            {
                integer x = 0;
                integer count = (gDataLines != [] );  
                for ( ; x < count; ++x)                    // Loop through the data list
                {
                    llOwnerSay( llList2String(gDataLines, x) );
                }
                llOwnerSay(gNotecard + " had a total of  " + (string) gLineTotal + " lines, of which " + (string) count + " contained data." );
            }
 
            else
            {
                gDataLines += data;                        // Add this data line to our global list
                // bump line number for reporting purposes and in preparation for reading next line
                ++gLineIndex;
                if (data == "" || llGetSubString(data, 0, 0) == "#")   ++gLineIndex;   // ignore blank or comment lines
                gReadRequestID = llGetNotecardLine(gNotecard, gLineIndex);
            }
        }
    }
    
    touch_start(integer total_number)
    {
        
        gDataLines = [];
        gLineIndex = 0;
        
        if (activeCard)         // Test if notecard exists and has been saved (returned key will be NULL_KEY otherwise)
        {
            gLineRequestID = llGetNumberOfNotecardLines(gNotecard);       // Kick off a request for the total number of lines that the notecard contains
        }   
        else llOwnerSay("Notecard '" + gNotecard + "' does not exist or has no saved data");
        
    }
}

 

Link to comment
Share on other sites

That won't work.
The event in which llGetInventoryKey() gets called is not the problem.

According to the wiki
If name is not copy, mod, trans then the return is NULL_KEY.
Use llGetInventoryType instead of this function to verify the existence of inventory.

 

Using Qie's solution will work. 

  • Thanks 1
Link to comment
Share on other sites

1 hour ago, SmacemanSpiff Grau said:

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

Also this will eventually break the script. If the end user drops something into the inventory, the script will reset, and it won't be able to get the key of the non-fullperm notecard in state_entry again

Link to comment
Share on other sites

Ron - I tested the script before posting and it worked for me, unless I missed a step.  I didn't quite get the llGetInventoryType usage, but now I do.  My brain read the first part of Qie 's post and then filled in the rest on its own - not something new, unfortunately.  I'll take another look  to get it right.

Ruthven - thanks for the add on.  In my full script I do have the changed event to catch that exact possibility.

 

 

Edited by SmacemanSpiff Grau
  • Like 1
Link to comment
Share on other sites

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