Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function isEmpty(i)
- if turtle.getItemCount(i)==0 then
- print("Empty")
- return true
- end
- end
- function shiftLeft()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- end
- function shiftRight()
- turtle.turnRight()
- turtle.forward()
- turtle.turnLeft()
- end
- function widthCheck(a, b)
- if a == b then
- return true
- end
- return false
- end
- function shiftDirection(d)
- if d == "left" then
- shiftLeft()
- end
- if d == "right" then
- shiftRight()
- end
- end
- --Main
- io.write("Enter Length: ")
- height = tonumber(io.read())
- io.write("Enter Width: ")
- width = tonumber(io.read())
- io.write("Direction- left or right: ")
- direction = string.lower(io.read())
- itemIndex = 1
- turtle.select(itemIndex)
- widthCount = 0
- while true do
- for i=1, height-1 do
- if isEmpty(itemIndex) then
- itemIndex = itemIndex + 1
- turtle.select(itemIndex)
- end
- turtle.place()
- turtle.up()
- end
- if isEmpty(itemIndex) then
- itemIndex = itemIndex + 1
- turtle.select(itemIndex)
- end
- turtle.place()
- widthCount = widthCount+1
- if widthCheck(widthCount, width) then
- break
- end
- shiftDirection(direction)
- for i=1, height-1 do
- if isEmpty(itemIndex) then
- itemIndex = itemIndex + 1
- turtle.select(itemIndex)
- end
- turtle.place()
- turtle.down()
- end
- if isEmpty(itemIndex) then
- itemIndex = itemIndex + 1
- turtle.select(itemIndex)
- end
- turtle.place()
- widthCount = widthCount+1
- if widthCheck(widthCount, width) then
- break
- end
- shiftDirection(direction)
- end
- if (width%2) > 0 then
- for i=1, height do
- turtle.down()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement