This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
aferral's profile picture

[Lua][Question] Create multiple arrays

Started by aferral, 02 April 2012 - 04:40 PM
aferral #1
Posted 02 April 2012 - 06:40 PM
Hi im here again, im trying to make somekind of Turtle 3D printer and i need to make one array for each level its posible to make something like this ?

print("How many layers you want")
layers = io.read()

for z = 1, layers, 1 do

create Array(z)

–here i fill the rows and colummns

end
Advert #2
Posted 02 April 2012 - 06:42 PM
Certainly; see Programming in Lua c. 11.2
aferral #3
Posted 02 April 2012 - 06:54 PM
I have already read that, some clue of where i can find something similar?
Advert #4
Posted 02 April 2012 - 07:16 PM
The answer you seek is in that link.

If you search around the forums, specifically for some turtle programs, you'll probably find stuff.
EatenAlive3 #5
Posted 02 April 2012 - 08:49 PM
Use the value of z in your for loop as keys to values. For example,

for z = 1,layers,1 do
  array[z] = {}
  --code
end