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

Lua: I can´t figure out repeat

Started by UGA_Warlock, 17 September 2012 - 08:52 AM
UGA_Warlock #1
Posted 17 September 2012 - 10:52 AM
Hey guys, i need some help with a wood farm im currently creating, im using a turtle as the harvester and placer

My problem is i want a it to detect if there is a block above and if there is break and move up.

local i = turtle.detectUp ()

repeat
turtle.digUp ()
turtle.up ()
print (i) – just to see if detect was working
until i == false

if there isnt a block its moving one up (not the problem) then problem is after it broke the blocks it keeps going up

Hope you can figure out what is wrong

thanks in advance
GopherAtl #2
Posted 17 September 2012 - 12:55 PM
DetectUp needs to be inside the loop! As written, it does detectup once, then repeats the rest forever of it detected anything at the start, or just once if it didn't.
sjele #3
Posted 17 September 2012 - 04:37 PM

while turtle.detectUp() do -- Starts a loop that continues until it does not detectup/it returns false
turtle.digUp()
turtle.up()
end --End while
Shorter version