Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Fuel = 16
- FARMHIGHT = 5
- CLUSTERS = 3
- -- Edit values above to suit your needs
- function megaSuck()
- for b=1,3,1 do
- turtle.suck()
- end
- end -- suck 3 times to avoid loss^
- --Change these functions if your farm downst have the same spacing as mine
- --You would be aiming to change the second number in the for loops of each function
- function up()
- checkFuel()
- for l=1,3,1 do
- turtle.up()
- end
- end
- function right()
- turtle.turnRight()
- for o=1,4,1 do
- turtle.forward()
- end
- turtle.turnLeft()
- end
- function left()
- turtle.turnLeft()
- for p=1,4,1 do
- turtle.forward()
- end
- turtle.turnRight()
- end
- function down()
- for g=1,FARMHIGHT,1 do
- for h=1,3,1 do
- turtle.down()
- end
- end
- end
- --DO NOT CHANGE THE REST
- --OF THE FUNCTIONS
- --UNLESS YOU KNOW WHAT YOU'RE DOING
- function RTH()
- down()
- for m=1,CLUSTERS-1,1 do
- left()
- end
- end
- function dump()
- rotate(2)
- for d=CLUSTERS+1,15,1 do
- turtle.select(d)
- turtle.drop()
- end
- rotate(2)
- end
- function plant()
- turtle.select(ACTIVECROP)
- turtle.place()
- end
- function checkFuel()
- if turtle.getFuelLevel() < 300 then
- turtle.select(Fuel)
- turtle.refuel(5)
- end
- end
- function farm()
- turtle.dig()
- megaSuck()
- turtle.select(ACTIVECROP)
- turtle.place()
- end
- function rotate(times)
- for j=1 , times, 1 do
- turtle.turnLeft()
- end
- end
- function process()
- checkFuel()
- while true do --When building keep in mind the implications of this while loop
- turtle.forward()
- turtle.turnLeft()--Facing crop
- if turtle.detect() then -- if crop found
- farm()
- else plant() end--if farmland is empty
- rotate(2)--face other crop
- if turtle.detect() then
- farm()
- else plant() end
- turtle.turnLeft()--prepares to move forward
- if turtle.detect() then break end --IF AT THE END
- end
- rotate(2) -- Turn Around
- while not turtle.detect() do -- go back also keep this loop in mind while building
- turtle.forward()
- end
- rotate(2)--Getting ready to proceed
- end
- function anothaOne(last)-- In charge of farming 1 cluster
- for b=1,FARMHIGHT,1 do--Y AXIS LOOP
- if last and b==FARMHIGHT then --If Last Line and Last cluster
- process()--Z Axis
- RTH()--Return To Home
- else if b==FARMHIGHT and not last then -- If last of the cluster but not the last cluster
- process()
- down()
- else -- could also be (else if not b==FARMHIGHT and not last then)
- process()
- up()
- end
- end
- end
- end --if someone could point out why this end needs to be here thatd be epic
- print("Put crops in the first " .. CLUSTERS .. " slots")
- print("Press Enter to continue")
- temp = io.read()
- --THIS IS WHERE THE CODE STARTS
- for x=1,CLUSTERS,1 do --X Axis Loop
- ACTIVECROP = ((x+(CLUSTERS-1))%CLUSTERS)+1 --For the uninitiated the % returns the remainder so 7%3=1
- if x==CLUSTERS then --if last
- anothaOne(true)--one more then stop
- break
- else
- anothaOne()--Y Axis
- right() -- go right on X Axis
- end
- end
- dump() --Dump items at chest
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement