Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Direction: 0=up 1=right 2=down 3=left
- tX = 0
- tY = 0
- tDirection = 0
- backX = 0
- backY = 0
- backDirection = 0
- waiting = 12
- i = 0
- imax = 9
- j = 0
- jmax = 9
- direction = 0
- SelectedSlot = 13
- imax = imax - 1
- local function tTurnLeft()
- if tDirection ~= 0 then
- tDirection = tDirection - 1
- else
- tDirection = 3
- end
- turtle.turnLeft()
- end
- local function tTurnRight()
- if tDirection ~= 3 then
- tDirection = tDirection + 1
- else
- tDirection = 0
- end
- turtle.turnRight()
- end
- local function tForward()
- while turtle.forward() == false do
- turtle.forward()
- end
- if tDirection == 0 then
- tY = tY + 1
- elseif tDirection == 1 then
- tX = tX + 1
- elseif tDirection == 2 then
- tY = tY - 1
- elseif tDirection == 3 then
- tX = tX - 1
- end
- end
- local function goToStartPos()
- print("Back to home.")
- backX = tX
- backY = tY
- backDirection = tDirection
- if tDirection == 0 then
- tTurnLeft()
- tTurnLeft()
- elseif tDirection == 1 then
- tTurnRight()
- elseif tDirection == 3 then
- tTurnLeft()
- end
- while tY ~= 0 do
- tForward()
- end
- tTurnLeft()
- while tX ~= 0 do
- tForward()
- end
- tTurnRight()
- end
- local function goToOldPos()
- print("Back to work.")
- if tDirection == 1 then
- tTurnLeft()
- elseif tDirection == 2 then
- tTurnLeft()
- tTurnLeft()
- elseif tDirection == 3 then
- tTurnRight()
- end
- while tY ~= backY do
- tForward()
- end
- tTurnLeft()
- while tX ~= backX do
- tForward()
- end
- if tDirection ~= backDirection then
- while tDirection ~= backDirection do
- tTurnLeft()
- end
- end
- end
- local function dropWheat()
- for slotI = 1, 12 do
- turtle.select(slotI)
- if turtle.drop() == false and turtle.getItemCount(slotI) ~= 0 then
- print("Chest is full!")
- while turtle.drop() == false and turtle.getItemCount(slotI) ~= 0 do
- turtle.drop()
- end
- end
- end
- end
- local function turnAround()
- turtle.turnLeft()
- turtle.turnLeft()
- end
- local function isFilled()
- count = 0
- slot = 1
- while slot < 13 do
- count = count + turtle.getItemSpace(slot)
- slot = slot + 1
- end
- --print("Count: " .. count)
- if count ~= 0 then
- return false
- else
- return true
- end
- end
- local function isLast()
- if turtle.getItemCount(13) == 1 then
- return true
- else
- return false
- end
- end
- local function fillSeeds()
- if isLast() then
- turtle.select(13)
- for slot = 1, 12 do
- if turtle.compareTo(slot) then
- turtle.select(slot)
- turtle.transferTo(13)
- turtle.select(13)
- end
- if turtle.getItemSpace(13) == 0 then
- break
- end
- end
- if isLast() then
- goToStartPos()
- turtle.select(13)
- if turtle.suck() == false then
- print("Put seeds in chest!!!")
- while isLast() do
- turtle.suck()
- end
- end
- goToOldPos()
- end
- end
- end
- local function unloading()
- if isFilled() == true then
- print("Unloading...")
- goToStartPos()
- dropWheat()
- goToOldPos()
- end
- end
- local function plow()
- if turtle.detectDown() == true and turtle.digDown() == true then
- turtle.digDown()
- end
- end
- while true do
- SelectedSlot = 13
- turtle.select(SelectedSlot)
- while j < jmax do
- while i < imax do
- turtle.select(1)
- unloading()
- plow()
- turtle.select(SelectedSlot)
- fillSeeds()
- turtle.placeDown()
- tForward()
- i = i + 1
- end
- unloading()
- plow()
- fillSeeds()
- turtle.placeDown()
- if j + 1 ~= jmax then
- if direction == 0 then
- tTurnLeft()
- tForward()
- tTurnLeft()
- direction = 1
- else
- tTurnRight()
- tForward()
- tTurnRight()
- direction = 0
- end
- end
- turtle.select(1)
- unloading()
- plow()
- turtle.select(SelectedSlot)
- fillSeeds()
- turtle.placeDown()
- j = j + 1
- i = 0
- end
- i = 0
- j = 0
- goToStartPos()
- dropWheat()
- turnAround()
- for wait = 1, waiting do
- sleep(60)
- print("Remaining " .. (waiting - wait) .. " minutes.")
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement