Talk:Notecard Configuration Reader by Maddox Deluxe
Suggestions
Hello Maddox
You might find this code easier for validating a key:
<lsl> integer isKey(string test) {
if ( (key) test) return TRUE; return FALSE;
} </lsl>
That's all you need to do. There's no need for the detailed inspection you have coded in your isKey() function.
You start your notecard reading by requesting the number of notecard lines - but you never use this information, in fact it appears that you will attempt to process the returned number of lines as if it were line #0 of the notecard itself, and you'll never process the true contents of line 0. In your application, I see no reason to request the number of lines. Just start by requesting a read of line #0.
Your IsElement() function is intended, I think, to ensure that a found texture name occurred at an index that was a multiple of 3. But it doesn't do so at all. Once the code passes the <lsl> if (~index) </lsl> test, it's bound to return TRUE.
Try this:-
<lsl> integer IsElement(list db, string search) {
integer index = llListFindList(db, [search]); if ( ! (index % 3 ) )
return TRUE; // was found on a stride boundary
return FALSE; // was not found
} </lsl>
Your code <lsl>
++line; notecardQueryId = llGetNotecardLine(GetNoteName, line);
</lsl> would be better placed up where you have put the comment: // speed is the key when scripting, ... At present your code will stall on the first error encountered, as it will not go on to read the next notecard line, and will never reach EOF.
Why ask the user to code a full null key where no texture is desired? Why not look for a simpler specific string such as NONE?
I could go on, but that's enough ... except to say: do indent your code properly. You may find the offline tool lslEditor useful for this, as it has an auto-indent feature.
Omei Qunhua 02:05, 22 April 2014 (PDT)
Well Omei, there is many ways to code things and everyone has their own style, but this script works just how it was made to. It has been tested many ways for error checking with the notecard format. I made it from on going project of my, the demo script just shows how you could handle themes UUID keys and using list for them. The "Error Checking" is 100% good.
All you got to do is run the test scripts and you will see they work fine. The format notecard was not made to handle spaces, the comment lines works just fine as long you keep each line right under each other.
This will work.
// Comment 1 [Author Name] = Maddox Deluxe // Comment 2 [Menu Button Name] = Fantasy Tiger // Comment 3 [BackDrop Texture UUID] = 8f304cf2-7120-24e2-d1f1-db6b31bd6f6c // Comment 4 [FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000 // Comment 5 [Menu Button Name] = Fantasy Car // Comment 6 [BackDrop Texture UUID] = 517b2288-67ca-b14c-1de2-c5f5fdf5291f // Comment 7 [FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000 // Comment 8 [Menu Button Name] = Fantasy Tree // Comment 9 [BackDrop Texture UUID] = f6321118-cc24-6230-78a5-a257a3e33378 // Comment 10 [FloorDrop Texture UUID] = 00000000-0000-0000-0000-000000000000
or this will work to.
[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
this will return error no data found.
[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
It does not handle spaces over the error checking, I had change the codes, but it did handle spaces at first. I will work the spaces part out and fix it later. I do know I should had not rush and try to share the script so fast, I'm bad at that and should had did more testing before hand. v1.3 not bad, just can't use spaces right now. I been out of second life for a long time, but I'm sure the scripting has change a lot over the months. The functions still does the job and seem to work very fast. Thanks for showing other ways to check things, from now on I will make sure the script is 100% done before sending it to the wiki.
- Thanks Maddox. You might like to try these bad keys, all of which will sail through your isKey() as valid, but all would be rejected by the much easier, shorter and FASTER if (MyKey) ... process.
<lsl> "8f3O4cf2-7120-24e2-d1f1-db6b31bd6f6c" "8f304cf2-7120-24e2-dlf1-db6b31bd6f6c" "8f304cf2-7120-24e2-d1f1-db6b31-bd6f6" </lsl>
The first has a letter O instead of 0 (4th character), the 2nd has a letter L instead of a 1 (2nd character in 4th group), and the last has an extra hyphen instead of a hex digit. Omei Qunhua 01:39, 26 April 2014 (PDT)
Thanks Qunhua, I will check things out soon. I need to get my butt to bed right now, thanks for update info.... Here I made a video for you to check out, showing the project with the script.
Here is the video:Click Here to watch
- Sorry to say there's still big problems. You might like to consider why your test returns a uuid starting with "8f30..." for Fantasy Car Backdrop Texture, when the correct UUID starts with "517b...". The reason is based on the fact that for every non-comment line in your notecard, you add 3 entries to your Themes list. So when you read the line [Fantasy Tiger] you add the string "Fantasy Tiger", AND two (default) null keys to Themes. Then when you read the line with [BACKDROP TEXTURE UUID] you add a further 3 entries, "Fantasy Tiger", the Backdrop UUID itself, and a Null key. Then when you read the [Floordrop Texture UUID] line, you add a FURTHER 3 entries: "Fantasy Tiger" again, the Backdrop UUID again, and the new Floordrop UUID. This process is repeated for every line of the notecard. So your lookup process is going to be a disaster. When you reach the "Fantasy Car" line, you add "Fantasy Car" to Themes, but you also add the old keys from Fantasy Tiger. Corrected entries follow on later in the database, but this is too late; your search will find the first (invalid) entry. Omei Qunhua 04:34, 26 April 2014 (PDT)
That is what second life copy asset UUID gave the images. Fantasy Tiger:8f304cf2-7120-24e2-d1f1-db6b31bd6f6c Fantasy Car:517b2288-67ca-b14c-1de2-c5f5fdf5291f Fantasy Tree:f6321118-cc24-6230-78a5-a257a3e33378 It all works and finds the tetxures and button names.
But in the test script it not 100% the same how the studio works, I will look into it and see. The strings for the search are return from the menu buttons linkmessage event, cause of the menu system that part does not work the same, but the codes should had work still. I am checking it now and will see what is up with it.
I see what is wrong, for some reason the test script is no longer setting the themes list format right. Damn, one thing after the other but in the studio the format is ok.
Crazy lol.. anyway I will work on it for a bit. I did some debug testing on both the studio and test script here.
Demo Script here
,,,Fantasy Tiger,,,Fantasy Tiger,8f304cf2-7120-24e2-d1f1-db6b31bd6f6c,,Fantasy Tiger,8f304cf2-7120-24e2-d1f1-db6b31bd6f6c, 00000000-0000-0000-0000-000000000000,Fantasy Car,8f304cf2-7120-24e2-d1f1-db6b31bd6f6c,00000000-0000-0000-0000-000000000000, Fantasy Car,517b2288-67ca-b14c-1de2-c5f5fdf5291f,00000000-0000-0000-0000-000000000000,Fantasy Tree, 517b2288-67ca-b14c-1de2-c5f5fdf5291f,00000000-0000-0000-0000-000000000000,Fantasy Tree, f6321118-cc24-6230-78a5-a257a3e33378,00000000-0000-0000-0000-000000000000
Studio script here
Fantasy Tiger,8f304cf2-7120-24e2-d1f1-db6b31bd6f6c,00000000-0000-0000-0000-000000000000, Fantasy Car,517b2288-67ca-b14c-1de2-c5f5fdf5291f,00000000-0000-0000-0000-000000000000, Fantasy Tree,f6321118-cc24-6230-78a5-a257a3e33378,00000000-0000-0000-0000-000000000000
Does not make since cause the studio adds the list the same way.
- BTW,, if you REALLY want to check that 4 consecutive characters are Hex, I'm pretty sure this would work:-
<lsl>
string char = llGetSubString(check, i, i+3 ); // (from your existing isKey() function) if ( (integer) ( "0x1" + char ) < 65536) return FALSE; ... etc.
</lsl> At least it'll be better than your existing test which fails miserably.
I explained why your Themes list is being built wrongly. It's due to where you've placed the Themes += statement. But it's not trivial to solve. A good exercise for you :) Omei Qunhua 14:59, 26 April 2014 (PDT)
Just crazy how the studio has the same line as the demo script, same place and same almost everything as far the notecard reading goes, but in the studio I move the list around and make new ones over the menu system. The studio works 100% with it all and as you see on the video I made.
In the studio at the end it has this <lsl>
llInstantMessage(id,"Themes Configuration Error on line: " +(string)LineIndex+ ". (1) The Floor-drop Texture UUID is empty. (2) The Floor-drop UUID is not a key."); llResetScript(); } ThemesCount = ThemesCount +1;
MainThemes += [Menu_Button_Name,Back_Drop_UUID,Floor_Drop_UUID]; // For the search list format Themes += [Menu_Button_Name+","+Back_Drop_UUID+","+Floor_Drop_UUID]; // For making the menu buttons format
} } }
</lsl> In the demo script <lsl>
llInstantMessage(id,"Themes Configuration Error on line: " +(string)LineIndex+ ". (1) The Floor-drop Texture UUID is empty. (2) The Floor-drop UUID is not a key."); 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];
} } }
</lsl>
Just the list format that stops it from working right, I will rewrite the demo script over and fix it all. The studio is 100% ok, I don't need to change anything as far the studio goes and It works just how it was made to, but I will test few things you said on the demo one.
I fix it, just had to move the list adding up like this.
<lsl>
llInstantMessage(id,"Themes Configuration Error on line: " +(string)LineIndex+ ". (1) The Floor-drop Texture UUID 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 test list database //Themes += [Menu_Button_Name,Back_Drop_UUID,Floor_Drop_UUID];
} } }
</lsl>
Now the search will find the match on the test string search from any in the notecard. I will copy the version I got on here just to make sure and test it.
All works now, you can grab the update scripts and give it a test, change the search string to any of the buttons name in the notecard, it will pull out the right keys and names from it all. :) I did not even notice the studio and demo was not the same at the adding themes part. Gezzz my bad..
IsElement and DumpListFind is about the same code, but one just checks to make sure it was found first. All it does is pull the 3 elements from the list, cause each adding is done by 3 at a time.
List format = Fantasy Tiger,8f304cf2-7120-24e2-d1f1-db6b31bd6f6c,00000000-0000-0000-0000-000000000000 1. Fantasy Tiger (Search String) 2. 8f304cf2-7120-24e2-d1f1-db6b31bd6f6c (Backdrop Texture Key) 3. 00000000-0000-0000-0000-000000000000 (Floor Drop Texture Key)
This is why I had to make format for the dialog system to handle the buttons in other type of list.
This from Second Life Example of the [llListFindList]
<lsl> list numbers = [1, 2, 3, 4, 5]; default {
state_entry() { integer index = llListFindList(numbers, [3]); if (index != -1) { list three_four = llList2List(numbers, index, index + 1); llOwnerSay(llDumpList2String(three_four, ",")); // Object: 3,4 } }
} </lsl>
Easy Math :)