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

table creation error!

Started by WestWindsDemon, 06 July 2015 - 03:36 PM
WestWindsDemon #1
Posted 06 July 2015 - 05:36 PM
Good day everyone. I'm having some issues with a little program that I've been working on for about a month and can't seem to get it to work. The goal is to gather the sonicScan() table and sort thru it to gather a 5x5 array of what a turtle is "looking" at, sort of a black and white short range camera (3 block in front), and this is where I'm having issues. I can't seem to create this table. Here's the code:


--: eye
--Variables & Such
s   = peripheral.wrap("left")
scn = s.sonicScan()
vsn = {}

--**--Start--**--

--while true do
pix = 1
for tby = 1, 5 do
tabY = 2
 for tbx = 1, 5 do
 tabX = -2
  for tbz = 1, 3 do
   for i, v in ipairs(scn) do
   ----
    if v["y"] == tabY and v["x"] == tabX then

     if v["type"] == "SOLID" then

     if v["z"] == 1 then
      vsn[pix] = 1
      print(i..v["type"]..v["z"])
      break

    elseif v["z"] == 2 then
     vsn[pix] = 2
     print(i..v["type"]..v["z"])
     break

   elseif v["z"] == 3 then
     vsn[pix] = 3
     print(i..v["type"]..v["z"])
     break

   else
   end

   elseif v["type"] == "LIQUID" then

    if v["z"] == 1 then
     vsn[pix] = "L"
     print(i..v["type"]..v["z"])
     break

   elseif v["z"] == 2 then
     vsn[pix] = "L"
     print(i..v["type"]..v["z"])
     break

   elseif v["z"] == 3 then
     vsn[pix] = "L"
     print(i..v["type"]..v["z"])
     break

   else
  end

 else
end

else
end
----
end
end
tabX = tabX + 1
end
tabY = tabY - 1
pix  = pix + 1
end
--end

