Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Ensure that the turtle is in the middle block of the wall 2 high from the ground in the back of the farm
- --The turtle also needs to be facing toward the farm so make sure to orient it correctly after placing it
- --This can be accomplished with turtle.turnLeft(2) or similar after placing it down from the lua prompt.
- --Functions
- local function refuel() --This refuels the turtle or instructs the player through the computer when he needs more coal
- while turtle.getFuelLevel() < 50 do
- term.write( "I need "..( 236 - turtle.getFuelLevel() ).." more fuel" )
- term.write( "Checking for fuel..." )
- rednet.send(0, "fuel")
- for i = 1, 16 do
- turtle.select( i )
- turtle.refuel()
- end
- term.write( "Checked for fuel...")
- end
- term.write( "I have got enough fuel...")
- turtle.select(1)
- rednet.send(0, "full")
- end
- local function place() --This is the loop that does all the planting
- for x=1, 7 do --repeats code 7 times
- turtle.placeDown() -- can only go 1 block at a time thus the for loop
- turtle.forward()
- turtle.placeDown() -- for end of row planting. will only work if possible otherwise it errors and keeps moving.
- if turtle.getItemCount() < 1 then --Checks to see if the slot is empty and switches to the next
- turtle.select(2)
- if turtle.getItemCount() < 1 then --Checks to see if the slot is empty and switches to the next
- turtle.select(3)
- if turtle.getItemCount() < 1 then --Checks to see if the slot is empty and switches to the next
- turtle.select(4)
- end
- end
- end
- end
- end
- local function reset() --Essentially this just turns the turtle around
- turtle.turnLeft()
- turtle.turnLeft()
- end
- local function left() --Function to clean up the code in the main work functions
- turtle.turnLeft()
- turtle.forward()
- turtle.turnLeft()
- end
- local function right() --Function to clean up the code in the main work functions
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- end
- local function empty() --Function to empty the inventory of the turtle
- turtle.select(1)
- turtle.drop()
- turtle.select(2)
- turtle.drop()
- turtle.select(3)
- turtle.drop()
- turtle.select(4)
- turtle.drop()
- end
- local function get() --Function to fill the inventory of the turtle
- turtle.suck()
- turtle.select(2)
- turtle.suck()
- turtle.select(3)
- turtle.suck()
- turtle.select(4)
- turtle.suck()
- turtle.select(1)
- end
- local function leftplanting() --Loop for the entire planting process
- for a=1, 3 do --This cycles through the planting levels
- for i=1, 4 do --This cycles through the planting pads
- if (i % 2 == 0) then
- place()
- right()
- else
- place()
- left()
- end
- end
- turtle.down()
- refuel()
- end
- end
- local function rightplanting() --Loop for the entire planting process
- for a=1, 3 do --This cycles through the planting levels
- for i=1, 4 do --This cycles through the planting pads
- if (i % 2 == 0) then
- place()
- left()
- else
- place()
- right()
- end
- end
- turtle.down()
- refuel()
- end
- end
- local function carrots()
- refuel()
- turtle.turnLeft() --Place this chest on the right of the turtle as your facing it
- get()
- turtle.turnRight()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- sleep(0.1)
- turtle.down()
- turtle.down()
- leftplanting()
- reset()
- turtle.up()
- turtle.up()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- for i=1, 12 do
- turtle.forward()
- end
- refuel()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- sleep(0.1)
- turtle.down()
- turtle.down()
- rightplanting()
- reset()
- turtle.up()
- turtle.up()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- for i=1, 14 do
- turtle.forward()
- end
- reset()
- turtle.turnLeft()
- empty()
- turtle.turnRight()
- rednet.send(0, "done") --Be sure to set this number to the id of the control computer
- os.reboot()
- end
- local function potatoes()
- refuel()
- turtle.turnRight() --Place this chest on the left of the turtle as your facing it
- get()
- turtle.turnLeft()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- sleep(0.1)
- turtle.down()
- turtle.down()
- leftplanting()
- reset()
- turtle.up()
- turtle.up()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- for i=1, 12 do
- turtle.forward()
- end
- refuel()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- sleep(0.1)
- turtle.down()
- turtle.down()
- rightplanting()
- reset()
- turtle.up()
- turtle.up()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- for i=1, 14 do
- turtle.forward()
- end
- reset()
- turtle.turnRight()
- empty()
- turtle.turnLeft()
- rednet.send(0, "done") --Be sure to set this number to the id of the control computer
- os.reboot()
- end
- local function wheat()
- refuel()
- reset() --Place this chest behind the turtle as your facing it
- get()
- reset()
- turtle.forward()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- sleep(0.1)
- turtle.down()
- turtle.down()
- leftplanting()
- reset()
- turtle.up()
- turtle.up()
- turtle.forward()
- turtle.forward()
- turtle.turnLeft()
- for i=1, 12 do
- turtle.forward()
- end
- refuel()
- turtle.turnRight()
- turtle.forward()
- turtle.forward()
- sleep(0.1)
- turtle.down()
- turtle.down()
- rightplanting()
- reset()
- turtle.up()
- turtle.up()
- turtle.forward()
- turtle.forward()
- turtle.turnRight()
- for i=1, 14 do
- turtle.forward()
- end
- empty()
- reset()
- rednet.send(0, "done") --Be sure to set this number to the id of the control computer
- os.reboot()
- end
- --Main Program
- rednet.open("right")
- while true do
- id, msg = rednet.receive(0) --Be sure to set this number to the id of the control computer
- if msg == "carrots" then
- carrots()
- else if msg == "potatoes" then
- potatoes()
- else if msg == "wheat" then
- wheat()
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement