Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need help with Array

Dragos Zaoh
Registered User
Join date: 11 Dec 2006
Posts: 58
08-07-2007 01:58
Pfft... i am trying to use an array and i have no idea how to do this.
Here is a code i would like to show you, and maybe you can give me a hint.

integer i;
integer x = 1;
integer a; ///// here is my problem.
default
{
state_entry()
{

for (i = 0;i<100;i++)
{
a = a+x; ///// a ?????-- here as well
if (i > 20) x = 2;
if (i > 40) x = 3;
if (i > 50) x = 5;
llSay(0,(string)a;//// a??
}

}


}


i don't know how can i do this in LSL,....what can i substitute a with....
I tried using lists but still no result.... as my a is an integer.
Squirrel Wood
Nuteater. Beware!
Join date: 14 Jun 2006
Posts: 471
08-07-2007 02:08
LSL does not support arrays.

Your only option is using Lists and Typecasting (when neccessary).
Shadow Subagja
Registered User
Join date: 29 Apr 2007
Posts: 354
08-07-2007 11:32
This might not work right off I haven't done a whole lot of list manipulation but it might get you down the right path:

integer i;
integer x = 1;
list a; ///// here is my problem.
default
{
state_entry()
{

//must generate items, you can do this by adding/appending, I don't think you can preload a list with allocated data;
for (i = 0;i<100;i++)
{
a += [0];
}

//to modify items once they exist you would do something more like this
for (i = 0;i<100;i++)
{
a = llListReplaceList(a, [x], i, i);
if (i > 20) a = llListReplaceList(a, [2], i, i);
if (i > 40) a = llListReplaceList(a, [3], i, i);
if (i > 50) a = llListReplaceList(a, [4], i, i);
llSay(0,llList2String(a,i);
}

}


}