Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- This program is designed to setup a 9x9 farm on a level surface with a
- water source block in the middle. These dimensions account for the
- maximum range a tilled dirt can be from water. If you would prefer to
- have the farm level with your terrain rather than raised one above it
- you need only clear a 9x9 hole in the ground and ensure your turtle is
- placed at the block height you want the farm built at. This program
- can handle wheat, carrots, and potatoes. A farming turtle will require
- the following items in it's inventory slots:
- 1) 64 dirt
- 2) 16 dirt
- 4) bucket of water
- 5) 64 seeds, carrots, or potatoes
- 6) 16 seeds, carrots, or potatoes
- 16) Fuel (preferably coal, charcoal, or a lava bucket)
- Future versions will support pumpkins and melons along with
- harvesting/replanting code.
- ]]--
- local step = 1 --used to track progression
- local count = 64 --used to track inventory slots
- local n = 1 --used to track slot selection
- function fuel()
- if turtle.getFuelLevel() < 10 then
- select(16)
- turtle.refuel(1)
- end
- end
- --assorted functions to shorten/tidy my actual code
- function left(reps)
- for x=1,reps do
- turtle.turnLeft()
- end
- end
- function right(reps)
- for x=1,reps do
- turtle.turnRight()
- end
- end
- function back(reps)
- for x=1,reps do
- fuel()
- turtle.back()
- end
- end
- function forward(reps)
- for x=1,reps do
- fuel()
- turtle.forward()
- end
- end
- function up(reps)
- for x=1,reps do
- fuel()
- turtle.up()
- end
- end
- function down(reps)
- for x=1,reps do
- fuel()
- turtle.down()
- end
- end
- function pDown()
- turtle.placeDown()
- end
- function pUp()
- turtle.placeUp()
- end
- function place()
- turtle.place()
- end
- function dDown()
- turtle.digDown()
- end
- function select(slot)
- turtle.select(slot)
- end
- --Turtle positions itself and begins creating the farm
- up(1)
- right(2)
- back(1)
- select(1)
- pDown()
- count = count - 1
- --Turtle creates the farm when z == 1 and then tills and plants when z == 2
- for z=1,2 do
- for x=1,9 do
- for y=1,8 do
- if z == 1 then
- if count > 0 then
- n=1
- else
- n=2
- end
- else
- if count > 0 then
- n=5
- else
- n=6
- end
- end
- if turtle.getItemCount(1) == 24 and count == 24 then --tracks for water placement
- back(2)
- down(1)
- select(4)
- place()
- up(1)
- forward(1)
- else
- back(1)
- select(n)
- pDown()
- end
- count = count - 1
- end
- if step == 1 then
- select(n)
- pDown()
- right(1)
- back(1)
- right(1)
- if not pDown() then
- select(n+1)
- pDown()
- end
- step = 2
- count = count - 2
- else
- select(n)
- pDown()
- left(1)
- back(1)
- left(1)
- if not pDown() then
- select(n+1)
- pDown()
- end
- step = 1
- count = count - 2
- end
- end
- for a=1,2 do
- right(1)
- forward(1)
- end
- up(1)
- count = 64
- end
Add Comment
Please, Sign In to add comment