Folco Boffin
Mad Moo Cow Cultist
Join date: 27 Feb 2005
Posts: 66
|
06-02-2005 23:23
Not quite sure what to search for to find this one if anyone has already stated how to do this, tried but no luck.
Anyway, what I'm trying to do is make it easier for people to add to my script with as little code editing as possible. In psedu code, this is what I'm trying to do.
integer totalvars = 8;
string var1 = "This would be the first string of the group."; string var2 = "second"; etc etc string var8 = "eighth";
and have all my user added data up here so I can have the rest of the more intricate part of the script not needed to be edited
This is where I get stuck... in my for loop.
list vars = []; integer n; for (n = 1, n <= totalvars, n++) {
list vars += [var(n)];
}
I have no idea how to just have it loop through adding all of the strings by the single line of code that would allow me to not have to have the end users add more lines of code for each string they wish to add to my script. Is this even possible?
Thanks in advance for any help you can give, even if it's to tell me I can't do it.
|
Olmy Seraph
Valued Member
Join date: 1 Nov 2004
Posts: 502
|
06-02-2005 23:50
I'd suggest putting the user data into a configuration notecard. There are a few examples of how to do that in the Script Library forum and the wiki, so I won't go into any more detail of how to. But that would let the user provide their own data without having to edit the script at all.
_____________________
Some people are like Slinkies... not really good for anything, but they sure bring a smile to your face when you push them down the stairs.
|
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
|
06-03-2005 00:01
From: Folco Boffin I have no idea how to just have it loop through adding all of the strings by the single line of code that would allow me to not have to have the end users add more lines of code for each string they wish to add to my script. Is this even possible? Sure. This is pretty easy... why name the variables at all? (Well, besides the fact that would be like an array, which we don't have...) A good place to start: http://secondlife.com/badgeo/wakka.php?wakka=ListsWhen you want a user to retrieve data from a specific point, you can just do the following: list stuff = [1,2,3,4,5,6]; integer test = llList2Integer(stuff,3);
//Returns 4 for the value of test. This is because the index starts at 0! You can then add to the list much like you were trying to do: stuff += 7;
// Returns [1,2,3,4,5,6,7] for stuff ... or add a query from a list to itself with llList2List, llListInsertList, and llListReplaceList.And yes, this all works with strings. Try llList2String.
_____________________
---
|
Folco Boffin
Mad Moo Cow Cultist
Join date: 27 Feb 2005
Posts: 66
|
06-03-2005 00:41
Heh, didn't think of the notecard approach. *sighs and misses his arrays* I already have a good working idea of how lists work as I already have a few scripts using lists and strided lists and have made arrays in other languages as well. Just was trying to have a section at the top where they could add the vector position of a location for one variable, then a name for it in a similar variable (ie: dest1 and destname1 or something) and have that all at the top then populate a list or strided list with the information from the variables with a for loop so that they wouldn't have to insert the extra code (or removed extra code) required for each location more or less than I have it set up for. Don't know if that gives you a better idea of what I'm trying to do or not, but now that I'm thinking of it, I'm going to have to go re-read up on notecard parsing. Thank you both for your help so far, and Jeff, do you ever sleep? Seems like you're always on the boards. 
|
Jeffrey Gomez
Cubed™
Join date: 11 Jun 2004
Posts: 3,522
|
06-03-2005 00:48
From: Folco Boffin Just was trying to have a section at the top where they could add the vector position of a location for one variable, then a name for it in a similar variable (ie: dest1 and destname1 or something) and have that all at the top then populate a list or strided list with the information from the variables with a for loop so that they wouldn't have to insert the extra code (or removed extra code) required for each location more or less than I have it set up for. Yeah, this is a task for notecards or just using a list at the top and leaving it at that, as my importers do. And I tend to be nocturnal - and occasionally leave the computer logged in while I work elsewhere. Procrastination is a virtue.
_____________________
---
|