This code here is wrong
dim levels [200, 5, 6, 2] as integer
These numbers create that many objects in the array, using a base-one counting system (you start counting at number one.) However, to access the objects in the array, you have to use a base-zero counting system (you start counting at number zero).
For instance. You want to store 200 objects in an array called 'foo'. You want each object to be set to the number 100. This code here would create it:
dim foo[200] as integer
i as integer
for i = 0 to 199
foo[i] = 100
next
Your lower limit starts at 0. Your upper limit ends at 199. If you count from 0 to 199, you have 200 objects! It's just that the array is zero-based, but you defined with a one-based number (200).
So, for you, try:
dim niveles[201, 6, 7, 3] as integer
opentoread ( 1, "media/niveles.txt")
for x = 0 to 200
for y = 0 to 5
for z = 0 to 6
niveles[ x , y , z , 0 ] = readinteger(1)
next z
next y
niveles[ x , y , z , 1 ] = readinteger(1)
niveles[ x , y , z , 2 ] = readinteger(1)
next x
closefile ( 1 )
This will give you space for 201 objects in your first dimension (0-200), 6 objects in your second dimension (0-5), 7 in your third dimension (0-6), and 3 in your fourth dimension (0-2).
I hope this helps you!
Hi there. My name is Dug. I have just met you, and I love you.