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

What am I doing wrong?

Started by Levistator, 11 July 2013 - 01:20 PM
Levistator #1
Posted 11 July 2013 - 03:20 PM
Every time I try to run my program, I get an error reading, "mainTunnel :3: attempt to index ? (a nil value.)"
For the command line arguments I put in "4 3 2". Please help. I have looked at all of the tutorials i could find on these arguments and I can't figure out what went wrong.


local tArgs = {...}
local width = tArgs[1]
local height = tARgs[2]
local depth = tArgs[3]

function moveRight()
  turtle.turnRight()
  turtle.forward()
  turtle.turnLeft()
end


function moveLeft()
  turtle.turnLeft()
  turtle.forward()
  turtle.turnRight()
end

 m=0

function row()
  if m==0 then
    for i=1,width do
	  turtle.dig()
	  moveRight()
    end
    m=1
  else
    for i=1,width do
	  turtle.dig()
	  moveLeft()
    end
    m=0
  end
end

function tunnelHeight()
  for i=1,height do
    row()
    turtle.up()
  end
end

function resetTurtlePos()
  if m==0 then
    for i=1,height do
	  turtle.down()
    end
    for i=1,width do
	  moveLeft()
    end
  else
    for i=1,height do
	  turtle.down()
    end
  end
  turtle.forward()
end

tunnelHeight()
resetTurtlePos()
Edited by
Lyqyd #2
Posted 12 July 2013 - 01:15 AM
Split into new topic.

You have tARgs, it should be tArgs. Capitalization is important.
Levistator #3
Posted 12 July 2013 - 02:49 PM
*facepalm* thanks