Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --the turtle places blocks for 'height' blocks, then turns around and repeats until it has placed 'width' rows
- local width = raw_input("How long do you want your build?")
- local height = raw_input("How wide do you want your build?")
- function back()
- if not turtle.back() then
- print("Something's in the way!")
- return false
- end
- return true
- end
- function place()
- selected = 0
- while(turtle.place() == false) do
- selected = selected + 1
- if selected == 17 then
- print("Out of blocks or block already placed!")
- return false
- end
- turtle.select(selected)
- end
- return true
- end
- for w = 1, width do
- for h = 2, height do
- if not (place() and back()) then
- return
- end
- end
- if not place() then
- return
- end
- if w % 2 == 0 then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- if not back() then
- return
- end
- if w % 2 == 0 then
- turtle.turnRight()
- else
- turtle.turnLeft()
- end
- if not (back() and back()) then
- return
- end
- end
- print("Job finished successfully")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement