Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Reading an indeterminate number of variables from a notecard

Rock Ryder
Registered User
Join date: 6 Oct 2006
Posts: 384
11-16-2007 05:54
Hi Guys,

I have a function that takes vectors from a notecard and places them in vector variables in my main script. If I put 10 vectors into the notecard I can then read them into 10 vector varibles (which I have declared). Simple enough so far.

However, I just cannot get my head around about how to read in vector variables if the number of variables in the notecard is indeterminate. For example, if a sim is divided into 9 parcels, or 10 or 12 or whatever, and I wish to pass the vectors of each parcel to my script via a notecard.

I guess I need to read the number of lines in the notecard = number of variables, then somehow (this is the bit I need help on) generate the same number of variables in my script, then read each line of the notecard into each of those variables.

Any ideas on how I can go about this?
Stephen Zenith
Registered User
Join date: 15 May 2006
Posts: 1,029
11-16-2007 05:55
Couldn't you just put them in a list? You can't create variables at runtime, which I think is what you're asking.
_____________________
Void Singer
Int vSelf = Sing(void);
Join date: 24 Sep 2005
Posts: 6,973
something like...
11-16-2007 06:56
CODE

list vgListVectors;
integer vgIntCurrentLine;

default{
state_entry(){
llGetNotecardLine( "config", vgIntCurrentLine );
}

dataserver( key vKeyNull, string vStrData ){
if (EOF == vStrData){ //-- quit reading the notecard when we reach the end
state vsMain;
}else{
vgListVectors = (vgListVectors = []) + vgListVectors + (vector)vStrData;
llGetNotecardLine( "config", ++vgIntCurrentLine );
}
}
}

state vsMain{
//-- your code here
}
_____________________
|
| . "Cat-Like Typing Detected"
| . This post may contain errors in logic, spelling, and
| . grammar known to the SL populace to cause confusion
|
| - Please Use PHP tags when posting scripts/code, Thanks.
| - Can't See PHP or URL Tags Correctly? Check Out This Link...
| -
Rock Ryder
Registered User
Join date: 6 Oct 2006
Posts: 384
11-16-2007 13:48
Many thanks Void, a couple of tweaks and that worked perfectly.

Rock