Posted 22 October 2018 - 06:33 PM
I made the turtle is just for experimental reasons. The turtle should go through a small labyrinth. In order to do that, it should check: if there is not block in front it should go forward, else it should go left, but after I tried it this message popped up: l.lua:30: attempt to comparte __lt on nil and nil.
Code:
local x = 0
local y = 0
local z = 0
turtle.down()
if turtle.detect() then
local x = 1
else x = 0
end
if turtle.turnLeft() then
local y = 1
else y = 0
end
turtle.turnRight()
turtle.turnRight()
if turtle.detect() then
local z = 1
else z = 0
end
if x == y then
local a = 1 else
local a = 0
end
if x == z then
local b = 1 else
local b = 0
end
if a == b then
turtle.forward()
end
if a > b then
turtle.turnLeft()
turtle.forward()
end
if b > a then
turtle.turnRight()
turtle.forward()
end
PS. I don't have much knowledge about progamming, I just read the ComputerCraft Introductions
Code:
local x = 0
local y = 0
local z = 0
turtle.down()
if turtle.detect() then
local x = 1
else x = 0
end
if turtle.turnLeft() then
local y = 1
else y = 0
end
turtle.turnRight()
turtle.turnRight()
if turtle.detect() then
local z = 1
else z = 0
end
if x == y then
local a = 1 else
local a = 0
end
if x == z then
local b = 1 else
local b = 0
end
if a == b then
turtle.forward()
end
if a > b then
turtle.turnLeft()
turtle.forward()
end
if b > a then
turtle.turnRight()
turtle.forward()
end
PS. I don't have much knowledge about progamming, I just read the ComputerCraft Introductions