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

line 29: 'for' limit must be a number

Started by ep1cspray, 27 December 2012 - 03:39 PM
ep1cspray #1
Posted 27 December 2012 - 04:39 PM
Not sure what is causing this.

EDIT: line 28 is where the error occurs.



local function digging()
   turtle.dig()
   turtle.forward()
   for j = 1,3 do
	   turtle.digUp()
	   turtle.up()
   end
   turtle.turnLeft()
   for j = 1,4 do
	  turtle.dig()
	  turtle.down()
   end
   turtle.turnRight()
   turtle.turnRight()
   for j = 1,4 do
	  turtle.up()
   end
   for j = 1,4 do
   turtle.dig()
   turtle.down()
   end
   turtle.turnLeft()
end

print("How far?")
dist = tonumber read()
n = 1
for i = 1, dist do
   digging()
   n = n + 1
   if n == 5 then
	  turtle.turnRight()
	  turtle.select(1)
	  turtle.place()
	  n = 1
   end
end
coranos #2
Posted 27 December 2012 - 04:46 PM
shouldnt it be
dist = tonumber( read())
ep1cspray #3
Posted 27 December 2012 - 04:47 PM
Ill try that.

EDIT: Thank you :D/>
coranos #4
Posted 27 December 2012 - 05:34 PM
sure thing :)/>