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

[DEBUGGING]

Started by jadelade, 01 May 2013 - 10:55 AM
jadelade #1
Posted 01 May 2013 - 12:55 PM
Hi,
I'm getting a error (attempt to perform arithmetic __add on number and nil) that i can't punch out of the program. i will put a indicator on with line the error is in

PS sorry if the long line are hard to read I don't know how to make them easier on the eyes.

Spoiler
local objectPics = {
{
  {
	"88f88",
	"8fff8",
	"f8f8f",
	"88f88",
	"88f88"
  },
  {
	"88f88",
	"88f88",
	"f8f8f",
	"8fff8",
	"88f88"
  },
  {
	"888f8",
	"88f88",
	"8f888",
	"88f88",
	"888f8"
  },
  {
	"8f888",
	"88f88",
	"888f8",
	"88f88",
	"8f888"
  }
},
{
  {
	"88888",
	"8f8f8",
	"f888f",
	"8f8f8",
	"88888"
  },
  {
	"fffff",
	"ff888",
	"f8f88",
	"f88f8",
	"8888f"
  },
  {
	"f8f8f",
	"8ff8f",
	"ff888",
	"888ff",
	"ff8ff"
  },
  {
	"88888",
	"88f88",
	"8fff8",
	"88f88",
	"88888"
  }
},
{
  {
	"88888",
	"f888f",
	"f888f",
	"8f8f8",
	"88f88"
  },
  {
	"88888",
	"8f88f",
	"888f8",
	"8f8ff",
	"8f8f8"
  },
  {
	"88888",
	"f8ff8",
	"ff88f",
	"f8888",
	"f8888"
  }
}
}


local colorPal = {}

for i=1,16 do
  colorPal[string.sub("0123456789abcdef",i,i)] = 2^(i-1)
end

for actionRow=1,2 do
  for actionObject=1,4 do
	for picRow=1,5 do
	  for picPixel=1,5 do
		term.setCursorPos((actionObject-1)*6+27+picPixel,(actionRow-1)*6+1+picRow)
		term.setBackgroundColor(colorPal[string.sub(objectPics[actionRow][actionObject][picRow],picPixel,picPixel)])
		write(" ")
	  end
	end
  end
end

for actionObject=1,3 do
  for PicRow=1,5 do
	for picPixel=1,5 do
	  term.setCursorPos((actionObject-1)*6+27+picPixel,(2)*6+1+picRow)------------------------------------------------------------------------------------------------------ERROR
	  term.setBackgroundColor(colorPal[string.sub(objectPics[3][actionObject][picRow],picPixel,picPixel)])
	  write(" ")
	end
  end
end
remiX #2
Posted 01 May 2013 - 01:23 PM
Your for loop is this:
for PicRow=1,5 do
but you're accessing the variable as picRow. LuA is CasE SenSitiVe

Also with your term.setBackgroundColor calls:
term.setBackgroundColor(colorPal[string.sub(objectPics[actionRow][actionObject][picRow],picPixel,picPixel)])
Looks a bit wonky, the commas would error? Thats like accessing a table within a table within a table within a table within a table within a table
jadelade #3
Posted 01 May 2013 - 01:49 PM
gaaaaa i had lots of bugs that i put a capital in the wrong place and it took me a week to find them and one time 2 months
:wacko:/> Thanks