Posted 17 October 2013 - 11:28 PM
I keep recieving this error
Mine:67: 'for' limit must be a number
I have looked at line 67 and I am not sure how to fix this problem.
Mine:67: 'for' limit must be a number
I have looked at line 67 and I am not sure how to fix this problem.
-- Mining Turtle
function checkFuel()
print ("Checking fuel level")
if turtle.getFuelLevel() <= 10 then
print ("Re-fueling")
turtle.select(13)
turtle.refuel(1)
else
print ("No fuel needed")
end
end
function turnAround()
turtle.turnRight()
turtle.turnRight()
end
function dig()
if turtle.detect() == true then
repeat
turtle.dig()
sleep(0.80)
until turtle.detect() == false
end
turtle.forward()
if turtle.detectUp() then
repeat
turtle.digUp()
sleep(0.80)
until turtle.detectUp() == false
end
turtle.turnLeft()
if turtle.detect() == true then
repeat
turtle.dig()
sleep(0.80)
until turtle.detect() == false
end
turtle.up()
if turtle.detect() == true then
repeat
turtle.dig()
sleep(0.80)
until turtle.detect() == false
end
turtle.turnRight()
turtle.turnRight()
if turtle.detect() == true then
repeat
turtle.dig()
sleep(0.80)
until turtle.detect() == false
end
turtle.down()
if turtle.detect() == true then
repeat
turtle.dig()
sleep(0.80)
until turtle.detect() == false
end
turtle.turnLeft()
end
function tunnel
local distance = 0
for index = 1,givenLength do
dig()
if turtle.forward() then
distance = distance + 1
end
turtle.select(14)
turtle.placeDown()
if distance == 10 then
turtle.select(15)
print("Placing torch...")
turnAround()
turtle.placeDown()
turnAround()
distance = 0
checkFuel()
end
if turtle.getItemCount(12) ~= 0 then
turtle.digDown()
print("Placing Chest...")
turtle.select(16)
turtle.placeDown()
for i = 1,12 do
turtle.select(i)
turtle.dropDown()
end
end
end
turtle.up()
for index = 1,givenLength do
turtle.back()
end
turtle.down()
end
print("Input tunnel length:")
local length = read()
local fuelNeeded = length*5
fuelNeeded = fuelNeeded+length
local floorNeeded = length/5
local torchNeeded = length/10
local chestNeeded = length/25
local fuelLevel = turtle.getFuelLevel()
local floorLevel = turtle.getItemCount(14)
local torchLevel = turtle.getItemCount(15)
local chestLevel = turtle.getItemCount(16)
if fuelLevel < fuelNeeded then
print ("Please fuel into slot 13")
repeat
select(13)
sleep(0.8)
turtle.refuel(10)
fuelLevel = turtle.getFuelLevel()
until fuelLevel >= fuelNeeded
end
if floorLevel < floorNeeded then
print ("Please insert non-wood floor block into slot 14")
repeat
sleep(0.8)
floorLevel = turtle.getItemCount(14)
until floorLevel > floorNeeded
end
if torchLevel < torchNeeded then
print("Please insert torches into slot 15")
repeat
sleep(0.8)
torchLevel = turtle.getItemCount(15)
until torchLevel > torchNeeded
end
if chestLevel < chestNeeded then
print("Please insert chests into slot 16")
repeat
sleep(0.8)
chestLevel = turtle.getItemCount(16)
until chestLevel > chestNeeded
end
print("Resources aquired, Starting excavation...")
tunnel(givenLength)
print("The tunnel has been excavated!")