Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- dbug=true
- local function roadLength(rs)
- if dbug then
- print("roadLength")
- end
- items=0
- for i=1,15 do
- print(i)
- print(rs)
- turtle.select(i)
- if turtle.compareTo(rs) then
- items=turtle.getItemCount(i)+items
- end
- end
- print(items)
- return items/2
- end
- local function moveForward()
- if dbug then
- print("moveForward")
- end
- while not turtle.forward() do
- turtle.attack()
- end
- end
- local function getItem()
- if dbug then
- print("getItem")
- end
- while currentSlot ~= referenceSlot do
- turtle.select(currentSlot)
- while turtle.compareTo(referenceSlot) do
- return true
- end
- currentSlot=currentSlot+1
- end
- quit=true
- return false
- end
- local function dig()
- if dbug then
- print("dig")
- end
- turtle.dig()
- turtle.digUp()
- turtle.digDown()
- turtle.up()
- turtle.digUp()
- turtle.down()
- end
- local function clearArea()
- if dbug then
- print("clearArea")
- end
- dig()
- if getItem() then
- turtle.placeDown()
- turtle.turnLeft()
- turtle.dig()
- moveForward()
- turtle.turnRight()
- dig()
- end
- if getItem() then
- turtle.placeDown()
- turtle.turnRight()
- moveForward()
- turtle.turnLeft()
- end
- end
- --Start
- xPos,zPos=0,0
- xDir,zDir=0,1
- height=0
- referenceSlot=16
- currentSlot=1
- quit=false
- zMax=roadLength(referenceSlot)
- if dbug then
- print(xPos .. "," .. zPos)
- print(xDir .. "," .. zDir)
- print(height)
- print(zMax)
- end
- print("Starting...")
- turtle.dig()
- while zPos < zMax and not quit do
- moveForward()
- zPos=zPos+1
- print("zPos: " .. zPos)
- clearArea()
- end
- print("zPos: " .. zPos)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement