Posted 24 March 2013 - 12:40 PM
I have a strange bug with this code :
turtle.dig()
turtle.forward()
if j == 4 then
turtle.turnRight()
turtle.turnRight()
turtle.select(1)
turtle.place()
turtle.turnRight()
turtle.turnRight()
j = 0
else
j = j + 1
end
turtle.turnLeft()
turtle.dig()
turtle.turnRight()
turtle.turnRight()
turtle.dig()
turtle.digUp()
turtle.up()
turtle.dig()
turtle.turnLeft()
turtle.turnLeft()
turtle.dig()
turtle.digUp()
turtle.up()
turtle.dig()
turtle.turnRight()
turtle.turnRight()
turtle.dig()
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.turnLeft()
turtle.dig()
turtle.turnRight()
turtle.turnRight()
turtle.dig()
turtle.digDown()
turtle.down()
urtle.dig()
turtle.turnLeft()
turtle.turnLeft()
turtle.dig()
turtle.digDown()
turtle.down()
turtle.dig()
turtle.turnRight()
turtle.turnRight()
turtle.dig()
turtle.turnLeft()
return j
end
function carburant()
if turtle.getFuelLevel() < 6 then
turtle.select(2)
turtle.refuel()
end
end
shell.run('clear')
print("Veuillez mettre les torches dans le premier slot et le carburant dans le second\n")
print("Veuillez entrer la distance a creuser : ")
local i = io.read()
local j = 8
local continuer = "true"
while continuer do
if (i < 0) or (i == 0) then
continuer = "false"
end
carburant()
j = creuser(j)
i = i - 2
end
This is a code to do a tunnel and place torch. But I have this error :
Thanks
Spoiler
local function creuser(j)turtle.dig()
turtle.forward()
if j == 4 then
turtle.turnRight()
turtle.turnRight()
turtle.select(1)
turtle.place()
turtle.turnRight()
turtle.turnRight()
j = 0
else
j = j + 1
end
turtle.turnLeft()
turtle.dig()
turtle.turnRight()
turtle.turnRight()
turtle.dig()
turtle.digUp()
turtle.up()
turtle.dig()
turtle.turnLeft()
turtle.turnLeft()
turtle.dig()
turtle.digUp()
turtle.up()
turtle.dig()
turtle.turnRight()
turtle.turnRight()
turtle.dig()
turtle.turnLeft()
turtle.dig()
turtle.forward()
turtle.turnLeft()
turtle.dig()
turtle.turnRight()
turtle.turnRight()
turtle.dig()
turtle.digDown()
turtle.down()
urtle.dig()
turtle.turnLeft()
turtle.turnLeft()
turtle.dig()
turtle.digDown()
turtle.down()
turtle.dig()
turtle.turnRight()
turtle.turnRight()
turtle.dig()
turtle.turnLeft()
return j
end
function carburant()
if turtle.getFuelLevel() < 6 then
turtle.select(2)
turtle.refuel()
end
end
shell.run('clear')
print("Veuillez mettre les torches dans le premier slot et le carburant dans le second\n")
print("Veuillez entrer la distance a creuser : ")
local i = io.read()
local j = 8
local continuer = "true"
while continuer do
if (i < 0) or (i == 0) then
continuer = "false"
end
carburant()
j = creuser(j)
i = i - 2
end
This is a code to do a tunnel and place torch. But I have this error :
I think is due to the variable i that is string however I enter a number.tunnel_v1:71: attempt to compare number with string expected, got number
Thanks