Hi,
I'd like to make my scripts a little more fool proof. Ideally id have the script refer to a notecard for any variables. This would allow the owner to make changes without touching the script.
Any help appreciated.
These forums are CLOSED. Please visit the new forums HERE
Notecard support |
|
|
Malik Bode
Registered User
Join date: 27 Dec 2006
Posts: 23
|
07-16-2007 08:14
Hi,
I'd like to make my scripts a little more fool proof. Ideally id have the script refer to a notecard for any variables. This would allow the owner to make changes without touching the script. Any help appreciated. |
|
Imajica Hand
Registered User
Join date: 3 Feb 2006
Posts: 66
|
07-16-2007 08:35
This question looks too easy...Something like that? http://lslwiki.net/lslwiki/wakka.php?wakka=LibrarySettingsNotecard |
|
Milambus Oh
Registered User
Join date: 6 Apr 2007
Posts: 224
|
07-16-2007 08:47
Reading from a Notecard is moderately easy, once you understand event driven programming. Writing to a Notecard however is impossible.
Here are the steps you need to go through to read a notecard: 1. Read the initial line with llGetNotecardLine. Store the key this function returns in a global variable. 2. Reading the line with fire the dataserver() event. Within the event check to make sure this is the correct data request and that you have not hit the end of the notecard. 3. Then process the data in some way. 4. Request the next line. 5. Steps #2-4 repeat until the end of the Notecard. Here is the bare bones needed to read a Notecard, adjust it however you need: CODE
|
|
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
|
07-16-2007 10:49
Yeah the event stuff is what made this hardest for me as well. You have to realize that your note card reading function will call llGetNoteCardLine then continue without having ever read a line. The dataserver event will get called by the server once your note card line is ready, and you continue from there (including calling llGetNoteCardLine again, from within the event to read more lines).
Once you get a handle on that, its really easy. Also I prefer to get my parameters different from the way the example script posted does. I will define a note card structure as follows: CODE
From that point on you can lookup a name in your nameList, and get the various values you associate with it with the same index in the other lists. That may not be the most memory efficient way to go, but I find that unless I have a memory constraint, the readability and flexibility (and this code is very generic so I can plop it down in any of my scripts and use it, just changing around the names of things a bit) really helps me just get along and not worry about the note cards. |