Talk:Notecard Configuration Reader by Maddox Deluxe

From Second Life Wiki
Revision as of 01:05, 22 April 2014 by Omei Qunhua (talk | contribs) (various suggestions)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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)