Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function isEmpty(i)
- if turtle.getItemCount(i)==0 then
- print("Slot empty. Changing Slot")
- return true
- else
- return false
- end
- end
- function shiftLeft()
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- end
- function shiftRight()
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- end
- function checkFront()
- if turtle.detect() then
- turtle.dig()
- end
- end
- function compareDown(i)
- turtle.select(16)
- if turtle.compareDown() then
- turtle.select(i)
- return true
- else
- turtle.select(i)
- return false
- end
- end
- function digDown()
- turtle.digDown()
- end
- function dig()
- turtle.dig()
- end
- function placeDown()
- turtle.placeDown()
- end
- --Main
- io.write("Enter Length: ")
- length = tonumber(io.read())
- io.write("Enter Width: ")
- width = tonumber(io.read())
- itemIndex = 1
- turtle.select(itemIndex)
- widthCount = 0
- while true do
- for l=1, (length) do
- if (compareDown(itemIndex)~=true) then
- digDown()
- if isEmpty(itemIndex) then
- itemIndex = itemIndex+1
- turtle.select(itemIndex)
- end
- placeDown()
- end
- checkFront()
- turtle.forward()
- if (compareDown(itemIndex)~=true) then
- digDown()
- if isEmpty(itemIndex) then
- itemIndex = itemIndex+1
- turtle.select(itemIndex)
- end
- placeDown()
- end
- end
- widthCount = widthCount+1
- if widthCount==width then
- break
- end
- shiftRight()
- for l=1, (length) do
- if (compareDown(itemIndex)~=true) then
- digDown()
- if isEmpty(itemIndex) then
- itemIndex = itemIndex+1
- turtle.select(itemIndex)
- end
- placeDown()
- end
- checkFront()
- turtle.forward()
- if (compareDown(itemIndex)~=true) then
- digDown()
- if isEmpty(itemIndex) then
- itemIndex = itemIndex+1
- turtle.select(itemIndex)
- end
- placeDown()
- end
- end
- widthCount = widthCount+1
- if widthCount==width then
- break
- end
- shiftLeft()
- end
- if (width%2)~=0 then
- for i=1, length do
- turtle.back()
- end
- end
- --[[
- function isEmpty(i)
- if turtle.getItemCount(i)==1 then
- print("Empty")
- return true
- end
- end
- function shiftLeft()
- turtle.turnLeft()
- turtle.dig()
- turtle.forward()
- turtle.turnLeft()
- end
- function shiftRight()
- turtle.turnRight()
- turtle.dig()
- turtle.forward()
- turtle.turnRight()
- end
- function widthCheck(a, b)
- if a == b then
- return true
- end
- return false
- end
- --Main
- io.write("Enter Length: ")
- length = tonumber(io.read())
- io.write("Enter Width: ")
- width = tonumber(io.read())
- itemIndex = 1
- turtle.select(itemIndex)
- widthCount = 0
- while true do
- for l=1, length do
- if turtle.detect() then
- turtle.dig()
- end
- if (turtle.compareDown() == false) then
- turtle.digDown()
- if isEmpty(itemIndex) then
- itemIndex = itemIndex + 1
- turtle.select(itemIndex)
- end
- turtle.placeDown()
- end
- end
- widthCount = widthCount+1
- if widthCheck(widthCount, width) then
- break
- end
- shiftRight()
- for l=1, length do
- if turtle.detect() then
- turtle.dig()
- end
- if (turtle.compareDown() == false) then
- turtle.digDown()
- if isEmpty(itemIndex) then
- itemIndex = itemIndex + 1
- turtle.select(itemIndex)
- end
- turtle.placeDown()
- end
- end
- widthCount = widthCount+1
- if widthCheck(widthCount, width) then
- break
- end
- shiftLeft()
- end
- if (width%2) > 0 then
- for i=1, length do
- turtle.back()
- end
- end
- --]]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement