Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local args = { ... }
- numArgs = table.getn(args)
- crop = {["minecraft:potatoes"]="minecraft:potato", ["minecraft:carrots"]="minecraft:carrot", ["minecraft:wheat"]="minecraft:wheat_seeds"}
- function fuel ()
- if turtle.getFuelLevel() == 0 then
- turtle.select(1)
- turtle.refuel(1)
- end
- end
- function scan ()
- worked, data = turtle.inspectDown()
- if data["metadata"] == 7 then
- return data["name"]
- else
- return false
- end
- end
- function farm (planted)
- toPlant = crop[planted]
- found = false
- slot = 1
- while not found and slot < 16 do
- check = turtle.getItemDetail(slot)
- if check ~= nil then
- if check["name"] == toPlant then
- turtle.select(slot)
- found = true
- end
- end
- slot = slot + 1
- end
- turtle.digDown()
- if turtle.getItemCount() > 0 then
- turtle.placeDown()
- end
- end
- function move (x, y)
- y = y or x
- for i = 1, x do
- for j = 1, y do
- planted = scan()
- if planted ~= false then
- farm(planted)
- end
- fuel()
- turtle.forward()
- end
- if scan() then
- farm()
- end
- if (i % 2 == 0) then
- turtle.turnLeft()
- fuel()
- turtle.forward()
- turtle.turnLeft()
- else
- turtle.turnRight()
- fuel()
- turtle.forward()
- turtle.turnRight()
- end
- end
- end
- --================Main===============--
- if numArgs == 1.0 then
- move(tonumber(args[1]))
- elseif numArgs == 2.0 then
- move(tonumber(args[1]), tonumber(args[2]))
- else
- error("Place at bootom left corner, and use below:")
- error("Usage: farm [int xDim & yDim] [int yDim]")
- end
Advertisement
Add Comment
Please, Sign In to add comment