|
|
Multi dimensional arrays ?
#268522
05/29/09 19:57
05/29/09 19:57
|
Joined: May 2009
Posts: 11 Romania, Targu Mures
F_P_kefas
OP
Newbie
|
OP
Newbie
Joined: May 2009
Posts: 11
Romania, Targu Mures
|
I`m a little new on the forum, and I was looking in the existing posts but couldn`t find may answer.
How can you define multi dimensional arrays(if you can)?
I`m using CSript, so:
I want to define an array variable that has "array variables".
I tried:
var door[10]; var door_var[3]; var counter=0;
function main(){ while (counter!=10){ door_var[0]=100; door_var[1]=200; door_var[3]=300; door[counter]=door_var; counter+=1; } }
but door[any_number] is always door_var[0]
Something (i know it sounds a little stupid, but...) is needed:
var door[10][3]; - is needed
can anyone help me?
hello
|
|
|
Re: Multi dimensional arrays ?
[Re: F_P_kefas]
#268524
05/29/09 20:09
05/29/09 20:09
|
Joined: Oct 2007
Posts: 5,209 İstanbul, Turkey
Quad
Senior Expert
|
Senior Expert
Joined: Oct 2007
Posts: 5,209
İstanbul, Turkey
|
as far as i know you cant have multi dimensional arrays in c-script...(but you can in lite-c)
if you are new, start with lite-c.(since it's the new thing)
3333333333
|
|
|
Re: Multi dimensional arrays ?
[Re: Quad]
#268525
05/29/09 20:14
05/29/09 20:14
|
Joined: May 2009
Posts: 11 Romania, Targu Mures
F_P_kefas
OP
Newbie
|
OP
Newbie
Joined: May 2009
Posts: 11
Romania, Targu Mures
|
Thanks for the answer, but I wrote I was new on the forum. I was doing CScript 5 years ago but meen while programmed in C++, Java, VisualC... Now I just need thid for something I started in Cscript.
I`ll try lite-c after I finished this project.
But thanks anyway.
hello
|
|
|
Re: Multi dimensional arrays ?
[Re: Quad]
#268527
05/29/09 20:19
05/29/09 20:19
|
Joined: Oct 2005
Posts: 4,771 Bay City, MI
lostclimate
Expert
|
Expert
Joined: Oct 2005
Posts: 4,771
Bay City, MI
|
as far as i know you cant have multi dimensional arrays in c-script...(but you can in lite-c)
if you are new, start with lite-c.(since it's the new thing) it is too possible in c-script, you just need to have a work around its explained under the variable syntax area in the manual.
|
|
|
Re: Multi dimensional arrays ?
[Re: lostclimate]
#268537
05/29/09 21:05
05/29/09 21:05
|
Joined: May 2009
Posts: 11 Romania, Targu Mures
F_P_kefas
OP
Newbie
|
OP
Newbie
Joined: May 2009
Posts: 11
Romania, Targu Mures
|
Well, I`w found a way for arrays to work as multi dimensional: var door[10]; var door_var[3]; counter_1=0; counter_2=0; ... while(counter_1!=10){ while(counter_2!=3{ door[counter_2]=door_var[counter_1]; counter_2+=1; } counter_1+=1; } and..so an whit many variable as you want, but still I didn`t DEFINE a multi dimensional array. P.S. where in the manual, pleas? 
hello
|
|
|
Re: Multi dimensional arrays ?
[Re: F_P_kefas]
#268558
05/29/09 23:23
05/29/09 23:23
|
Joined: Feb 2008
Posts: 3,232 Australia
EvilSOB
Expert
|
Expert
Joined: Feb 2008
Posts: 3,232
Australia
|
Deep down on the "Variables" page. Multidimensional arrays can be defined by multiplying the index by the array width. Suppose you need an array in two dimensions, like a 10*20 grid of height values. It is defined this way:
var heightmap[200]; // 200 = 10*20 The array value at position (j,i) can then be accessed through:
heightmap[j*20 + i] = 10; // j = 0..9, i = 0..19
LC In lite-C, you can alternatively define (uninitialized) and address multidimensional arrays by using several indices:
var heightmap[10][20];... heightmap[j][i] = 10; // j = 0..9, i = 0..19
"There is no fate but what WE make." - CEO Cyberdyne Systems Corp. A8.30.5 Commercial
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|