Difference between revisions of "Notecard Configuration Reader by Maddox Deluxe"

From Second Life Wiki
Jump to navigation Jump to search
m (<lsl> tag to <source>)
 
(127 intermediate revisions by one other user not shown)
Line 1: Line 1:
== This new update has been tested and works great ==
Read the script comments to have better understanding of the codes. [[http://youtu.be/f9hRGWNW7a4 v1.6 Video]]
{{ColorPanel
|background=#cdd
|bordercolor=#000
|Fixes in v1.6|
* Backdrop uuid now checks for NULL KEY
* Checks the notecard for saved data
* Clean up the script
}}
{{ColorPanel
{{ColorPanel
|background=#cdd
|background=#cdd
|bordercolor=#000
|bordercolor=#000
|First make a note card called (Category Theme).Fantasy and copy the data of this one into it. The 00000000-0000-0000-0000-000000000000 just means no floor drop|
|Fixes in v1.5|
* New uuid Key checking function
}}
{{ColorPanel
|background=#cdd
|bordercolor=#000
|Fixes in v1.4|
* Themes list format adding
}}
{{ColorPanel
|background=#cdd
|bordercolor=#000
|Fixes in v1.3|
* Empty notecard data error checking
* Spaces error checking
* Add few more comments to some codes
}}  
}}  
<pre>
// Our test note card
Author Name=Maddox Deluxe
// Theme [1]
Menu Button Name=Fantasy Tiger
BackDrop Texture UUID=8f304cf2-7120-24e2-d1f1-db6b31bd6f6c
FloorDrop Texture UUID=00000000-0000-0000-0000-000000000000
// Theme [2]
Menu Button Name=Fantasy Car
BackDrop Texture UUID=517b2288-67ca-b14c-1de2-c5f5fdf5291f
FloorDrop Texture UUID=00000000-0000-0000-0000-000000000000
// Theme [3]
Menu Button Name=Fantasy Tree
BackDrop Texture UUID=f6321118-cc24-6230-78a5-a257a3e33378
FloorDrop Texture UUID=00000000-0000-0000-0000-000000000000
</pre>
{{ColorPanel
{{ColorPanel
|background=#cdd
|background=#cdd
|bordercolor=#000
|bordercolor=#000
|If you like to make it faster for loading then just make it like this|
|Fixes in v1.2|
* Key names error checking
* Other fixes that are not listed
}}  
}}  
<pre>
// Optimized for faster loading
Author Name=Maddox Deluxe
Menu Button Name=Fantasy Tiger
BackDrop Texture UUID=8f304cf2-7120-24e2-d1f1-db6b31bd6f6c
FloorDrop Texture UUID=00000000-0000-0000-0000-000000000000
Menu Button Name=Fantasy Car
BackDrop Texture UUID=517b2288-67ca-b14c-1de2-c5f5fdf5291f
FloorDrop Texture UUID=00000000-0000-0000-0000-000000000000
Menu Button Name=Fantasy Tree
BackDrop Texture UUID=f6321118-cc24-6230-78a5-a257a3e33378
FloorDrop Texture UUID=00000000-0000-0000-0000-000000000000
</pre>
{{ColorPanel
{{ColorPanel
|background=#cdd
|background=#cdd
|bordercolor=#000
|bordercolor=#000
|Our main script called (CODE).Notecard.Reader|
|Useful Functions - (See main script comments)|
*very fast note card reader
* DumpListFind(list db, string name)
* integer IsElement(list db, string search)
* integer KeyNameCheck(list db, string search)
* integer isKey(key uuid)
}}  
}}  
<lsl>
 
// Notecard Configuration Reader by Maddox Deluxe
First make a notecard called (Category Theme).Fantasy and copy the data of this one into it. The 00000000-0000-0000-0000-000000000000 just means no floor drop, but holds the key format still for error checking. The notecard format can not have line spaces and need to be done just how you see the notecard settings here, the error checking works great for the script.
 
<pre>
// our test notecard
[Author Name] = Maddox Deluxe
// Theme [1]
[Menu Button Name] = Fantasy Tiger
[BackDrop Texture UUID] = 8f304cf2-7120-24e2-d1f1-db6b31bd6f6c
[FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000
// Theme [2]
[Menu Button Name] = Fantasy Car
[BackDrop Texture UUID] = 517b2288-67ca-b14c-1de2-c5f5fdf5291f
[FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000
// Theme [3]
[Menu Button Name] = Fantasy Tree
[BackDrop Texture UUID] = f6321118-cc24-6230-78a5-a257a3e33378
[FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000
</pre>
Or with out the comments.
<pre>
[Author Name] = Maddox Deluxe
[Menu Button Name] = Fantasy Tiger
[BackDrop Texture UUID] = 8f304cf2-7120-24e2-d1f1-db6b31bd6f6c
[FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000
[Menu Button Name] = Fantasy Car
[BackDrop Texture UUID] = 517b2288-67ca-b14c-1de2-c5f5fdf5291f
[FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000
[Menu Button Name] = Fantasy Tree
[BackDrop Texture UUID] = f6321118-cc24-6230-78a5-a257a3e33378
[FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000
</pre>
Our main script called (CODE).Notecard.Reader
<source lang="lsl2">
// Notecard Multi-line Entries Configuration Reader v1.6 by Maddox Deluxe
// Error Checking for: Key Names, values, Empty Notecard Data, Line Spaces
// This script is free; you can redistribute it and/or modify it
// This script is free; you can redistribute it and/or modify it
// Just read the comments on the script
// Just read the comments on the script
key NotecardQueryId;          // key name of the notecard
key LineRequestID;            // notecard line count
integer LineTotal;            // The number of lines in the notecard
integer LineIndex;            // index for data read requests
string Author_Name = "";      // variable for setting author name
string Menu_Button_Name = ""; // variable for setting menu button name to the themes list
string Back_Drop_UUID = "";  // variable for setting backdrop uuid key to the themes list
string Floor_Drop_UUID = "";  // variable for setting floor drop uuid key to the themes list


key notecardQueryId; //name key of the notecard
string data;                 // notecard data
integer line; // note card line tracker
string GetNoteName;           // notecard name  
 
// Variables
list Themes;                 // our list database for testing
string Author_Name = "";
list KeyNames;                // our list database for the key names: [Author Name]. [Menu Button Name], ect..
string Menu_Button_Name = "";
string Back_Drop_UUID = "";
integer ThemesCount;         // counts how many themes they are in the notecard configuration
string Floor_Drop_UUID = "";
string data; // note card data
key User;                     // user tracker key
string GetNoteName; // incoming note card name  
 
// function by Maddox Deluxe  
list Themes; // our list database for testing
// test to dump all 3 elements in the list that goes with each other
 
integer ThemesCount; // counts how many themes they are in the note card configuration
 
key User; // user tracker key
 
// Function by Maddox Deluxe
// test to dump all 3 elements in the list that goes with each other.
DumpListFind(list db, string name)
DumpListFind(list db, string name)
{
{
Line 78: Line 113:
         {
         {
             list Found = llList2List(db, index, index + 2);  
             list Found = llList2List(db, index, index + 2);  
           
             string BN = llList2String(Found,0);   
             string BN = llList2String(Found,0);   
             string BD = llList2String(Found,1);
             string BD = llList2String(Found,1);
             string FD = llList2String(Found,2);
             string FD = llList2String(Found,2);
           
             llOwnerSay("Dump testing for list database search.\nButton Name: "+(string)BN+ "\nBackdrop Texture: "+(string)BD+ "\nFloor drop Texture: "+(string)FD);
             llOwnerSay("Dump testing for list database search.\nAuthor Name: "+(string)Author_Name+ "\nButton Name: "+(string)BN+ "\nBackdrop Texture: "+(string)BD+ "\nFloor drop Texture: "+(string)FD);
           
     llOwnerSay("List Dump Found Test: "+llDumpList2String(Found, ","));
     llOwnerSay("List Dump Found Test: "+llDumpList2String(Found, ","));
           
   //  llMessageLinked(LINK_SET, 0,"SET BACKDROP TEXTURE",(string)BD);
   //  llMessageLinked(LINK_SET, 0,"SET BACKDROP TEXTURE",(string)BD);
             if(FD != "00000000-0000-0000-0000-000000000000")
             if(FD != (key)"00000000-0000-0000-0000-000000000000")
             {
             {
  //    llMessageLinked(LINK_SET, 0,"SET FLOOR DROP TEXTURE",(string)FD);
  //    llMessageLinked(LINK_SET, 0,"SET FLOOR DROP TEXTURE",(string)FD);
             }
             }
           
         }
         }
}
}
// Function by Maddox Deluxe
// function by Maddox Deluxe  
// looks for 3 elements and the search string is the first element of the set
// looks for 3 elements and the search string is the first element of the set
integer IsElement(list db, string search)
integer IsElement(list db, string search)
Line 103: Line 138:
         {
         {
             list Found = llList2List(db, index, index + 2);  
             list Found = llList2List(db, index, index + 2);  
           
             string i = llList2String(Found,0);   
             string str = llList2String(Found,0);   
             if (i == search)  
             if (str == search)  
             return TRUE; // was found
             return TRUE; // was found
         }
         }
         return FALSE; // was not found
         return FALSE; // was not found
}
}
// just for testing on this demo script to check keys
// function by Maddox Deluxe
integer isKey(key test)  
// checks the key names making sure they match what is setup in the notecard
integer KeyNameCheck(list db, string search)
{
{
    if (llStringLength(test) != 36)
        return FALSE;
       
    // Hyphenation test:
    if  (    (llGetSubString(test, 8, 8) != "-")
          ||  (llGetSubString(test, 13, 13) != "-")
          ||  (llGetSubString(test, 18, 18) != "-")
          ||  (llGetSubString(test, 23, 23) != "-"))
            return FALSE;
           
    // Remove dashes
    test = llDeleteSubString(llDeleteSubString(llDeleteSubString(llDeleteSubString((string)test, 8, 8), 12, 12), 16, 16), 20, 20);
    // Hex test
     integer i;
     integer i;
     for (i = 0; i < 32; i+=4)  
     for (i=0;i<llGetListLength(db);++i)
     {
     {
         string char = llGetSubString(test, i, i+3 );
         string s = llList2String(db,i);
         if ((integer)("0x"+char) == 0 && char != "0000")  
         if (s==search) return TRUE;
            return FALSE;
     }
     }
     return TRUE; // Passed all tests
     return FALSE;
}
 
// Checks the uuid keys in the notecard, making sure they are real keys
// 2 valid key, not NULL_KEY
// 1 (TRUE):  NULL_KEY
// 0 (FALSE): not a key
// https://wiki.secondlife.com/wiki/Category:LSL_Key
integer isKey(key uuid)
{
    if (uuid)
        return 2;
    return (uuid == NULL_KEY);
}
}
// note card loader
 
NoteCardInit(string GrabNoteCardName, key id) // key id could be use for dialog messages or llInstantMessages
// notecard initialization
NoteCardInit(string GrabNoteCardName, key id) // key id could be use for dialog message or llInstantMessage
{
{
  if(llGetInventoryType(GrabNoteCardName) != INVENTORY_NOTECARD)
if (llGetInventoryKey(GrabNoteCardName) == NULL_KEY) // update v1.6 with notecard null key checking
    {
  {
  llInstantMessage(id,"Theme note card was not found "+(string)GrabNoteCardName+".");
llInstantMessage(id,"Notecard '" +GrabNoteCardName+ "' (1) The notecard key is null, write some data in it and hit save. (2) Notecard was not found.");
   return;   
   return;   
     }
     }
     Themes = [];// clear the themes list
    else
     line = 0; //start reading from first line 0
    LineRequestID = llGetNumberOfNotecardLines(GrabNoteCardName); // total number of lines in the notecard
     ThemesCount = 0; // counts how many themes they are
     Themes = [];     // clear the themes list
     notecardQueryId = llGetNumberOfNotecardLines(GetNoteName);
     LineIndex = 0;   // start reading from line 0
    llInstantMessage(id,"Please stand by, reading themes configuration for " +GetNoteName);
     ThemesCount = 0; // start adding from 0
     NotecardQueryId = llGetNotecardLine(GrabNoteCardName, LineIndex);
    KeyNames = [];    // clear the keynames list
                      // setup our key names
    KeyNames = ["[author name]","[menu button name]","[backdrop texture uuid]","[floordrop texture uuid]"];
    llInstantMessage(id,"Please stand by, reading themes configuration for " +GrabNoteCardName);
    GetNoteName = GrabNoteCardName;
}
}


ProcessThemes(string data, key id) // key id could be use for dialog messages or llInstantMessages
ProcessThemes(string data, key id) // key id could be use for dialog message or llInstantMessage
{
{
list cmd;
list cmd;
string cmd_grab;
string cmd_grab;
string value;
string value;
 
//  if we are at the end of the file
//  if we are at the end of the file
    if(data == EOF)
  if(data == EOF)
     {
     {
         llInstantMessage(id,"Done reading themes configuration for "+GetNoteName+ "\n\nTotal Themes: "+(string)ThemesCount);
         llInstantMessage(id,"Done reading themes configuration for "+GetNoteName+ "\n\nTotal Themes: "+(string)ThemesCount);
         // lets use the 2nd search string for this test. The search strings are the button names in the note card configuration.
         string search_test = "Fantasy Car";
         // lets use the 2nd search string for this test, the search strings are the button names in the notecard configuration
       
         string TestSearch = "Fantasy Car";
         if(IsElement(Themes,search_test)==TRUE)
         if(IsElement(Themes,TestSearch)==FALSE)
         {
         {
           DumpListFind(Themes,search_test);
        llInstantMessage(id,"Themes Configuration Error. Button search string was not found.");
        return;
          }
        else
           DumpListFind(Themes,TestSearch);
           return;
           return;
         }
         }
         else
         if(data == "")
         return;
        {
    }
        llInstantMessage(id,"Themes Configuration Format Error. (1) No DATA found. (2) Got line spaces.");
    if(data != "")
         llResetScript();
    {
        }
          // speed is the key when scripting, I always write fast codes
        if(data != "")
 
        {
        if ( llGetSubString(data, 0, 0) != "//" && llStringTrim(data, STRING_TRIM) != "" )
            // lets move on and read the next line
        {
            NotecardQueryId = llGetNotecardLine(GetNoteName, ++LineIndex);
            integer index = llSubStringIndex(data, " ");
           
            if(~index)
            // cut off any leading blanks
            // ignore comment lines
            // if you change the comment line from // to #, make sure you change the 1 to 0
            if (llGetSubString(data, 0, 1) != "//" && llStringTrim(data, STRING_TRIM) != "" )
             {
             {
             cmd = llParseString2List(data, ["="], []);
             cmd = llParseString2List(data, ["="], []);
cmd_grab = llStringTrim(llToLower(llList2String(cmd, 0)),STRING_TRIM);
            cmd_grab = llStringTrim(llToLower(llList2String(cmd, 0)),STRING_TRIM);
value = llStringTrim(llList2String(cmd, 1), STRING_TRIM);
            value = llStringTrim(llList2String(cmd, 1), STRING_TRIM);
         
           
             // should always add block if statements for error checking
             // we only need this at the start to check for key name errors :)
 
             if(KeyNameCheck(KeyNames,cmd_grab)==FALSE)
             if(cmd_grab == "author name")
             {
             {
            llInstantMessage(id,"Themes Configuration Format Error on line: " +(string)LineIndex+ ".");
            llResetScript();
            }
            if(cmd_grab == "[author name]")
            {
             Author_Name = value;
             Author_Name = value;
             // error checking for Author Name
             // error checking for Author Name
            if(value == "")
            if(value == "")
             {
             {
            llInstantMessage(id,"Themes Configuration Error on line: " +(string)line+ ". Author Name can not be empty");
            llInstantMessage(id,"Themes Configuration Error on line: " +(string)LineIndex+ ". Author Name can not be empty.");
            return;
            llResetScript();
             }
             }
           }
           }
             else
             else
             if(cmd_grab == "menu button name")
             if(cmd_grab == "[menu button name]")
             {
             {
             Menu_Button_Name = value;
             Menu_Button_Name = value;
Line 204: Line 255:
             if(value == "")
             if(value == "")
             {
             {
             llInstantMessage(id,"Themes Configuration Error on line: " +(string)line+ ". Menu Button Name can not be empty");
             llInstantMessage(id,"Themes Configuration Error on line: " +(string)LineIndex+ ". Menu Button Name can not be empty.");
             return;
             llResetScript();
             }
             }
             }
             }
             else
             else
             if(cmd_grab == "backdrop texture uuid")
             if(cmd_grab == "[backdrop texture uuid]")
          {
            {
             Back_Drop_UUID = llToLower(value);
             Back_Drop_UUID = value;
             // error checking for BackDrop Texture UUID
             // error checking for BackDrop Texture UUID
             if(value == "" || (isKey((string)value) != TRUE))
             if(value == "" || (isKey((key)value)) == 1 || (isKey((key)value)) == 0)
             {
             {
             llInstantMessage(id,"Themes Configuration Error on line: " +(string)line+ ". (1) The Backdrop Texture UUID is empty. (2) The Backdrop UUID is not a key.");
             llInstantMessage(id,"Themes Configuration Error on line: " +(string)LineIndex+ ". (1) The Backdrop UUID Key is empty. (2) The Backdrop UUID is not a key. (3) The Backdrop UUID Key is NULL.");
             return;
             llResetScript();
            }
            }
          }
          }
            else
          else
            if(cmd_grab == "floordrop texture uuid")
          if(cmd_grab == "[floordrop texture uuid]")
             {
             {
             Floor_Drop_UUID = llToLower(value);
             Floor_Drop_UUID = value;
             // error checking for FloorDrop Texture UUID
             // error checking for FloorDrop Texture UUID
             if(value == "" || (isKey((string)value) != TRUE))
             if(value == "" || (isKey((key)value)) == 0)
             {
             {
             llInstantMessage(id,"Themes Configuration Error on line: " +(string)line+ ". (1) The Floor-drop Texture UUID is empty. (2) The Floor-drop UUID is not a key.");
             llInstantMessage(id,"Themes Configuration Error on line: " +(string)LineIndex+ ". (1) The Floor-drop UUID Key is empty. (2) The Floor-drop UUID is not a key.");
            return;
            llResetScript();
             }
             }
 
            ThemesCount = ThemesCount +1;                                  // add +1 to our themes count
// add to our test list database
            Themes += [Menu_Button_Name,Back_Drop_UUID,Floor_Drop_UUID];   // add to our themes test list database
Themes += [Menu_Button_Name,Back_Drop_UUID,Floor_Drop_UUID];
            }
ThemesCount = ThemesCount + 1; // we don't count the note lines
           }
           }
         }
         }
     }
     }  
}
    // lets move on to the next lines in our note card configuration
    ++line;
    notecardQueryId = llGetNotecardLine(GetNoteName, line);
}
// we don't need a state entry to run this script, best thing is you don't even have to reset the script at all.
 
default
default
{
{
 
link_message(integer sender_num, integer num, string str, key id)
link_message(integer sender_num, integer num, string str, key id)
{
{
Line 255: Line 298:
if(str == "LoadThemes")  
if(str == "LoadThemes")  
{
{
// loads up our test note card
// loads up our test notecard
GetNoteName = id;
NoteCardInit((string)id, User);
NoteCardInit((string)GetNoteName, User);
   }     
   }     
  }
  }
//  Triggered when task receives asynchronous data
//  triggered when task receives asynchronous data
  dataserver(key request_id, string data)
  dataserver(key request_id, string data)
   {
   {
   if(request_id == notecardQueryId)
   if(request_id == NotecardQueryId)
   {
   {
//  we start processing our notecard data
   ProcessThemes(data, User);
   ProcessThemes(data, User);
   }
   }
  }
  }
}
}
</lsl>
</source>
{{ColorPanel
Our notecard script tester called (CODE).Notecard.Tester
|background=#cdd
<source lang="lsl2">
|bordercolor=#000
|Our script that will load the note card is called (CODE).Notecard.Tester|
}}
<lsl>
// Our test script for loading the notecard
// Our test script for loading the notecard
// place this script with the main note card one and then just click the object
// place this script with the main notecard one and then just click the object
 
// our test notecard name for reading
// our test notecard name for reading
string NotecardName = "(Category Theme).Fantasy";
string NotecardName = "(Category Theme).Fantasy";
 
default
default
{
{
     state_entry()
     state_entry()
     {
     {
     
     }
     }
 
     touch_start(integer total_number)
     touch_start(integer total_number)
     {
     {
     key User = llDetectedKey(0); // sets the user key
     key User = llDetectedKey(0); // sets the user key
     // sending user key to the note card reader script
     // sending user key to the notecard reader script
     llMessageLinked(LINK_SET,0,"SetUserKey",User);
     llMessageLinked(LINK_SET,0,"SetUserKey",User);
 
     // sending the note card name to the note card reader script
     // sending the note card name to the notecard reader script
     llMessageLinked(LINK_SET,0,"LoadThemes",(string)NotecardName);
     llMessageLinked(LINK_SET,0,"LoadThemes",(string)NotecardName);
     }
     }
}
}
</lsl>
</source>
 
<pre>
<pre>
Test Run Output
Test Run Output
---------------
---------------
Dump testing for list database search.
Dump testing for list database search.
Author Name: Maddox Deluxe
Button Name: Fantasy Car
Button Name: Fantasy Car
Backdrop Texture: 517b2288-67ca-b14c-1de2-c5f5fdf5291f
Backdrop Texture: 8f304cf2-7120-24e2-d1f1-db6b31bd6f6c
Floor drop Texture: 00000000-0000-0000-0000-000000000000
Floor drop Texture: 00000000-0000-0000-0000-000000000000


List Dump Found Test: Fantasy Car,517b2288-67ca-b14c-1de2-c5f5fdf5291f,00000000-0000-0000-0000-000000000000
List Dump Found Test: Fantasy Car,8f304cf2-7120-24e2-d1f1-db6b31bd6f6c,00000000-0000-0000-0000-000000000000
</pre>
</pre>
[[Category:LSL_Library]]

Latest revision as of 19:03, 24 January 2015

This new update has been tested and works great

Read the script comments to have better understanding of the codes. [v1.6 Video]

Fixes in v1.6
  • Backdrop uuid now checks for NULL KEY
  • Checks the notecard for saved data
  • Clean up the script


Fixes in v1.5
  • New uuid Key checking function


Fixes in v1.4
  • Themes list format adding


Fixes in v1.3
  • Empty notecard data error checking
  • Spaces error checking
  • Add few more comments to some codes


Fixes in v1.2
  • Key names error checking
  • Other fixes that are not listed


Useful Functions - (See main script comments)
  • DumpListFind(list db, string name)
  • integer IsElement(list db, string search)
  • integer KeyNameCheck(list db, string search)
  • integer isKey(key uuid)


First make a notecard called (Category Theme).Fantasy and copy the data of this one into it. The 00000000-0000-0000-0000-000000000000 just means no floor drop, but holds the key format still for error checking. The notecard format can not have line spaces and need to be done just how you see the notecard settings here, the error checking works great for the script.

// our test notecard
[Author Name] = Maddox Deluxe
// Theme [1]
[Menu Button Name] = Fantasy Tiger
[BackDrop Texture UUID] = 8f304cf2-7120-24e2-d1f1-db6b31bd6f6c
[FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000
// Theme [2]
[Menu Button Name] = Fantasy Car
[BackDrop Texture UUID] = 517b2288-67ca-b14c-1de2-c5f5fdf5291f
[FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000
// Theme [3]
[Menu Button Name] = Fantasy Tree
[BackDrop Texture UUID] = f6321118-cc24-6230-78a5-a257a3e33378
[FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000

Or with out the comments.

[Author Name] = Maddox Deluxe
[Menu Button Name] = Fantasy Tiger
[BackDrop Texture UUID] = 8f304cf2-7120-24e2-d1f1-db6b31bd6f6c
[FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000
[Menu Button Name] = Fantasy Car
[BackDrop Texture UUID] = 517b2288-67ca-b14c-1de2-c5f5fdf5291f
[FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000
[Menu Button Name] = Fantasy Tree
[BackDrop Texture UUID] = f6321118-cc24-6230-78a5-a257a3e33378
[FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000

Our main script called (CODE).Notecard.Reader

// Notecard Multi-line Entries Configuration Reader v1.6 by Maddox Deluxe
// Error Checking for: Key Names, values, Empty Notecard Data, Line Spaces
// This script is free; you can redistribute it and/or modify it
// Just read the comments on the script
 
key NotecardQueryId;          // key name of the notecard
key LineRequestID;            // notecard line count
integer LineTotal;            // The number of lines in the notecard
integer LineIndex;            // index for data read requests
 
string Author_Name = "";      // variable for setting author name
string Menu_Button_Name = ""; // variable for setting menu button name to the themes list
string Back_Drop_UUID = "";   // variable for setting backdrop uuid key to the themes list
string Floor_Drop_UUID = "";  // variable for setting floor drop uuid key to the themes list

string data;                  // notecard data
string GetNoteName;           // notecard name 
 
list Themes;                  // our list database for testing
list KeyNames;                // our list database for the key names: [Author Name]. [Menu Button Name], ect..
 
integer ThemesCount;          // counts how many themes they are in the notecard configuration
 
key User;                     // user tracker key
 
// function by Maddox Deluxe    
// test to dump all 3 elements in the list that goes with each other
DumpListFind(list db, string name)
{
 integer index = llListFindList(db, [name]);
        if (~index)
        {
            list Found = llList2List(db, index, index + 2); 
 
            string BN = llList2String(Found,0);   
            string BD = llList2String(Found,1);
            string FD = llList2String(Found,2);
 
            llOwnerSay("Dump testing for list database search.\nAuthor Name: "+(string)Author_Name+ "\nButton Name: "+(string)BN+ "\nBackdrop Texture: "+(string)BD+ "\nFloor drop Texture: "+(string)FD);
 
    llOwnerSay("List Dump Found Test: "+llDumpList2String(Found, ","));
 
  //  llMessageLinked(LINK_SET, 0,"SET BACKDROP TEXTURE",(string)BD);
            if(FD != (key)"00000000-0000-0000-0000-000000000000")
            {
 //    llMessageLinked(LINK_SET, 0,"SET FLOOR DROP TEXTURE",(string)FD);
            }
 
        }
}
// function by Maddox Deluxe    
// looks for 3 elements and the search string is the first element of the set
integer IsElement(list db, string search)
{
 integer index = llListFindList(db, [search]);
        if (~index)
        {
            list Found = llList2List(db, index, index + 2); 
 
            string str = llList2String(Found,0);   
            if (str == search) 
            return TRUE; // was found
        }
        return FALSE; // was not found
 }
// function by Maddox Deluxe
// checks the key names making sure they match what is setup in the notecard 
integer KeyNameCheck(list db, string search)
{
    integer i;
    for (i=0;i<llGetListLength(db);++i)
    {
        string s = llList2String(db,i);  
        if (s==search) return TRUE;
    }
    return FALSE;
}

// Checks the uuid keys in the notecard, making sure they are real keys
// 2 valid key, not NULL_KEY
// 1 (TRUE):  NULL_KEY
// 0 (FALSE): not a key
// https://wiki.secondlife.com/wiki/Category:LSL_Key
integer isKey(key uuid)
{
    if (uuid)
        return 2;
    return (uuid == NULL_KEY);
}

// notecard initialization
NoteCardInit(string GrabNoteCardName, key id) // key id could be use for dialog message or llInstantMessage
{
 if (llGetInventoryKey(GrabNoteCardName) == NULL_KEY) // update v1.6 with notecard null key checking
  {
 llInstantMessage(id,"Notecard '" +GrabNoteCardName+ "' (1) The notecard key is null, write some data in it and hit save. (2) Notecard was not found.");
   return;   
    }
    else
    LineRequestID = llGetNumberOfNotecardLines(GrabNoteCardName); // total number of lines in the notecard
    Themes = [];      // clear the themes list
    LineIndex = 0;    // start reading from line 0
    ThemesCount = 0;  // start adding from 0
    NotecardQueryId = llGetNotecardLine(GrabNoteCardName, LineIndex);
    KeyNames = [];    // clear the keynames list
                      // setup our key names
    KeyNames = ["[author name]","[menu button name]","[backdrop texture uuid]","[floordrop texture uuid]"];
    llInstantMessage(id,"Please stand by, reading themes configuration for " +GrabNoteCardName);
    GetNoteName = GrabNoteCardName;
}

ProcessThemes(string data, key id) // key id could be use for dialog message or llInstantMessage
{
list cmd;
string cmd_grab;
string value;
 
//  if we are at the end of the file
  if(data == EOF)
    {
        llInstantMessage(id,"Done reading themes configuration for "+GetNoteName+ "\n\nTotal Themes: "+(string)ThemesCount);
 
         // lets use the 2nd search string for this test, the search strings are the button names in the notecard configuration
         string TestSearch = "Fantasy Car";
         if(IsElement(Themes,TestSearch)==FALSE)
         {
         llInstantMessage(id,"Themes Configuration Error. Button search string was not found.");
         return;
          }
         else
          DumpListFind(Themes,TestSearch);
          return;
         }
         if(data == "")
         {
         llInstantMessage(id,"Themes Configuration Format Error. (1) No DATA found. (2) Got line spaces.");
         llResetScript();
         }
         if(data != "")
         {
             // lets move on and read the next line
             NotecardQueryId = llGetNotecardLine(GetNoteName, ++LineIndex);
            
            // cut off any leading blanks
            // ignore comment lines
            // if you change the comment line from // to #, make sure you change the 1 to 0
            if (llGetSubString(data, 0, 1) != "//" && llStringTrim(data, STRING_TRIM) != "" )
            {
            cmd = llParseString2List(data, ["="], []);
            cmd_grab = llStringTrim(llToLower(llList2String(cmd, 0)),STRING_TRIM);
            value = llStringTrim(llList2String(cmd, 1), STRING_TRIM);
            
            // we only need this at the start to check for key name errors :)
            if(KeyNameCheck(KeyNames,cmd_grab)==FALSE)
            {
             llInstantMessage(id,"Themes Configuration Format Error on line: " +(string)LineIndex+ ".");
             llResetScript();
             }
             if(cmd_grab == "[author name]")
             {
             Author_Name = value;
            // error checking for Author Name
            if(value == "")
             {
            llInstantMessage(id,"Themes Configuration Error on line: " +(string)LineIndex+ ". Author Name can not be empty.");
            llResetScript();
             }
           }
            else
            if(cmd_grab == "[menu button name]")
            {
            Menu_Button_Name = value;
            // error checking for Menu Button Name
            if(value == "")
            {
             llInstantMessage(id,"Themes Configuration Error on line: " +(string)LineIndex+ ". Menu Button Name can not be empty.");
             llResetScript();
             }
            }
            else
            if(cmd_grab == "[backdrop texture uuid]")
            {
            Back_Drop_UUID = value;
            // error checking for BackDrop Texture UUID
            if(value == "" || (isKey((key)value)) == 1 || (isKey((key)value)) == 0)
            {
             llInstantMessage(id,"Themes Configuration Error on line: " +(string)LineIndex+ ". (1) The Backdrop UUID Key is empty. (2) The Backdrop UUID is not a key. (3) The Backdrop UUID Key is NULL.");
             llResetScript();
            }
          }
           else
           if(cmd_grab == "[floordrop texture uuid]")
            {
            Floor_Drop_UUID = value;
            // error checking for FloorDrop Texture UUID
            if(value == "" || (isKey((key)value)) == 0)
            {
             llInstantMessage(id,"Themes Configuration Error on line: " +(string)LineIndex+ ". (1) The Floor-drop UUID Key is empty. (2) The Floor-drop UUID is not a key.");
             llResetScript();
            }
            ThemesCount = ThemesCount +1;                                  // add +1 to our themes count
            Themes += [Menu_Button_Name,Back_Drop_UUID,Floor_Drop_UUID];   // add to our themes test list database
             }
           }
        }
    } 
default
{
 
link_message(integer sender_num, integer num, string str, key id)
{
if(str == "SetUserKey")
{
// sets up the user key that click the object
User = (key)id; 
}
if(str == "LoadThemes") 
{
// loads up our test notecard
NoteCardInit((string)id, User);
  }    
 }
//  triggered when task receives asynchronous data
 dataserver(key request_id, string data)
  {
  if(request_id ==  NotecardQueryId)
   {
//  we start processing our notecard data
   ProcessThemes(data, User);
   }
 }
}

Our notecard script tester called (CODE).Notecard.Tester

// Our test script for loading the notecard
// place this script with the main notecard one and then just click the object
 
// our test notecard name for reading
string NotecardName = "(Category Theme).Fantasy";
 
default
{
    state_entry()
    {
 
    }
 
    touch_start(integer total_number)
    {
    key User = llDetectedKey(0); // sets the user key
    // sending user key to the notecard reader script
    llMessageLinked(LINK_SET,0,"SetUserKey",User);
 
    // sending the note card name to the notecard reader script
    llMessageLinked(LINK_SET,0,"LoadThemes",(string)NotecardName);
    }
}
Test Run Output
---------------
Dump testing for list database search.
Author Name: Maddox Deluxe
Button Name: Fantasy Car
Backdrop Texture: 8f304cf2-7120-24e2-d1f1-db6b31bd6f6c
Floor drop Texture: 00000000-0000-0000-0000-000000000000

List Dump Found Test: Fantasy Car,8f304cf2-7120-24e2-d1f1-db6b31bd6f6c,00000000-0000-0000-0000-000000000000