Advertisement
xmarks

AutomaticFarm

Dec 17th, 2013
1,417
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.12 KB | None | 0 0
  1. -- FTB AutomaticFarm - V 1.0
  2. -- Made by Xmarks
  3. -- https://www.youtube.com/channel/UCA6oAnFqdDcc0sa6H8G5DSA
  4. -- Program Farms and Replants Seeds
  5. -- TODO: Not getting blocked by Blocks or Entities
  6. -- TODO: Drop Excess to chest below Turtle
  7. -- *********************************
  8. -- Fuel Goes to Slot 1
  9. -- Seeds for comparison go to Slot 2
  10. -- *********************************
  11.  
  12. x = 2
  13. y = 2
  14. seed_slot = 0
  15.  
  16. local function CheckFuel()
  17.   if turtle.getFuelLevel() < 20 then
  18.     turtle.select(1)
  19.     turtle.refuel(1)
  20.   end
  21. end
  22.  
  23. local function forward()
  24.   CheckFuel()
  25.   Counter = 0
  26.   while Counter < 1 do
  27.     if turtle.forward() then
  28.       Counter = Counter + 1
  29.     end
  30.   end
  31. end
  32.  
  33. local function GoLeft()
  34.   turtle.turnLeft()
  35.   forward()
  36.   turtle.turnLeft()
  37. end
  38.  
  39. local function GoRight()
  40.   turtle.turnRight()
  41.   forward()
  42.   turtle.turnRight()
  43. end
  44.  
  45. local function find_seeds()
  46.   for i = 3,16 do
  47.     turtle.select(i)
  48.     if turtle.compareTo(2) then
  49.       return i
  50.     end
  51.   end
  52.   return 0
  53. end
  54.  
  55. local function HarvestReplant()
  56.   seed_slot = find_seeds()
  57.   if seed_slot == 0 then
  58.     turtle.select(2)
  59.   else
  60.     turtle.select(seed_slot)
  61.   end
  62.   turtle.digDown()
  63.   turtle.placeDown()
  64. end
  65.  
  66. local function Farm()
  67.   for i =1,x do
  68.     if i%2 == 1 then
  69.       GoLeft()
  70.       for j =1,y do
  71.         HarvestReplant()
  72.         if j ~= y then
  73.           forward()
  74.         end
  75.       end
  76.     elseif i%2 == 0 then
  77.       GoRight()
  78.       for j = 1,y do
  79.         HarvestReplant()
  80.         if j ~= y then
  81.           forward()
  82.         end
  83.       end
  84.     end
  85.   end
  86. end
  87.  
  88. local function ReturnHome()
  89.   if x%2 == 0 then
  90.     forward()
  91.     turtle.turnRight()
  92.     for i = 1,x do
  93.       forward()
  94.     end
  95.   elseif x%2 == 1 then
  96.     turtle.turnLeft()
  97.     turtle.turnLeft()
  98.     for j = 1,y do
  99.       forward()
  100.     end
  101.     turtle.turnRight()
  102.     for i = 1,x do
  103.       forward()
  104.     end
  105.   end
  106.   turtle.turnRight()
  107.   forward()
  108.   turtle.turnLeft()
  109.   turtle.turnLeft()
  110. end
  111.  
  112. local function TimeOut()
  113.   for i = 23100,0,-1 do
  114.     print(i)
  115.     sleep(1)
  116.   end
  117. end
  118.  
  119. while true do
  120.   Farm()
  121.   ReturnHome()
  122.   TimeOut()
  123. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement