Posted 08 August 2014 - 03:26 AM
Hi, I'm having a little trouble with this function I wrote to create tables at specific sizes. I am not particularly good at computercraft, so I am sure I have missed something obvious, but the function will not create tables with the name specified.
Here is the function,
This function is part of a larger program I am trying to make, that will scan and destroy an area of land, writing the values of the blocks it encounters to an array. Then a second turtle could rebuild the structure elsewhere, using the array as a reference. For 3d structures, the "scanning" turtle would have to be placed down again for each layer, and the program modified to avoid writing over the previous layer's data.
Thanks in advance to anyone who can help me with this,
Will
Here is the function,
function matrixCreate(x,y,name)
name = {} --#creates empty table with the name specified in the third part of the function call
for i=1,x do
name[i] = {} --#this sets all values within the table to tables themselves.
for j=1,y do
name[i][j] = 1 --#This is just to make sure the table is as big as it needs to be. I would later rewrite these values to different things
end
end
end
matrixCreate(16,16,Grid) --#I also tried "matrixCreate(16,16,"Grid")", but no luck either.
print(Grid[11][2]) --# This was just to test if the table had been successfully created, and the values set.
This function is part of a larger program I am trying to make, that will scan and destroy an area of land, writing the values of the blocks it encounters to an array. Then a second turtle could rebuild the structure elsewhere, using the array as a reference. For 3d structures, the "scanning" turtle would have to be placed down again for each layer, and the program modified to avoid writing over the previous layer's data.
Thanks in advance to anyone who can help me with this,
Will
Edited on 08 August 2014 - 03:41 AM