Advertisement
rhn

flowerfarm2

rhn
Jun 30th, 2014
690
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.45 KB | None | 0 0
  1. --Flower farm
  2. -- 5x5 grass plot.
  3.  
  4. -- G: Grass, T: Turtle, U: Unloading inventory, B: Bonemeal refilling inventory, F: Fuel refilling inventory
  5.  
  6. --    G G G G G
  7. --    G G G G G
  8. --    G G G G G
  9. --    G G G G G
  10. --    G G G G G
  11. --  U T F
  12. --    B
  13.  
  14. -- Place turtle one block above the grass. Ceiling height of 2 blocks over the entire grass plot except for the 5 grass blocks in direct line in front of the turtle starting position position which should be 3 blocks tall. Ceiling directly above the turtle starting position should be 4 blocks tall. This is vital to ensure the turtle can find its starting location after server/PC restarts.
  15.  
  16. local function move()
  17.     turtle.digDown()
  18.     while not turtle.forward() do
  19.                     sleep(1)
  20.     end
  21. end
  22. local function move2()
  23.     while not turtle.forward() do
  24.                     sleep(1)
  25.     end
  26. end
  27. local function harvest()
  28.     --move to middle
  29.     for i = 1,3 do
  30.         move2()
  31.     end
  32.     turtle.turnRight()
  33.     for i = 1,2 do
  34.         move2()
  35.     end
  36.     --clear middle and bonemeal
  37.     turtle.digDown()
  38.     turtle.select(15)
  39.     turtle.placeDown()
  40.  
  41.     --harvest spiralling out
  42.     turtle.turnRight()
  43.     move()
  44.     turtle.turnLeft()
  45.     move()
  46.     turtle.turnLeft()
  47.     move()
  48.     move()
  49.     turtle.turnLeft()
  50.     move()
  51.     move()
  52.     turtle.turnLeft()
  53.     move()
  54.     move()
  55.     move()
  56.     turtle.turnLeft()
  57.     move()
  58.     move()
  59.     move()
  60.     turtle.turnLeft()
  61.     move()
  62.     move()
  63.     move()
  64.     move()
  65.     turtle.turnLeft()
  66.     move()
  67.     move()
  68.     move()
  69.     move()
  70.     turtle.turnLeft()
  71.     move()
  72.     move()
  73.     move()
  74.     move()
  75.     move()
  76.     turtle.turnRight()
  77.  
  78. end
  79. local iRepeat = 0
  80. local iSec = 60
  81. local spacer = ""
  82.  
  83. --find starting location
  84.     turtle.up()
  85.     turtle.up()
  86.     for i = 1,5 do
  87.         for i = 1,5 do
  88.             turtle.forward()
  89.         end
  90.         turtle.up()
  91.         turtle.turnLeft()
  92.     end
  93.     turtle.down()
  94.     turtle.down()
  95.     while turtle.detect() == true do
  96.         turtle.turnLeft()
  97.         sleep(0.5)
  98.     end
  99. while true do
  100.     term.clear()
  101.     term.setCursorPos(1,4)
  102.     print("Fuel Remaning : "..tostring(turtle.getFuelLevel()))
  103.     term.setCursorPos(1,1)
  104.     iRepeat = iRepeat+1
  105.     print("Harvesting   :"..iRepeat)
  106.     --Refuel
  107.     local fuelLevel = turtle.getFuelLevel()
  108.         if (fuelLevel < 100) then
  109.                 turtle.select(16)
  110.                 turtle.refuel(2)
  111.         end
  112.     --Harvest
  113.         harvest()
  114.             for slot=1,14 do
  115.                 turtle.select(slot)
  116.                 sleep(0.1)
  117.                 turtle.drop()
  118.             end
  119.         turtle.turnLeft()
  120.     --refuel bonemeal from chest
  121.     turtle.select(15)
  122.     turtle.suck()
  123.     for slot=1,14 do
  124.             turtle.select(slot)
  125.             sleep(0.1)
  126.             turtle.drop()
  127.     end
  128.     turtle.turnLeft()
  129.     --Refill fuel from chest
  130.     turtle.select(16)
  131.     turtle.suck()
  132.     for slot=1,14 do
  133.             turtle.select(slot)
  134.             sleep(0.1)
  135.             turtle.drop()
  136.     end
  137.         turtle.turnLeft()
  138.     term.setCursorPos(1,4)
  139.     print("Fuel Remaning : "..tostring(turtle.getFuelLevel()))
  140.    
  141.  
  142.                    
  143.     term.setCursorPos(1,2)
  144.     term.clearLine()
  145.     print("sleeping "..iSec.." seconds")
  146.         for i = iSec,0,-1 do
  147.                                     sleep(1)
  148.                                     term.setCursorPos(1,3)
  149.                                     term.clearLine()
  150.                                     if i < 10 then
  151.                                                     spacer = "0"
  152.                                     else
  153.                                                     spacer = ""
  154.                                     end
  155.                                     write("To go    "..spacer..i)
  156.         end
  157.  
  158.    
  159. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement