Advertisement
soee

cacti

Apr 26th, 2014
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.38 KB | None | 0 0
  1. local fuelSlot = 16
  2.  
  3. local length = 8
  4. local width = 8
  5.  
  6. function tF(d)
  7.   for i = 1,d do
  8.     while(not turtle.forward()) do
  9.       sleep(1)
  10.     end
  11.   end
  12. end
  13.  
  14. function tRefuel()
  15.   while (turtle.getFuelLevel() < 200) do
  16.     turtle.select(fuelSlot) --charcol in this slot
  17.     turtle.refuel(1)
  18.     print("Refueled")
  19.   end
  20.   print( "Fuel Level: ", turtle.getFuelLevel() )
  21. end
  22.  
  23. local function selectCactus()
  24.     turtle.select(1)
  25.     if turtle.getItemCount(1) > 1 then
  26.         return true
  27.     else
  28.         for otherSlot = 2, 15 do
  29.             if (turtle.compareTo(otherSlot)) then
  30.                 turtle.select(otherSlot)
  31.                 return true
  32.             end
  33.         end
  34.     end
  35.     return false
  36. end
  37.  
  38. function plant()
  39.    selectCactus()
  40.    turtle.placeDown()
  41. end
  42.  
  43. function harvestRow()
  44.   for i=1, length do
  45.     tF(1)
  46.     tF(1)
  47.     if (turtle.detectDown()) then
  48.       turtle.digDown()
  49.       turtle.down()
  50.       turtle.digDown()
  51.       turtle.up()
  52.     end
  53.   end
  54. end
  55.  
  56. function harvestField()
  57.   for i=1, width do
  58.     harvestRow()
  59.     if (i % 2 == 0) then
  60.       tF(1)
  61.       turtle.turnRight()
  62.       tF(1)
  63.       turtle.turnRight()
  64.     else
  65.       tF(1)
  66.       turtle.turnLeft()
  67.       tF(1)
  68.       turtle.turnLeft()
  69.     end
  70.   end
  71. end
  72.  
  73. turtle.up()
  74. turtle.up()
  75. harvestField()
  76. turtle.turnLeft()
  77. tF(width)
  78. turtle.turnLeft()
  79. turtle.down()
  80. turtle.down()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement