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

Error/Question

Started by Bpwoods, 02 January 2013 - 10:36 AM
Bpwoods #1
Posted 02 January 2013 - 11:36 AM
Ok, so the Error I'm getting is with the code below. (I'm running tekkit 1.2.5, not CC 1.4.6) When i try to run the program, i get the error "Tunnel :5: 'for' limit must be a number". I'm not sure why I'm getting this error, does anyone know?





print("How far?")
dist = tonumber read()
n = 1

for i = 1, dist do
while turtle.detect() do
turtle.dig()
sleep(0.25)
end
turtle.forward()
turtle.digUp()
n = n + 1
if not turtle.detectDown() then
turtle.select(2)
turtle.placeDown()
end
if n == 7 then
turtle.turnLeft()
turtle.dig()
turtle.select(1)
turtle.place()
turtle.turnRight()
n = 1
end
end
Doyle3694 #2
Posted 02 January 2013 - 01:11 PM
tonumber() is actually a function, and so it needs parentheses. Change second line to

dist = tonumber(read())
Bpwoods #3
Posted 02 January 2013 - 02:24 PM
Thanks so much man, that worked :D/>