Posted 06 December 2012 - 11:53 PM
I have been wondering how to do this for several of my projects and now i have to ask for guidance :)/>
I'm making a turtle program that will build a flat surface depending on the input it receives through the read() command.
So far it is working well but i'm having problems with the for loop for the width of the build. When the turtle gets to the end of the lenght of the build i want it to turn right and go on to building the next lane of the length and then when that one is done turn left. This way it will zig zag up and down the build. But how do i tell it that every second time in the for loop i want it to do that?
I'm also wondering how i can make it – turtle.select() – the next slot when the 64 blocks in slot 1 have been used up?
Thanks for taking your time and helping me :)/>
I'm making a turtle program that will build a flat surface depending on the input it receives through the read() command.
So far it is working well but i'm having problems with the for loop for the width of the build. When the turtle gets to the end of the lenght of the build i want it to turn right and go on to building the next lane of the length and then when that one is done turn left. This way it will zig zag up and down the build. But how do i tell it that every second time in the for loop i want it to do that?
I'm also wondering how i can make it – turtle.select() – the next slot when the 64 blocks in slot 1 have been used up?
Thanks for taking your time and helping me :)/>
term.clear()
term.setCursorPos(1,1)
function tryForward()
if not turtle.forward() then
turtle.dig()
turtle.forward()
end
end
function compare()
if turtle.compareDown() == false then
turtle.digDown()
turtle.placeDown()
end
end
function build()
tryForward()
compare()
end
print "How long do you want me to build?"
length = read()
print "How wide do yo want me to build?"
width = read()
for i=1,width do
compare()
for i=1,length - 1 do
build()
end
turtle.turnRight()
turtle.forward()
turtle.turnRight()
compare()
for i=1,length - 1 do
build()
end
turtle.turnLeft()
turtle.forward()
turtle.turnLeft()
compare()
end