Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Config
- local dwidth = 16
- local ddepth = 16
- local dtimer = 24 -- In minutes (Crops should grow in like 24 min)
- local seeds = {"seed","cotton"} -- Insert seed names here (For example Wheat Seed has 'seed' in it, so you don't need to add it)
- --Setting variables to defaults
- local width = dwidth
- local depth = ddepth
- local dtimer = dtimer
- --Argument Handling
- local args = {...}
- print("Auto-Farm:")
- if args[1] and tonumber(args[1]) ~= nil then
- width = tonumber(args[1])
- print("X:",args[2])
- else
- print("X:",dwidth,"(Default)")
- end
- if args[2] and tonumber(args[2]) ~= nil then
- depth = tonumber(args[2])
- print("Z:",args[2])
- else
- print("Z:",ddepth,"(Default)")
- end
- if args[3] and tonumber(args[3]) ~= nil then
- timer = tonumber(args[3])
- print("Timer:",tonumber(args[3]))
- else
- print("Timer:",dtimer,"(Default)")
- end
- -- Edited built in functions
- local turt = {
- forward = function()
- local fueltypes = {"coal","charcoal","lava"}
- if turtle.getFuelLevel() <= 0 then
- print("Panik! No Fuel!")
- end
- while true do
- if turtle.getFuelLevel() > 0 then
- break
- end
- for i=1,16 do
- local data = turtle.getItemDetail(i)
- for ind=1,#fueltypes do
- if data and string.find(data.name,fueltypes[ind]) then
- turtle.select(ind)
- turtle.refuel(turtle.getItemCount(ind))
- end
- end
- end
- end
- while not turtle.forward() do
- turtle.dig()
- end
- end,
- lookFor = function(list)
- if not list then error("Table required for argument 2") end
- for i=1,16 do
- local data = turtle.getItemDetail(i)
- for ind=1,#list do
- if data and string.find(data.name,list[ind]) then
- return ind
- end
- end
- end
- end
- }
- local function placeSeed()
- local seedslot = turt.lookFor(seeds)
- if seedslot and seedslot ~= turtle.getSelectedSlot() then
- print(seedslot)
- turtle.select(seedslot)
- elseif not seedslot then
- print("Panik! No Seeds!")
- while not turt.lookFor(seeds) do
- sleep(1)
- end
- turtle.select(turt.lookFor(seeds))
- end
- turtle.placeDown()
- turtle.suckDown()
- end
- --Farm Circuit
- local function farmCircuit()
- turtle.up()
- turt.forward()
- turtle.digDown()
- turtle.suckDown()
- placeSeed()
- turtle.turnRight()
- for z=1,depth do
- for x=1,width-1 do
- turt.forward()
- turtle.digDown()
- turtle.suckDown()
- placeSeed()
- end
- if z ~= depth then
- if z % 2 == 0 and then
- turtle.turnRight()
- turt.forward()
- turtle.turnRight()
- else
- turtle.turnLeft()
- turt.forward()
- turtle.turnLeft()
- end
- turtle.digDown()
- turtle.suckDown()
- placeSeed()
- else
- end
- end
- end
- --Checking for an instant start arg or not
- if args[4] then
- while true do
- farmCircuit()
- sleep(dtimer*60)
- end
- else
- while sleep(dtimer*60) do
- farmCircuit()
- end
- end
Add Comment
Please, Sign In to add comment