Advertisement
Guest User

Untitled

a guest
Nov 25th, 2014
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.39 KB | None | 0 0
  1. height = 16
  2. width = 14
  3. pos = {}
  4. pos.x = 0
  5. pos.y = 1
  6.  
  7. endp = {}
  8. endp.x = width
  9. move = "+"
  10.  
  11. if (width % 2 == 0) then
  12.     endp.y = 1
  13.     direction = "toward"
  14. else
  15.     endp.y = height
  16.     direction = "away"
  17. end
  18.  
  19. function restock (turtle)
  20.        
  21. end
  22.  
  23. function forwardCheck (turtle, pos)
  24.     turtle.forward()
  25.  
  26.     if (move == "+") then
  27.         pos.y = pos.y + 1
  28.     else
  29.         pos.y = pos.y - 1
  30.     end
  31.  
  32.     local suc, crop = turtle.inspectDown()
  33.     if (crop.name == 'minecraft:wheat' and crop.metadata == 7) then
  34.         turtle.digDown()
  35.         turtle.select(1)
  36.         turtle.placeDown()
  37.     end
  38. end
  39.  
  40. function leftTurnCheck (turtle, pos)
  41.     turtle.turnLeft()
  42.     turtle.forward()
  43.     pos.x = pos.x + 1
  44.     turtle.turnLeft()
  45.     move = "-"
  46.  
  47.     local suc, crop = turtle.inspectDown()
  48.     if (crop.name == 'minecraft:wheat' and crop.metadata == 7) then
  49.         turtle.digDown()
  50.         turtle.select(1)
  51.         turtle.placeDown()
  52.     end
  53. end
  54.  
  55. function rightTurnCheck (turtle, pos)
  56.     turtle.turnRight()
  57.     turtle.forward()
  58.     pos.x = pos.x + 1
  59.     turtle.turnRight()
  60.     move = "+"
  61.  
  62.     local suc, crop = turtle.inspectDown()
  63.     if (crop.name == 'minecraft:wheat' and crop.metadata == 7) then
  64.         turtle.digDown()
  65.         turtle.select(1)
  66.         turtle.placeDown()
  67.     end
  68. end
  69.  
  70. while true do
  71.     print('x: ', pos.x, ' y: ', pos.y)
  72.     if (pos.x == endp.x and pos.y == endp.y) then
  73.         if (direction == "away") then
  74.             turtle.turnLeft()
  75.             turtle.turnLeft()
  76.         end
  77.  
  78.         while (pos.x > 1) do
  79.             turtle.forward()
  80.             pos.x = pos.x - 1
  81.         end
  82.  
  83.         turtle.turnLeft()
  84.  
  85.         while (pos.y > 1) do
  86.             turtle.forward()
  87.             pos.x = pos.x - 1
  88.         end
  89.  
  90.         turtle.turnRight()
  91.         turtle.forward()
  92.         turtle.turnLeft()
  93.         turtle.turnLeft()
  94.  
  95.         restock(turtle)
  96.        
  97.         sleep(15 * 60)
  98.     else
  99.         if (pos.x == 0 and pos.y == 1) then
  100.             forwardCheck(turtle, pos)
  101.             forwardCheck(turtle, pos)
  102.         elseif (pos.y == 1) then
  103.             rightTurnCheck(turtle, pos)
  104.             forwardCheck(turtle, pos)
  105.         elseif (pos.y == height) then
  106.             leftTurnCheck(turtle, pos)
  107.             forwardCheck(turtle, pos)
  108.         else
  109.             forwardCheck(turtle, pos)
  110.         end
  111.     end
  112. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement