|
Celebrator Subagja
Registered User
Join date: 27 Dec 2006
Posts: 2
|
01-27-2007 08:00
Hi ,
i'm trying and trying whithout any luck...
i have a script wich works... there are some hardcoded variables in it.
Now i want those variables read into the script via a notecard.
I already experimented with dataserver and llGetNotecardLine but without any luck..
Anybody has a little sample script for me ?
thanks in advance !
Celebrator
|
|
Atashi Toshihiko
Frequently Befuddled
Join date: 7 Dec 2006
Posts: 1,423
|
01-27-2007 08:12
There is / was a sample in the wiki on how to do this, in the Script Library I believe. It looks a bit complicated at first, but once you 'get' it I'm sure you'll have no trouble adapting it into your own scripts.
So have a look in the wiki, Script Library, use the example in there as a starting point.
-Atashi
|
|
Celebrator Subagja
Registered User
Join date: 27 Dec 2006
Posts: 2
|
Yes !!!
01-27-2007 09:18
Yep thank you .... didn't saw this one before, but it works.. and fits my needs... for the peeps who also looks for this : http://www.lslwiki.org/index.php/LibrarySettingsNotecard
|
|
Talon Brown
Slacker Punk
Join date: 17 May 2006
Posts: 352
|
01-27-2007 13:27
I was also using that script from the library until I took a good look at it and realized that it could be rewritten to be quite a bit faster. You'll note that it parses the notecard lines with string functions, which are already quite slow, and does so in a manner that reparses each line until it finds a match. A faster way to do that is to use llParseString2List to break the string into 2 parts and then convert those back to strings with llList2String. (In my admittedly limited testing, this method is twice as fast as using the string functions.) That removes the need for the StringLeftICompare function entirely since you can now directly compare the 1st string to your setting names. It also means that the GetValue func can be stripped down as well since it's now only needed to convert "true/false" to "1/0" and in all other cases you can typecast the 2nd string which already contains the value for that setting. Also, the original script parses multiple notecards so if you're only using one that's more code that can be stripped out. Anyway, here's the stripped down version that I now use. // Globals integer iNoteCardLine = 0; key kCurrentDataRequest; string sSettingsNotecard = "Config";
string GetValue(string sString) { if (sString) { string sbValue = llToLower(sString); if (sbValue == "true") return "1"; if (sbValue == "false") return "0"; return (sString); } return(NULL_KEY); }
// Script states begin here default { on_rez(integer param) { llResetScript(); }
state_entry() { llSetText("Initializing...", <1.0, 0.0, 0.0>, 1.0);
if (llGetInventoryType(sSettingsNotecard) == INVENTORY_NOTECARD) kCurrentDataRequest = llGetNotecardLine( sSettingsNotecard, iNoteCardLine ); else llWhisper( 0, "Using Default Values." ); }
dataserver( key kQuery, string sData ) { list lSetting = llParseString2List(sData, ["="], []); string lHeader = llList2String(lSetting, 0); string lValue = llList2String(lSetting, 1);
kCurrentDataRequest = ""; if (sData != EOF) { // you can string several of these tests for whatever values you may want.
if ( lHeader == "ShowHoverText") iShowHoverText = (integer)GetValue(lValue); else if (lHeader == "HoverTextValue") sHoverTextValue = lValue; else if(lHeader == "Color") vColor = (vector)lValue;
kCurrentDataRequest = llGetNotecardLine( sSettingsNotecard, ++iNoteCardLine ); } else { state run_object; } } }
|
|
Baron Hauptmann
Just Designs / Scripter
Join date: 29 Oct 2005
Posts: 358
|
01-27-2007 19:02
Excellent! I will incorporate those modifications in my own work. I had more or less copied from the library example, assuming that I could not improve on it much. Kudos to you! Thanks so much!
Baron H.
|