Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local blockX = 1
- local blocksX = 16
- local blocksXSkip = {1,8,9,10}
- local blockY = 1
- local blocksY = 37
- local slotsRef = {14,15,16}
- local slotsRefDump = {14}
- local slotsSeed = {15,16}
- local slotsDump = {5,6,7,8,9,10,11,12,13}
- local dirAway = true
- local function organizeSpace()
- for countA=1,13 do
- if turtle.getItemCount(countA) > 0 and turtle.getItemCount(countA) < 64 then
- turtle.select(countA)
- for countB=1,countA do
- turtle.transferTo(countB)
- end
- end
- end
- end
- local function checkSpace()
- local spaceAvail = 0
- for count=1,16 do
- spaceAvail = spaceAvail + turtle.getItemSpace(count)
- end
- return spaceAvail
- end
- local function moveForward()
- if turtle.getFuelLevel() > 0 then
- if turtle.forward() == false then
- os.sleep(5)
- moveForward()
- end
- else
- while turtle.getFuelLevel() == 0 do
- os.sleep(30)
- end
- if turtle.forward() == false then
- os.sleep(5)
- moveForward()
- end
- end
- end
- local function isBlockPlantable()
- local isPlantable = true
- for i=1,#blocksXSkip do
- if blockX==blocksXSkip[i] then
- isPlantable=false
- end
- end
- return isPlantable
- end
- local function selectSlot(slotRef)
- turtle.select(slotRef)
- for count=13,1,-1 do
- if turtle.compareTo(count) == true then
- turtle.select(count)
- return
- end
- end
- end
- local function plantItem()
- if isBlockPlantable(blockX) then
- turtle.digDown()
- if blockX % 2 == 0 then
- selectSlot(slotsSeed[1])
- else
- selectSlot(slotsSeed[2])
- end
- turtle.placeDown()
- end
- end
- local function turnRight()
- turtle.turnRight()
- moveForward()
- turtle.turnRight()
- end
- local function turnLeft()
- turtle.turnLeft()
- moveForward()
- turtle.turnLeft()
- end
- local function dropItems()
- turtle.down()
- for i=1,#slotsRefDump do
- turtle.select(slotsRefDump[i])
- for j=1,13 do
- if turtle.compareTo(j) then
- turtle.select(j)
- turtle.dropDown()
- end
- end
- end
- organizeSpace()
- for i=1,#slotsDump do
- turtle.select(slotsDump[i])
- turtle.dropDown()
- end
- turtle.up()
- end
- local function returnToStart()
- if (blockX == 1) and (blockY == 1) then
- dropItems()
- else
- if dirAway == true then
- if blockX > 2 then
- turtle.turnRight()
- turtle.turnRight()
- for count=1,blockX - 1 do
- moveForward()
- end
- end
- if blockY > 1 then
- turtle.turnRight()
- for count=1,blockY - 1 do
- moveForward()
- end
- turtle.turnRight()
- else
- turtle.turnRight()
- turtle.turnRight()
- end
- else
- if blockX > 2 then
- for count=1,blockX - 1 do
- moveForward()
- end
- end
- if blockY > 1 then
- turtle.turnRight()
- for count=1,blockY - 1 do
- moveForward()
- end
- turtle.turnRight()
- else
- turtle.turnRight()
- turtle.turnRight()
- end
- end
- dropItems()
- end
- end
- local function returnToBlock()
- if blockY==1 then
- if blockX > 1 then
- for count=1, blockX - 1 do
- moveForward()
- end
- end
- else
- turtle.turnRight()
- for count=1, blockY - 1 do
- moveForward()
- end
- turtle.turnLeft()
- if blockX > 1 then
- for count=1, blockX - 1 do
- moveForward()
- end
- if dirAway == false then
- turtle.turnRight()
- turtle.turnRight()
- end
- end
- end
- end
- local function start()
- for countY=1, blocksY do
- blockY = countY
- for countX=1, blocksX - 1 do
- local spaceAvail = checkSpace()
- if spaceAvail < 128 then
- returnToStart()
- returnToBlock()
- end
- plantItem()
- moveForward()
- if dirAway == true then
- blockX = blockX + 1
- else
- blockX = blockX - 1
- end
- end
- plantItem()
- if blockY == blocksY then
- returnToStart()
- else
- organizeSpace()
- if dirAway == true then
- turnRight()
- dirAway = false
- else
- turnLeft()
- dirAway = true
- end
- end
- end
- end
- while true == true do
- blockX = 1
- blockY = 1
- dirAway = true
- start()
- os.sleep(60*30)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement