Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print "[!]Harvester ready for action!"
- --customization
- fieldsizex=9
- fieldsizey=9
- minfuel=1500 --the minimum amount of fuel we should stock up on when done
- --system variables, do not edit
- od = true --am I going in the Outward Direction
- df = false --done farming
- --function declarations
- function movePlace() --harvests, collects, replants, and moves
- turtle.digDown()
- turtle.suckDown(5)
- turtle.placeDown()
- turtle.forward()
- end
- function moveCollect() --collects the crops as it comes back
- turtle.suckDown(5)
- turtle.forward()
- end
- function waitFourMinutes()
- print "[!]Sleeping for 4 minutes"
- os.sleep(240)
- end
- --main proccesses
- while true do
- --prepare
- turtle.forward()
- turtle.turnLeft()
- --farm
- for y=1,fieldsizey do
- for x=1,fieldsizex-1 do --harvest across the field
- movePlace()
- end
- turtle.turnRight() --spin around
- turtle.digDown()
- turtle.suckDown(5)
- turtle.placeDown()
- turtle.turnRight()
- od = false
- for x=1,fieldsizex-1 do --collect accross the field
- moveCollect()
- end
- if y==fieldsizey then --we are done, so we need to go home
- print "[!]Done farming!"
- turtle.turnRight()
- for i=0,fieldsizey do turtle.forward() end
- df = true
- break
- else -- we need to hook left and make another run
- turtle.turnLeft()
- moveCollect()
- turtle.turnLeft()
- end
- end
- --dump items
- print "[!]Dumping items..."
- for i=1,16 do --go through each slot
- turtle.select(i)
- count = turtle.getItemCount() --count the items in each slot
- if count ~= 0 then
- turtle.dropDown(count) --if there are any dump them into the chest
- end
- end
- --refuel
- print "[!]Checking if I need fuel..."
- i = 1
- print(" - Fuel " .. turtle.getFuelLevel())
- while turtle.getFuelLevel() < minfuel do
- if turtle.suck(1) == false then --theres no more in the chest!!!
- print "[!]The fuel chest is out of fuel!!!"
- break
- end
- turtle.refuel(1)
- i = i+1
- if math.fmod(i,10) == 0 then
- print(" - Fuel " .. turtle.getFuelLevel())
- end
- end
- print "[!]Done refueling!"
- turtle.turnRight()
- turtle.turnRight()
- waitFourMinutes()
- while rs.getAnalogSignal("left") < 1 do
- print "[!] Request signal not high enough"
- waitFourMinutes()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement