Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
|
06-16-2005 00:20
ok, so I have a list that has a bunch of names, and I want to be able to call it into the chat, so I use llList2CSV(). However, this list builds on itself, and eventually has too many things to fit in one llWhisper() or llOwnerSay(). Is there a way that I could count the number of things in the list and then if it gets to be greater than a certain number, split the message into two messages. I know I could do this as follows: list happy;
llOwnerSay("" + (string) llList2String(happy,0) + ", " + (string) llList2String(happy,1) + ", ") ...and on and on and on, but I know there must be a better way than this. The second message could either carry over the remainder, or have the whole message split directly in two and shared equally between the two messages, whatever's easier. Thanks for the help.
_____________________
Other than that, Mrs. Lincoln, how was the play?
|
Christopher Omega
Oxymoron
Join date: 28 Mar 2003
Posts: 1,828
|
06-16-2005 01:26
Here ya go  list happy; integer LENGTH_LIMIT = 255; string SEPERATOR = ", "; integer i; integer len = llGetListLength(happy); string builtString; for (i = 0; i < len; ++i) { // For each element in happy: string str = llList2String(happy, i); // If the combined length of the storage, the new // string, and the seperator is larger then the limit. if (llStringLength(builtString) + llStringLength(str) + llStringLength(SEPERATOR) > LENGTH_LIMIT) { // Say what we have, and start anew: llOwnerSay(builtString); builtString = ""; } builtString += str + SEPERATOR; } // If we have stuff left over: if (llStringLength(builtString) > 0) llOwnerSay(builtString);
==Chris
|
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
|
06-16-2005 23:35
hmmm. This works the first time I call it, but the second time it doubles the list, and the third, triples, and so on, like so.
me: happy object: 1,2,3
me: happy object: 1,2,3,1,2,3
and so on. why's it doing this?
_____________________
Other than that, Mrs. Lincoln, how was the play?
|
Eloise Pasteur
Curious Individual
Join date: 14 Jul 2004
Posts: 1,952
|
06-17-2005 01:31
try adding a clear out of the builtString at the bottom too, since I guess you will usually have stuff left over (254 out of 255 times in fact).
so add a new last line
builtString="";
|
Douglas Callahan
Fresh Prince Of SL
Join date: 2 Jul 2004
Posts: 349
|
06-17-2005 13:28
fixed it right up, thanks guys. 
_____________________
Other than that, Mrs. Lincoln, how was the play?
|