This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
ChunLing's profile picture

Super Simple Farming

Started by ChunLing, 03 August 2012 - 02:40 PM
ChunLing #1
Posted 03 August 2012 - 04:40 PM
With the new functionality of the 1.4 turtles, you can set up a turtle to turn bonemeal into wheat using a single block of tilled dirt. Nothing spectacular in the code, but it can make life a lot easier if you are exploring a cave system or whatever and don't want to have to run home to get food. As long as you have skeletons to fight and some starting seeds, you're in business.


local cldt = {} --I like reusing data in tables so I don't have to remember a bunch of variable names, but since only the farming function is shown here (and it only uses one
local tfnctns = {} --variable), this is just this way so I don't accidentally break the code with a typo

tfnctns[6] = function() --I embedded this in a package of other simple functions so I only have to remember one file name for them all
print("Place seeds in Slot 1,")
print("Bonemeal in Slots 2-15")
write("Leave Slot 16 empty")
io.read()
cldt[1] = 2
repeat
turtle.select(1)
if not turtle.place() then print("There must be tilled dirt for planting") break end
turtle.select(cldt[1])
if not turtle.place() then print("Process requires Bonemeal to continue") break end
if turtle.getItemCount(cldt[1]) < 1 then cldt[1] = cldt[1]+1 end
turtle.dig()
until cldt[1] > 15
end

shell.run('clear')
repeat --this is the part that selects the functions from the table (based on user input), it might be of some interest to people who want to do something similar
print("Select function by number")
print("6: Auto Farm")
write("Or other key to exit")
local sclfn = tfnctns[tonumber(io.read())]
if sclfn then sclfn() else break end
until false

You can set up your turtle sitting on the ground with some hydrated farmland in front of it, like this side view:
t
T
WD –The little t is a torch, the capital T is the turtle, the W is water under the turtle, and the D is a block of dirt (you need to till it yourself unless you use a turtle that can do that for you).
Now you've got a better way to live off monster drops than eating rotten flesh. You can easily carry everything you need to set this up in the field (or cave, whatever) and move it about as you explore.
basdxz #2
Posted 16 August 2012 - 10:49 PM
It works but, it shits out tons of seeds and I suggest you make it put stuff in a chest.