Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Generating a list from a notecard via llGetNotecardLine()

Otis Pertwee
Registered User
Join date: 22 Jan 2006
Posts: 12
05-07-2006 05:12
Hi, I'm working on a script where I would like to keep a list of UUIDs in a notecard and then compile them into a list for the script.

I'm not entirely certain how to go about doing that. I do know how to read the line FROM the card (the LSL wiki is a beautiful thing) but I'm not sure how I will compile them into a list.

list song = [line one, line two, line three, etc];

Any help would be greatly appreciated.
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
05-07-2006 06:04
Try something like this (it's fragments of real code)

CODE

list keys;
string card="cardname";
integer pointer=0;
//Then in some suitable event
llGetNotecardLine(card, pointer);
//Then the data server event
dataserver(key query, string data)
{
if(data!=EOF)
{
keys+=(key)data;
pointer++;
llGetNotecardLine(card, pointer);
} else
{
//Do something here is necessary - we've finished the card.
}
}


There are bells and whistles - you can check for the key of the query for example, vital if there are more scripts in the prim with dataserver events, you can store data in CSVs or use other separators and parse the data into lists and then on into other lists etc. But that's the basic structure
Otis Pertwee
Registered User
Join date: 22 Jan 2006
Posts: 12
05-07-2006 06:48


Hi again Eloise! If you didn't notice, it's me- the boy who was making the boom box music player.

I've worked GREAT DEAL on it, your help got me coding like a madman.

I understand how to fetch the data FROM the card, I'm just really not sure how to compile it into a list.

See, I've made two modes for the player now- one that just plays the loops and one that uses preloading and buffering of a list of clips to play a full length song.

I want to be able to lock down the main script and keep the options + list of clips for the buffering mode in a notecard so they can be saved and swapped out- like changing what tape is playing.

It works by reading a list of uuids
Joannah Cramer
Registered User
Join date: 12 Apr 2006
Posts: 1,539
05-07-2006 08:09
From: Otis Pertwee
I understand how to fetch the data FROM the card, I'm just really not sure how to compile it into a list.

It's being done in that code snippet in earlier example. There's 'global' list to store the compilation (list keys) and then in the dataserver event each new line is being added to that list, as new entry (keys += (key)data) ... so when the card processing is done, all the uuid's are stored in sequence in that 'keys' list, and you can access it from other points in your script...
Talarus Luan
Ancient Archaean Dragon
Join date: 18 Mar 2006
Posts: 4,831
05-07-2006 11:10
Just remember that if you store multiple items on a single line that the maximum line length is 255 characters. It sounds like a lot, but that is only about 7 keys, for example. The lines are truncated to that size, extra data is lost.