Advertisement
Guest User

farmer.lua

a guest
May 26th, 2016
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.57 KB | None | 0 0
  1. sides = require("sides")
  2. component = require("component")
  3. robot = require("robot")
  4. geo = component.geolyzer
  5. harvesting = true
  6. row = 1
  7. column = 1
  8. robot.up()
  9. while harvesting == true do
  10.   robot.forward()
  11.   if geo.analyze(sides.down)["name"] == "minecraft:wheat" then
  12.     robot.swingDown()
  13.     robot.placeDown()
  14.   elseif geo.analyze(sides.down)["name"] == "minecraft:air" then
  15.     if robot.placeDown() == false then
  16.       robot.down()
  17.       if geo.analyze(sides.down)["name"] == "minecraft:water" then
  18.         robot.up()
  19.       elseif geo.analyze(sides.down)["name"] == "minecraft:stone" then
  20.         robot.up()
  21.         if row % 2 == 1 then
  22.           robot.turnRight()
  23.           robot.forward()
  24.           robot.turnRight()
  25.         else
  26.           robot.turnLeft()
  27.           robot.forward()
  28.           robot.turnLeft()
  29.         end
  30.         row = row + 1
  31.       elseif geo.analyze(sides.down)["name"] == "minecraft:dirt" or geo.analyze(sides.down)["name"] == "minecraft:grass" then
  32.         robot.up()
  33.         robot.useDown()
  34.         robot.placeDown()
  35.       elseif geo.analyze(sides.down)["name"] == "minecraft:wool" then
  36.         harvesting = false
  37.         if row % 2 == 1 then
  38.           robot.turnAround()
  39.           robot.up()
  40.           while column > 0 do
  41.             robot.forward()
  42.             column = column - 1
  43.           end
  44.         end
  45.         robot.turnRight()
  46.         while row > 1 do
  47.           robot.forward()
  48.           row = row -1
  49.         end
  50.         robot.turnRight()
  51.         robot.down()
  52.       end
  53.     end
  54.   end
  55.   if row % 2 == 1 then
  56.     column = column + 1
  57.   else
  58.     column = column - 1
  59.   end
  60. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement