|
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
|
07-12-2007 14:11
I dont know why I'm having such an issue with this.. but if someone could help shove me in the right direction, I'd really appreciate it...
I'm trying to create a list from a notecard. However, I cant seem to figure out how to do it. I'm able to get the data from the notecard, but for some reason, even though there are only 3 items in the notecard, the dataserver event gets called 5 times...
Esentially, I want to go from this: Avatar One Avatar Two Avatar Three in the notecard... to this:
list AvatarList = ["Avatar One", "Avatar Two", "Avatar Three"];
any help would be appreciated.
|
|
RJ Source
Green Sky Labs
Join date: 10 Jan 2007
Posts: 272
|
07-12-2007 14:25
Could it be you have blank lines at the end?
|
|
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
|
07-12-2007 15:06
From: RJ Source Could it be you have blank lines at the end? hmm... no, I didnt put any blank lines at the end.. but 3 items plus 2 carriage returns equals 5.. maybe that's why...
|
|
Qie Niangao
Coin-operated
Join date: 24 May 2006
Posts: 7,138
|
07-12-2007 15:54
From: Johan Laurasia ... carriage returns... (/me looks up from his Underwood keyboard, thinking of simpler times.) Well, unless it's already excluded from the count, there will be an EOF event. Also, all scripts in a prim get all dataserver events generated by any of them, so if there's another script calling, say llRequestAgentData, that dataserver event would appear in this script, too (hence the importance of matching the queryID returned by the requesting functions).
|
|
Cryas Tokhes
Great Googley Moogley...
Join date: 8 Feb 2006
Posts: 124
|
07-12-2007 18:00
From: Johan Laurasia I dont know why I'm having such an issue with this.. but if someone could help shove me in the right direction, I'd really appreciate it... I'm trying to create a list from a notecard. However, I cant seem to figure out how to do it. I'm able to get the data from the notecard, but for some reason, even though there are only 3 items in the notecard, the dataserver event gets called 5 times... Esentially, I want to go from this: Avatar One Avatar Two Avatar Three in the notecard... to this: list AvatarList = ["Avatar One", "Avatar Two", "Avatar Three"]; any help would be appreciated. yeah... dataserver is a tricky thing... it seems to run parallel to the rest of the program. so the looping or requesting this information is not a fun one, but easy once you understand how it works. treat it as a goto (just weirder) string notecard = "AvatarNames"; // Enter names in here, one per line key lineTotalID; key currentLineID; integer totalLines; integer currentLine; list AvatarList; default { state_entry() { lineTotalID = llGetNumberOfNotecardLines(notecard); } dataserver(key requested, string data) { if (requested == lineTotalID ) { totalLines = (integer)data; llOwnerSay("Detected " + totalLines + " Names."); currentLine = 0; AvatarList = []; currentLineID = llGetNotecardLine(notecard,currentLine); } if ( currentLineID == requested) { currentLine++; AvatarList = AvatarList + data; if (currentLine <= totalLines) { currentLineID = llGetNotecardLine(notecard,currentLine); } } } }
|
|
Johan Laurasia
Fully Rezzed
Join date: 31 Oct 2006
Posts: 1,394
|
07-12-2007 22:59
From: Cryas Tokhes yeah... dataserver is a tricky thing... it seems to run parallel to the rest of the program. so the looping or requesting this information is not a fun one, but easy once you understand how it works. QUOTE] Thanks so much Cryas.. that did it... one thing though.. there was an error as written.. easy enough to fix.. you forgot to cast the totalLines integer variable into a string in the llOwnerSay(), after I fixed that, it compiled and worked fine.. thanks a bunch 
|