Multidim arrays in javascript

Am i right in thinking that you can’t create multidim arrays in javascript but you can still use them?
Anything I try seems to spit an error like expected eof or ; on the first line
I have even tried copying existing code that is said to work (so I can compare my own code to see how my format is different) and they still spit the same errors.

The line that seems to offend the most is the opening linevar multiDimArray = new int [,,];

Nope, the code you posted is fine. If it’s not working, then you must be using a old version of Unity.

–Eric

i downloaded it last night as i thought this myself maybe a full uninstall/reinstall?

I’m on unity 3.5 Is it a pro feature?

Try passing the size:

var multiDimArray = new int[10,10,10];

sorry i’m doing that now and it just gives me the same result :frowning:
gonna try a full reinstall instead of reinstalling over the old one

Actually, yeah, “var multiDimArray = new int [,]” won’t work, I was reading that as “var multiDimArray : int [,]”. However tonyd’s code will work.

–Eric

ok well I tried this on its own and it works fine but as soon as i add a “for” statement it flips out :frowning:
go easy on me now its been a while since i did any of this

Anybody got any ideas?

What’s the result of your observation?

As soon as I use any kind of “for” statement It throws an error all the way down the page stating expexting “EOF” or “;”

how about posting your full code? The reason I ask is because currently my brainwave telepathy scanner (the BTS) isn’t currently working as I already fried it answering other posts with the WTF (wave thought finder).

I’ve dropped my orange peels and I felt like canned tuna…

Sorry, here’s what it looks like.

var voxelData = new int[64,64,4];

for (int x = 0; x < 64; ++x)

{

    for (int y = 0; y < 64; ++y)

    {

        var color = colors[x + y * 64];

        for (int z = 0; z < 4; ++z)

        {

            voxelData[x, y, z] = (int)(color[z] * 255);

        }

    }

}

I get the feeling i’m making a huge noob mistake here

the error I get here is “expecting ;, found ‘x’.”

I see not how that is relevant or of any help to me

You’re mixing C# and JS syntax.

–Eric

Right but where am I using the C# cos I’m ment to be using JS I get muddled up sometimes.
in the “for” section?

seriously considering moving to C# though :confused:

Why are you pre-incrementing your counters, instead of post-incrementing? Meaning why are you using ++x and not x++ ?

pre incrementing will return the numbers 0 to 63 (I believe). Since the image I want loaded is 64 pixels wide then post incrementing would return 0-64 which would return a size of 65 or am I missing something. Still need to get it all to js though

You have to declare variables in JS with “var”, not the type.

It makes no difference either way in this case, since the value of x is changed at the end of the loop. You could also use x += 1.

–Eric

Ok really dense here “type”? do you mean “int”?

Yes, int is a type, like float, bool, Vector3, etc.

–Eric