Advertisement
NoobieDoobie

farm

Mar 27th, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.45 KB | None | 0 0
  1. function CheckSlots(slotNum, minVal)
  2.     if turtle.getItemCount(slotNum)<minVal then
  3.         return false
  4.     else
  5.         return true
  6.     end
  7. end
  8.  
  9. function Input()
  10.     write("Width?")
  11.     breite=tonumber(read())
  12.     write("Length?")
  13.     laenge=tonumber(read())
  14. end
  15.  
  16. function CheckFuel()
  17.     if turtle.getFuelLevel() < 40 and turtle.getItemCount(1) < 1 then
  18.         print "Please but some coal in slot 1"
  19.     end
  20. end
  21.  
  22. function Refuel()
  23.     if turtle.getFuelLevel() < 80 then
  24.         turtle.refuel()
  25.     end
  26. end
  27.  
  28. function DetectAndReplace()
  29.     isThere, data=turtle.inspectDown()
  30.     if isThere then
  31.         if data.metadata==7 then
  32.             if data.name=="minecraft:wheat" then
  33.                 turtle.select(2)
  34.                 turtle.digDown()
  35.                 if CheckSlots(2,1) then
  36.                     turtle.placeDown()
  37.                 else
  38.                     write("Please put wheatseeds in slot 2")
  39.                     while CheckSlots(2,1)==false do
  40.                     end
  41.                 end
  42.             end
  43.         end
  44.         if data.metadata==7 then
  45.             if data.name=="minecraft:carrots" then
  46.                 turtle.select(3)
  47.                 turtle.digDown()
  48.                 if CheckSlots(3,1) then
  49.                     turtle.placeDown()
  50.                 else
  51.                     write("Please put carrots in slot 3")
  52.                     while CheckSlots(3,1)==false do
  53.                     end
  54.                 end
  55.             end
  56.         end
  57.         if data.metadata==7 then
  58.             if data.name=="minecraft:potatoes" then
  59.                 turtle.select(4)
  60.                 turtle.digDown()
  61.                 if CheckSlots(4,1) then
  62.                     turtle.placeDown()
  63.                 else
  64.                     write("Please put potatoes in slot 2")
  65.                     while CheckSlots(4,1)==false do
  66.                     end
  67.                 end
  68.             end
  69.         end
  70.         return true
  71.     else
  72.         return false
  73.     end
  74. end
  75.  
  76. function Forward()
  77.     CheckFuel()
  78.     Refuel()
  79.     while turtle.forward()==false do
  80.         turtle.forward()
  81.     end
  82. end
  83.  
  84. function Drop()
  85.     for i=5,16,1 do
  86.         turtle.select(i)
  87.         turtle.dropDown()
  88.     end
  89. end
  90.  
  91. function main()
  92.     Input()
  93.     Forward()
  94.     while true do
  95.         for i=1,breite-1,1 do
  96.             for j=1,laenge-1,1 do
  97.                 DetectAndReplace()
  98.                 Forward()
  99.             end
  100.             if i%2==1 and l~=breite then
  101.                 turtle.turnRight()
  102.                 Forward()
  103.                 turtle.turnRight()
  104.             elseif l~=breite then
  105.                 turtle.turnLeft()
  106.                 Forward()
  107.                 turtle.turnLeft()
  108.             end
  109.         end
  110.         if(breite%2==0) then
  111.             turtle.turnRight()
  112.             for i=1,breite,1 do
  113.                 Forward()
  114.             end
  115.             turtle.turnLeft()
  116.             Forward()
  117.             turtle.turnLeft()
  118.             turtle.turnLeft()
  119.         else
  120.             turtle.turnLeft()
  121.             for i=1,breite,1 do
  122.                 Forward()
  123.             end
  124.             turtle.turnLeft()
  125.             for i=1,laenge+1,1 do
  126.                 Forward()
  127.             end
  128.             turtle.turnLeft()
  129.             turtle.turnLeft()
  130.         end
  131.         Drop()
  132.         os.sleep(300)
  133.     end
  134. end
  135.  
  136. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement