Posted 04 January 2013 - 06:21 PM
Hi, I'm building a basic floor filler to learn LUA. Here's the code:
There is no error, but when I set the program to run the turtle moves forwards and places blocks underneath itself as it should, but when it detects a block it does nothing. Can anybody figure out why this is?
Thanks very much.
--Startup
turtle.forward()
--Variables
itemcount=1
--Functions
function mainline()
repeat
turtle.forward()
turtle.placeDown()
until turtle.detect() == false
end
function returnto()
turtle.turnRight()
turtle.turnRight()
repeat
turtle.forward()
until turtle.detect() == false
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
end
--Run
while turtle.getFuelLevel() > 100 do
if turtle.detect() then
returnto()
else
turtle.select(itemcount)
mainline()
end
if turtle.getItemCount(itemcount) == 1 then
itemcount = itemcount + 1
turtle.select(itemcount)
end
end
There is no error, but when I set the program to run the turtle moves forwards and places blocks underneath itself as it should, but when it detects a block it does nothing. Can anybody figure out why this is?
Thanks very much.