Notze

Farm v1.0

Aug 22nd, 2013
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.69 KB | None | 0 0
  1. --[[
  2. Version 1.0
  3. Written by: Tom Nordloh (Notze)
  4.  
  5. Create a rectangular field (configured
  6. for a 9x9 field but you can make your
  7. own adjustments in the lower section)
  8. and place a chest on the left side
  9. infront of it. Place the Turtle upon
  10. the chest faceing towards the field.
  11. Place the following things into the
  12. Turtles inventory:
  13. Slot 1: cole
  14. Slot 2: seeds
  15. ]]
  16.  
  17. -- make your adjustments here
  18. local int x = 9 -- from Turtle's direction right
  19. local int y = 9 -- in Turtle's looking direction
  20. -- end of adjustments
  21.  
  22. function main()
  23.     -- refuel in dependency to field size
  24.     refuel(1+(x*y+x+y)/96)
  25.    
  26.     -- harvest and plant
  27.     local boolean nextEndUp = true
  28.     forward(y)
  29.     for j=2, x, 1 do
  30.  
  31.         if nextEndUp then
  32.             turnRight()
  33.             forward(1)
  34.             turnRight()
  35.             forward(y-1)
  36.             nextEndUp = false
  37.         else
  38.             turnLeft()
  39.             forward(1)
  40.             turnLeft()
  41.             forward(y-1)
  42.             nextEndUp = true
  43.         end
  44.  
  45.     end
  46.  
  47.     -- return to chest
  48.     if nextEndUp then
  49.         back(y)
  50.         turnRight()
  51.         back(x-1)
  52.         turnLeft()
  53.     else
  54.         forward(1)
  55.         turnLeft()
  56.         back(x-1)
  57.         turnLeft()
  58.     end
  59.  
  60.     -- place everything but cole and seeds in the Chest
  61.     for i=3, 16 do
  62.         turtle.select(i)
  63.         turtle.dropDown()
  64.     end
  65. end
  66.  
  67. function refuel(amount)
  68.     if turtle.getFuelLevel() < 96*amount then
  69.         turtle.select(1)
  70.         turtle.refuel(amount)
  71.     end
  72. end
  73.  
  74. function forward(length)
  75.     for i=1, length, 1 do
  76.         turtle.forward()
  77.         turtle.digDown()
  78.         turtle.select(2)
  79.         turtle.placeDown()
  80.     end
  81. end
  82.  
  83. function back(length)
  84.     for i=1, length, 1 do
  85.         turtle.back()
  86.     end
  87. end
  88.  
  89. function turnRight()
  90.     turtle.turnRight()
  91. end
  92.  
  93. function turnLeft()
  94.     turtle.turnLeft()
  95. end
  96.  
  97. function turnAround()
  98.     turnRight()
  99.     turnRight()
  100. end
  101.  
  102. main()
Advertisement
Add Comment
Please, Sign In to add comment