for itr, itm in ipairs(vsn) do
if itm == nil then
write("n")
else
write(tostring(itm)..",")
end
end
print("pix "..pix)
write("#")
print(#vsn)

It outputs 2 lines:


pix 6
#0

Ultimately, the plan is to make the turtle running this program to send the created table over rednet using textutils.serialise() to a pocket computer in which will be rendered like a remote control. Please help me, I'm getting a little frustrated.
Bomb Bloke #2
Posted 07 July 2015 - 02:26 AM
Your indentation leaves much to be desired. This is probably why you didn't notice that you've got your "tabX = tabX + 1" and "tabY = tabY - 1" lines in the wrong places. They're currently sitting in the bottom of the "tbx" and "tby" loops respectively, which reset tabX and tabY back to -2 and 2 every time they repeat (and so the variables effectively never change). You want to move those lines into the bottom of the tbz and tbx loops:

Spoiler
--Variables & Such
s   = peripheral.wrap("left")
scn = s.sonicScan()
vsn = {}

--**--Start--**--

pix = 1
for tby = 1, 5 do
	tabY = 2
	
	for tbx = 1, 5 do
		tabX = -2
		
		for tbz = 1, 3 do
			for i, v in ipairs(scn) do
				if v["y"] == tabY and v["x"] == tabX then
					if v["type"] == "SOLID" then
						if v["z"] == 1 then
							vsn[pix] = 1
							print(i..v["type"]..v["z"])
							break
						elseif v["z"] == 2 then
							vsn[pix] = 2
							print(i..v["type"]..v["z"])
							break
						elseif v["z"] == 3 then
							vsn[pix] = 3
							print(i..v["type"]..v["z"])
							break
						end
					elseif v["type"] == "LIQUID" then
						if v["z"] == 1 then
							vsn[pix] = "L"
							print(i..v["type"]..v["z"])
							break
						elseif v["z"] == 2 then
							vsn[pix] = "L"
							print(i..v["type"]..v["z"])
							break
						elseif v["z"] == 3 then
							vsn[pix] = "L"
							print(i..v["type"]..v["z"])
							break
						end
					end
				end
			end
			
			tabX = tabX + 1
		end
		
		tabY = tabY - 1
	end
	
	pix  = pix + 1
end

for itr, itm in ipairs(vsn) do
	if itm == nil then
		write("n")
	else
		write(tostring(itm)..",")
	end
end

print("pix "..pix)
write("#")
print(#vsn)

Note that I've also stripped out all the redundant "else" statements. "else end" isn't needed, just use "end".

The same "vsn" table could be produced by simply iterating through the "scn" table once and using a bit of math:

Spoiler
--Variables & Such

local s   = peripheral.wrap("left")
local scn = s.sonicScan()
local vsn = {}

local xmin, xmax, ymin, ymax, zmin, zmax = -2, 2, -2, 2, 1, 3

local xrange, zrange = xmax - xmin + 1, zmax - zmin + 1

--**--Start--**--

local pix = 0

for i, v in ipairs(scn) do
	if v.y >= ymin and v.y <= ymax and v.x >= xmin and v.x <= xmax and v.z >= zmin and v.z <= zmax and (v.type == "SOLID" or v.type == "LIQUID") then
		pix = pix + 1
		vsn[(v.y - ymin) * xrange * zrange + (v.x - xmin) * zrange + v.z] = v.type == "SOLID" and v.z or "L"  -- See http://lua-users.org/wiki/TernaryOperator
	end
end

for itr, itm in ipairs(vsn) do write((item or "n")..",") end

print("pix "..pix)
print("#"..#vsn)

Though personally I think formatting "vsn" as a three-dimensional table would result in something much easier to use, in the end:

Spoiler
--Variables &amp; Such

local s   = peripheral.wrap("left")
local scn = s.sonicScan()
local vsn = {}

local xmin, xmax, ymin, ymax, zmin, zmax = -2, 2, -2, 2, 1, 3

--**--Start--**--

for i, v in ipairs(scn) do
	if v.y >= ymin and v.y <= ymax and v.x >= xmin and v.x <= xmax and v.z >= zmin and v.z <= zmax and (v.type == "SOLID" or v.type == "LIQUID") then
		if not vsn[v.z - zmin + 1] then vsn[v.z - zmin + 1] = {} end
		if not vsn[v.z - zmin + 1][v.y - ymin + 1] then vsn[v.z - zmin + 1][v.y - ymin + 1] = {} end
		vsn[v.z - zmin + 1][v.y - ymin + 1][v.x - xmin + 1] = v.type == "SOLID" and v.z or "L"  -- See http://lua-users.org/wiki/TernaryOperator
	end
end

for z = 1, #vsn do
	for y = 1, #vsn[z] do
		for x = 1, #vsn[z][y] do
			write((vsn[z][y][x] or "n") .. ",")
		end
		print()
	end
	print()
end

If you're still stuck, post the content of your "scn" table. You should be able to write it to a file like so:

local myFile = fs.open("file.txt", "w")
myFile.writeLine(textutils.serialize(scn))
myFile.close()
Edited on 07 July 2015 - 12:27 AM
WestWindsDemon #3
Posted 07 July 2015 - 03:07 AM
Omg, thank you! I'll look thought the code and fix it as soon as I can. I'll let you know the results. You're awesome! Also, I apologize for the indentation, I copy-pasted from my note++ window and some indents are tabs while the others were spaces and didn't copy good. I'll get it right next time.
Edited on 07 July 2015 - 01:10 AM
WestWindsDemon #4
Posted 08 July 2015 - 10:27 PM
So I tested the code and here is what came out in the file with the little code snippet that you gave me:
Spoiler

{
  {
    type = "AIR",
    z = 0,
    y = 0,
    x = -3,
  },
  {
    type = "SOLID",
    z = -1,
    y = -2,
    x = -2,
  },
  {
    type = "SOLID",
    z = 0,
    y = -2,
    x = -2,
  },
  {
    type = "SOLID",
    z = 1,
    y = -2,
    x = -2,
  },
  {
    type = "SOLID",
    z = -2,
    y = -1,
    x = -2,
  },
  {
    type = "SOLID",
    z = -1,
    y = -1,
    x = -2,
  },
  {
    type = "SOLID",
    z = 0,
    y = -1,
    x = -2,
  },
  {
    type = "SOLID",
    z = 1,
    y = -1,
    x = -2,
  },
  {
    type = "SOLID",
    z = 2,
    y = -1,
    x = -2,
  },
  {
    type = "AIR",
    z = -2,
    y = 0,
    x = -2,
  },
  {
    type = "SOLID",
    z = -1,
    y = 0,
    x = -2,
  },
  {
    type = "SOLID",
    z = 0,
    y = 0,
    x = -2,
  },
  {
    type = "AIR",
    z = 1,
    y = 0,
    x = -2,
  },
  {
    type = "AIR",
    z = 2,
    y = 0,
    x = -2,
  },
  {
    type = "AIR",
    z = -2,
    y = 1,
    x = -2,
  },
  {
    type = "AIR",
    z = -1,
    y = 1,
    x = -2,
  },
  {
    type = "AIR",
    z = 0,
    y = 1,
    x = -2,
  },
  {
    type = "AIR",
    z = 1,
    y = 1,
    x = -2,
  },
  {
    type = "AIR",
    z = 2,
    y = 1,
    x = -2,
  },
  {
    type = "AIR",
    z = -1,
    y = 2,
    x = -2,
  },
  {
    type = "AIR",
    z = 0,
    y = 2,
    x = -2,
  },
  {
    type = "AIR",
    z = 1,
    y = 2,
    x = -2,
  },
  {
    type = "SOLID",
    z = -2,
    y = -2,
    x = -1,
  },
  {
    type = "SOLID",
    z = -1,
    y = -2,
    x = -1,
  },
  {
    type = "SOLID",
    z = 0,
    y = -2,
    x = -1,
  },
  {
    type = "SOLID",
    z = 1,
    y = -2,
    x = -1,
  },
  {
    type = "SOLID",
    z = 2,
    y = -2,
    x = -1,
  },
  {
    type = "SOLID",
    z = -2,
    y = -1,
    x = -1,
  },
  {
    type = "SOLID",
    z = -1,
    y = -1,
    x = -1,
  },
  {
    type = "SOLID",
    z = 0,
    y = -1,
    x = -1,
  },
  {
    type = "SOLID",
    z = 1,
    y = -1,
    x = -1,
  },
  {
    type = "SOLID",
    z = 2,
    y = -1,
    x = -1,
  },
  {
    type = "AIR",
    z = -2,
    y = 0,
    x = -1,
  },
  {
    type = "SOLID",
    z = -1,
    y = 0,
    x = -1,
  },
  {
    type = "AIR",
    z = 0,
    y = 0,
    x = -1,
  },
  {
    type = "AIR",
    z = 1,
    y = 0,
    x = -1,
  },
  {
    type = "AIR",
    z = 2,
    y = 0,
    x = -1,
  },
  {
    type = "AIR",
    z = -2,
    y = 1,
    x = -1,
  },
  {
    type = "SOLID",
    z = -1,
    y = 1,
    x = -1,
  },
  {
    type = "AIR",
    z = 0,
    y = 1,
    x = -1,
  },
  {
    type = "AIR",
    z = 1,
    y = 1,
    x = -1,
  },
  {
    type = "AIR",
    z = 2,
    y = 1,
    x = -1,
  },
  {
    type = "AIR",
    z = -2,
    y = 2,
    x = -1,
  },
  {
    type = "AIR",
    z = -1,
    y = 2,
    x = -1,
  },
  {
    type = "AIR",
    z = 0,
    y = 2,
    x = -1,
  },
  {
    type = "AIR",
    z = 1,
    y = 2,
    x = -1,
  },
  {
    type = "AIR",
    z = 2,
    y = 2,
    x = -1,
  },
  {
    type = "SOLID",
    z = 0,
    y = -3,
    x = 0,
  },
  {
    type = "SOLID",
    z = -2,
    y = -2,
    x = 0,
  },
  {
    type = "SOLID",
    z = -1,
    y = -2,
    x = 0,
  },
  {
    type = "SOLID",
    z = 0,
    y = -2,
    x = 0,
  },
  {
    type = "SOLID",
    z = 1,
    y = -2,
    x = 0,
  },
  {
    type = "SOLID",
    z = 2,
    y = -2,
    x = 0,
  },
  {
    type = "SOLID",
    z = -2,
    y = -1,
    x = 0,
  },
  {
    type = "SOLID",
    z = -1,
    y = -1,
    x = 0,
  },
  {
    type = "SOLID",
    z = 0,
    y = -1,
    x = 0,
  },
  {
    type = "SOLID",
    z = 1,
    y = -1,
    x = 0,
  },
  {
    type = "AIR",
    z = 2,
    y = -1,
    x = 0,
  },
  {
    type = "AIR",
    z = -3,
    y = 0,
    x = 0,
  },
  {
    type = "AIR",
    z = -2,
    y = 0,
    x = 0,
  },
  {
    type = "AIR",
    z = -1,
    y = 0,
    x = 0,
  },
  {
    type = "AIR",
    z = 1,
    y = 0,
    x = 0,
  },
  {
    type = "AIR",
    z = 2,
    y = 0,
    x = 0,
  },
  {
    type = "AIR",
    z = 3,
    y = 0,
    x = 0,
  },
  {
    type = "AIR",
    z = -2,
    y = 1,
    x = 0,
  },
  {
    type = "AIR",
    z = -1,
    y = 1,
    x = 0,
  },
  {
    type = "AIR",
    z = 0,
    y = 1,
    x = 0,
  },
  {
    type = "AIR",
    z = 1,
    y = 1,
    x = 0,
  },
  {
    type = "AIR",
    z = 2,
    y = 1,
    x = 0,
  },
  {
    type = "AIR",
    z = -2,
    y = 2,
    x = 0,
  },
  {
    type = "AIR",
    z = -1,
    y = 2,
    x = 0,
  },
  {
    type = "AIR",
    z = 0,
    y = 2,
    x = 0,
  },
  {
    type = "AIR",
    z = 1,
    y = 2,
    x = 0,
  },
  {
    type = "AIR",
    z = 2,
    y = 2,
    x = 0,
  },
  {
    type = "AIR",
    z = 0,
    y = 3,
    x = 0,
  },
  {
    type = "SOLID",
    z = -2,
    y = -2,
    x = 1,
  },
  {
    type = "SOLID",
    z = -1,
    y = -2,
    x = 1,
  },
  {
    type = "SOLID",
    z = 0,
    y = -2,
    x = 1,
  },
  {
    type = "SOLID",
    z = 1,
    y = -2,
    x = 1,
  },
  {
    type = "SOLID",
    z = 2,
    y = -2,
    x = 1,
  },
  {
    type = "SOLID",
    z = -2,
    y = -1,
    x = 1,
  },
  {
    type = "SOLID",
    z = -1,
    y = -1,
    x = 1,
  },
  {
    type = "SOLID",
    z = 0,
    y = -1,
    x = 1,
  },
  {
    type = "SOLID",
    z = 1,
    y = -1,
    x = 1,
  },
  {
    type = "AIR",
    z = 2,
    y = -1,
    x = 1,
  },
  {
    type = "AIR",
    z = -2,
    y = 0,
    x = 1,
  },
  {
    type = "AIR",
    z = -1,
    y = 0,
    x = 1,
  },
  {
    type = "AIR",
    z = 0,
    y = 0,
    x = 1,
  },
  {
    type = "AIR",
    z = 1,
    y = 0,
    x = 1,
  },
  {
    type = "AIR",
    z = 2,
    y = 0,
    x = 1,
  },
  {
    type = "AIR",
    z = -2,
    y = 1,
    x = 1,
  },
  {
    type = "AIR",
    z = -1,
    y = 1,
    x = 1,
  },
  {
    type = "AIR",
    z = 0,
    y = 1,
    x = 1,
  },
  {
    type = "AIR",
    z = 1,
    y = 1,
    x = 1,
  },
  {
    type = "AIR",
    z = 2,
    y = 1,
    x = 1,
  },
  {
    type = "AIR",
    z = -2,
    y = 2,
    x = 1,
  },
  {
    type = "AIR",
    z = -1,
    y = 2,
    x = 1,
  },
  {
    type = "AIR",
    z = 0,
    y = 2,
    x = 1,
  },
  {
    type = "AIR",
    z = 1,
    y = 2,
    x = 1,
  },
  {
    type = "AIR",
    z = 2,
    y = 2,
    x = 1,
  },
  {
    type = "SOLID",
    z = -1,
    y = -2,
    x = 2,
  },
  {
    type = "SOLID",
    z = 0,
    y = -2,
    x = 2,
  },
  {
    type = "SOLID",
    z = 1,
    y = -2,
    x = 2,
  },
  {
    type = "SOLID",
    z = -2,
    y = -1,
    x = 2,
  },
  {
    type = "SOLID",
    z = -1,
    y = -1,
    x = 2,
  },
  {
    type = "SOLID",
    z = 0,
    y = -1,
    x = 2,
  },
  {
    type = "SOLID",
    z = 1,
    y = -1,
    x = 2,
  },
  {
    type = "SOLID",
    z = 2,
    y = -1,
    x = 2,
  },
  {
    type = "AIR",
    z = -2,
    y = 0,
    x = 2,
  },
  {
    type = "AIR",
    z = -1,
    y = 0,
    x = 2,
  },
  {
    type = "AIR",
    z = 0,
    y = 0,
    x = 2,
  },
  {
    type = "AIR",
    z = 1,
    y = 0,
    x = 2,
  },
  {
    type = "SOLID",
    z = 2,
    y = 0,
    x = 2,
  },
  {
    type = "AIR",
    z = -2,
    y = 1,
    x = 2,
  },
  {
    type = "AIR",
    z = -1,
    y = 1,
    x = 2,
  },
  {
    type = "AIR",
    z = 0,
    y = 1,
    x = 2,
  },
  {
    type = "AIR",
    z = 1,
    y = 1,
    x = 2,
  },
  {
    type = "AIR",
    z = 2,
    y = 1,
    x = 2,
  },
  {
    type = "AIR",
    z = -1,
    y = 2,
    x = 2,
  },
  {
    type = "AIR",
    z = 0,
    y = 2,
    x = 2,
  },
  {
    type = "AIR",
    z = 1,
    y = 2,
    x = 2,
  },
  {
    type = "AIR",
    z = 0,
    y = 0,
    x = 3,
  },
}
this is awesome that the code actually worked for a change, but I was looking for a table looking like this:

 vsn = {1,1,1,3,3,3,3,2,2,2,2,1,L, L,L,0, 0, 0, 0, 0}

25 entries consisting of the distance of the closest block (1,3) in the z axis or if its air then 0, and for liquids "L"
Any advice to make it happen? thanks a lot man, really helped me out
Edited on 08 July 2015 - 09:41 PM
Bomb Bloke #5
Posted 09 July 2015 - 02:33 AM
The table the scanner is giving you may not have enough information in it to get much accuracy. It seems to represent a small sphere centered around the turtle - so at eg x3, the only point covered is y0/z0, and ditto for x-3.

But anyway, the way to go would be to build two two-dimensional tables: One to track the deepest known block checked within the scan, and one to track the content of that block.

Spoiler
--Variables &amp; Such

local s   = peripheral.wrap("left")
local scn = s.sonicScan()
local vsn = {}

local xmin, xmax, ymin, ymax, zmin, zmax = -2, 2, -2, 2, 1, 3

local xrange, yrange = xmax - xmin + 1, ymax - ymin + 1

--**--Start--**--

-- Pre-fill the results table with "air":
local results = {}
for y = 1, yrange do
	results[y] = {}
	for x = 1, xrange do
		results[y][x] = 0
	end
end

local checked = {}
for i = 1, yrange do checked[i] = {} end

for i, v in ipairs(scn) do
	local thisX, thisY = v.x - xmin + 1, v.y - ymin + 1
	
	-- If the current block is within our range of interest, and isn't air, and we haven't already found something along this x/y co-ord that has a closer z co-ord, then...
	if v.y >= ymin and v.y <= ymax and v.x >= xmin and v.x <= xmax and v.z >= zmin and v.z <= zmax and v.type ~= "AIR" and ((not checked[thisY][thisX]) or checked[thisY][thisX] > v.z) then
		checked[thisY][thisX] = v.z  -- Record that the closest block we currently know of along this x/y co-ord is at this z co-ord.
		results[thisY][thisX] = v.type == "LIQUID" and "l" or v.z  -- Either reference the found thing as an "l" or as the distance.
	end
end

for y = 1, #results do
	for x = 1, #results[y] do
		write(results[y][x] .. ",")
	end
	
	print()
end
WestWindsDemon #6
Posted 09 July 2015 - 11:55 PM
While I can't test the code right now, I am trying to understand it… working on it. If it helps you what the turtle currently sees its:



y= -2 / 2
  X

y= -1 / 1
XXXXX
XXXXX
XXXXX
XXXXX
XXXXX

y= 0
...X
.XXXXX
.XXXXX
XXXXXXX
.XXXXX
.XXXXX
...X
WestWindsDemon #7
Posted 12 July 2015 - 01:37 AM
So… I've been thinking and haven't actually tried it yet, would a repeat loop work for the z axis? looking into the depth? going to try in a bit, wish me luck!
Bomb Bloke #8
Posted 12 July 2015 - 01:48 AM
Technically you could make any sort of loop work. A single "for" loop seems most efficient to me.
WestWindsDemon #9
Posted 19 July 2015 - 02:22 AM
Hi guys, I've been tinkering with my code, using Bomb Bloke and some friends suggestions and changed my code a bit, I'ts now very close to what I'm looking for but still having problems, first here's the code:

Spoiler


--: eye V:1.5
--Variables &amp; Such

s	  = peripheral.wrap("left")
modem  = peripheral.wrap("right")
scn	= s.sonicScan()
vsn	= {}

function tableBuild()	 --This pre-fabricates my table with "A" (air), in the format that I'm looking for
for once = 1, 25 do
  vsn[once] = "A"
end
print("# in vsn: "..#vsn)
end

function send()	--A very rustic way to send the table over to the pocket computer
rednet.open("right")
rednet.send(0, textutils.serialize(vsn))
end

--**--Start--**--

tableBuild()

--while true do
   pix = 1
   for tabY = 2, -2, -1 do   --Finally discovered how to run for loops backwards, number wise
	  for tabX = -2, 2, 1 do
		 for tabZ = 1, 3, 1 do
			   for ite, dat in pairs(scn) do
				  if dat.type == "SOLID" and dat.z == tabZ*-1 and dat.y == tabY*-1 and dat.x == tabX then   --This format correlates with the layout of the scn array

						   if rs.getInput("back") == true then   --This is a litle trouble shooting thingy I made, works with a lever on the back
							  textutils.slowPrint("pix "..pix..", "..dat.type..", in x:"..dat.x..", z:"..dat.z.." ("..tabY..", "..tabX..")")
						   elseif rs.getInput("back") ~= true then
							  print("pix "..pix..", "..dat.type..", in x:"..dat.x..", z:"..dat.z.." ("..tabY..", "..tabX..")")
						   end

						vsn[pix] = tabZ

				  elseif dat.type == "LIQUID" and dat.z == tabZ*-1 and dat.y == tabY*-1 and dat.x == tabX then
						print("pix "..pix..", "..dat.type)
						vsn[pix] = "L"
						--pix = pix + 1
				  end
			   end
		 end
		 pix = pix + 1
	  end
   end
--end

print("finished loop")

myFile = fs.open("ver1_post_prog.txt", "w")
myFile.writeLine(textutils.serialize(vsn))
myFile.close()

send()

V=0
for verify, n in pairs(vsn) do
   if vsn[verify] ~= "A" then V = V + 1 end
end
print("# in vsn: "..#vsn..", non 'A' in vsn: "..V)




This piece of code is for some reason repeating the tabX, I can't figure out why, I attached a screenshot of it: [attachment=2332:2015-07-18_21.17.35.png]
The "ver1_post_prog.txt" file has this:

Spoiler


{
  1,
  2,
  2,
  2,
  1,
  2,
  2,
  2,
  2,
  2,
  2,
  2,
  3,
  2,
  2,
  2,
  2,
  2,
  2,
  2,
  1,
  2,
  2,
  2,
  1,
}


where in reality it should always be all 1, because there is literally a wall right in front of the turtle.
I feel that thanks to you I'm really close to my goal and I really want to see it thru.
Bomb Bloke #10
Posted 19 July 2015 - 05:03 AM
This piece of code is for some reason repeating the tabX, I can't figure out why,

Well, thanks to your nested loops you'll be checking each tabY five times once for each tabX you check, further times three for each tabZ you inspect… You've got nothing in the code to stop any of your loops early, so, um, what did you expect?

I suppose a simple "fix" would be:

for tabZ = 3, 1, -1 do

This way you won't be replacing information you gather about "closer" blocks, with information you later gather about "further" blocks - you'll instead do the reverse.
Edited on 19 July 2015 - 03:06 AM
WestWindsDemon #11
Posted 20 July 2015 - 12:52 AM
It is with great joy that I say thank you for putting up with me, I (with Bomb Bloke's help of course) managed to complete the code, doing what I wanted it to do.

Here's the final code:

Spoiler

--: eye V:1.5
--Variables &amp; Such
s      = peripheral.wrap("left")
modem  = peripheral.wrap("right")
scn    = s.sonicScan()
vsn    = {}

function tableBuild()
 for once = 1, 25 do
  vsn[once] = "A"
 end 
 print("# in vsn: "..#vsn)
end

function send()
 rednet.open("right")
 rednet.send(0, textutils.serialize(vsn))
end

--**--Start--**--
tableBuild()

--while true do
   pix = 1
   for tabY = 2, -2, -1 do
      for tabX = -2, 2, 1 do
         for tabZ = 1, 3, 1 do
            for ite, dat in pairs(scn) do
               if dat.type == "SOLID" and dat.z == tabZ*-1 and dat.y == tabY*1 and dat.x == tabX then

                  if rs.getInput("back") == true then
                     textutils.slowPrint("pix "..pix..", "..dat.type..", in x:"..dat.x..", z:"..dat.z.." ("..tabY..", "..tabX..") + "..tabZ)
                  elseif rs.getInput("back") ~= true then
                     print("pix "..pix..", "..dat.type..", in x:"..dat.x..", z:"..dat.z.." ("..tabY..", "..tabX..") + "..tabZ)
                  end

                  vsn[pix] = tabZ
                  break

               elseif dat.type == "LIQUID" and dat.z == tabZ*-1 and dat.y == tabY*-1 and dat.x == tabX then
                  print("pix "..pix..", "..dat.type)
                  vsn[pix] = "L"
                  break

               end
            end
         end
         pix = pix + 1
      end
   end
--end

print("finished loop")
myFile = fs.open("ver1_post_prog.txt", "w")
myFile.writeLine(textutils.serialize(vsn))
myFile.close()

send()


V=0
for verify, n in pairs(vsn) do
   if vsn[verify] ~= "A" then V = V + 1 end
end
print("# in vsn: "..#vsn..", non 'A' in vsn: "..V)


Now all I have left is to finish the program! Thanks!