AnonymusHochgenuss

wheat

Apr 20th, 2024 (edited)
463
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.39 KB | None | 0 0
  1. x= 12
  2. z= 12
  3. -- Settings --
  4. -- x = laenge
  5. -- z = breite (MUSS EINE GERADE ZAHL SEIN)
  6. -- Um die Änderung zu bestätigen muss die
  7. -- Datei "farmfirststart" gelöscht werden
  8. -- vor dem nächsten start des Programms
  9.  
  10. xid=os.getComputerID()
  11. os.setComputerLabel("Wheat-Farmer#"..xid)
  12. function farm()
  13.  shell.run("clear")
  14.  print("Farm Programm by M3veronMast3r")
  15.  print("------------------------------")
  16.  print("   !!!-WORK IN PROGRESS-!!!")
  17.  print("Sent all Fails to +491748274510")
  18. end
  19.  
  20.  
  21.  
  22. -- functions --
  23.  
  24. function forward()
  25.  while not turtle.forward() do
  26.   sleep(1)
  27.  end
  28. end
  29.  
  30. function back()
  31.  while not turtle.back() do
  32.   sleep(1)
  33.  end
  34. end
  35.  
  36. function reboot()
  37.  fields=x*z
  38.  if fields > 192 then
  39.   if field > 320 then
  40.    if fields > 448 then
  41.     if fields > 576 then
  42.      o=5
  43.     else
  44.      o=7
  45.     end
  46.    else
  47.     o=9
  48.    end
  49.   else
  50.    o=11
  51.   end
  52.  else
  53.   o=13
  54.  end
  55.  if fields > 704 then
  56.   shell.run("clear")
  57.   print("Fields over 704 Blocks are not Supported.")
  58.   print("The Turtle has only 16 Slots and it needs")
  59.   print("at least the first 4 to operate this farm.")
  60.   print("")
  61.   print("Means Slot 5 to 15 could be used to collect")
  62.   print("11 Slots * 64 is 704")
  63.   print("")
  64.   print("You are trying to create a Field of "..fields.." Blocks.")
  65.   print("")
  66.   print("edit the wheat config and make the field smaller")
  67.   print("")
  68.   print("Good Bye")
  69.   return
  70.  end
  71.  while turtle.getItemCount(16) < 1 do
  72.   shell.run("clear")
  73.   print("Need Chest for detecting DropOff")
  74.   print("in Slot 16. It must be the same")
  75.   print("Chest Type")
  76.   sleep(1)
  77.  end
  78.  shell.run("clear")
  79.  print("starting Farm Programm..")
  80.  turtle.select(16)
  81.  turtle.turnLeft()
  82.  if turtle.compare() then
  83.   turtle.turnRight()
  84.  else
  85.   while not turtle.compare() do
  86.    while not turtle.detect() do
  87.     forward()
  88.    end
  89.    if turtle.compare() then
  90.    else
  91.     turtle.turnRight()
  92.    end
  93.   end
  94.   turtle.turnRight()
  95.   farm()
  96.  end
  97. end
  98.  
  99. function check()
  100.  if turtle.getItemCount(e) < 1 then
  101.   while turtle.getItemCount(e) < 1 do
  102.    e=e+1
  103.    if e > 4 then
  104.     e=2
  105.     turtle.select(e)
  106.     return
  107.    end
  108.   end
  109.  end
  110.  turtle.select(e)
  111. end
  112.  
  113. function sort()
  114.  ot=o-1
  115.  for h=5,ot do
  116.   if turtle.getItemCount(15) > 1 then
  117.    while turtle.getItemCount(o) > 1 do
  118.     o=o-1
  119.     if o < 7 then
  120.      reboot()
  121.      turtle.turnLeft()
  122.      drop()
  123.      turtle.turnRight()
  124.      sort()
  125.      drop()
  126.      os.reboot()
  127.     end
  128.    end
  129.   end
  130.   if turtle.getItemCount(h) > 1 then
  131.    if turtle.getItemCount(e) < 32 then
  132.     turtle.select(h)
  133.     harvested=turtle.getItemCount(h)
  134.     if turtle.compareTo(1) then
  135.      for j=2,4 do
  136.       SeedSlot=turtle.getItemCount(j)
  137.       if SeedSlot < 64 then
  138.        SeedsNeeded= 64-SeedSlot
  139.        if SeedsNeeded > harvested then
  140.         turtle.transferTo(j,harvested)
  141.        else
  142.         turtle.transferTo(j,SeedsNeeded)
  143.        end
  144.       end
  145.      end
  146.     end
  147.    end
  148.    if turtle.getItemCount(h) > 63 then
  149.     turtle.select(h)
  150.     if turtle.getItemCount(2) > 32 and turtle.getItemCount(3) > 32 and turtle.getItemCount(4) > 32 then
  151.      if turtle.compareTo(1) then
  152.       tomuchseeds=turtle.getItemCount(h)
  153.       turtle.transferTo(13,tomuchseeds)
  154.       turtle.transferTo(14,tomuchseeds)
  155.       turtle.transferTo(15,tomuchseeds)
  156.      end
  157.     end
  158.     if not turtle.compareTo(1) then
  159.      if h < o and turtle.getItemCount(h) > 0 then
  160.       wheatspace=64-turtle.getItemCount(o)
  161.       if wheatspace > 1 then
  162.        if turtle.getItemCount(h) < wheatspace then
  163.         wheatharvest=turtle.getItemCount(h)
  164.         turtle.transferTo(o,wheatharvest)
  165.        else
  166.         turtle.transferTo(o,wheatspace)
  167.         v=o+1
  168.         wheatspace=64-turtle.getItemCount(v)
  169.         while turtle.getItemCount(h) > 1 do
  170.          turtle.transferTo(v,wheatspace)
  171.          if turtle.getItemCount(v) > 63 then
  172.           v=v+1
  173.           if v > 15 then
  174.            return
  175.           end
  176.          end
  177.         end
  178.        end
  179.       else
  180.        v=o+1
  181.        wheatspace=64-turtle.getItemCount(v)
  182.        while turtle.getItemCount(h) > 1 do
  183.         turtle.transferTo(v,wheatspace)
  184.         if turtle.getItemCount(v) > 63 then
  185.          v=v+1
  186.          if v > 15 then
  187.           return
  188.          end
  189.         end
  190.        end
  191.       end
  192.      end
  193.     end
  194.    end
  195.   end
  196.  end
  197. end
  198.  
  199. function drop()
  200.  for i=o,15 do
  201.   turtle.select(i)
  202.   turtle.drop()
  203.  end
  204. end
  205.  
  206. function Seeds()
  207.  if turtle.getItemCount(e) < 1 then
  208.   while turtle.getItemCount(1) < 1 do
  209.    shell.run("clear")
  210.    print("Need some Seeds in first Slot to start.")
  211.    print("Continue if you inserted some")
  212.    print("")
  213.    write("Press ENTER to continue")
  214.    read()
  215.    if turtle.getItemCount(1) < 1 then
  216.     print("")
  217.     print("can't start without having Seeds in Slot 1")
  218.     print("The Turtle needs at least 1 of them to")
  219.     print("separate Seeds from Wheat.")
  220.     print("")
  221.     print("Insert now some Seeds in Slot 1")
  222.     print("")
  223.     write("Press ENTER to continue")
  224.     read()
  225.    end
  226.   end
  227.  end
  228.  if turtle.getItemCount(1) > 1 then
  229.   eh=turtle.getItemCount(1)-1
  230.   turtle.select(1)
  231.   turtle.transferTo(15,eh)
  232.  end
  233. end
  234.  
  235. -- functions end --
  236.  
  237. reboot()
  238. e=2
  239. r=0
  240. r2=0
  241. f=0
  242. check()
  243. if not fs.exists("farmfirststart") then
  244.   file=fs.open("farmfirststart","w")
  245.   file.writeLine(x)
  246.   file.writeLine(z)
  247.   file.close()
  248.   farm()
  249. elseif fs.exists("farmfirststart") then
  250.  file=fs.open("farmfirststart","r")
  251.  x=tonumber(file.readLine())
  252.  z=tonumber(file.readLine())
  253.  file.close()
  254. end
  255.  
  256. while true do
  257.  if turtle.getItemCount(16) < 1 then
  258.   reboot()
  259.  end
  260.  farm()
  261.  Seeds()
  262.  while z > 0 do
  263.   while x > 0 do
  264.    turtle.select(5)
  265.    turtle.digDown()
  266.    turtle.digDown()
  267.    turtle.suckDown()
  268.    turtle.suckDown()
  269.    sort()
  270.    check()
  271.    turtle.placeDown()
  272.    if x > 1 then
  273.     forward()
  274.    end
  275.    x=x-1
  276.    r2=r2+1
  277.   end
  278.   while r2 > 0 do
  279.    x=x+1
  280.    r2=r2-1
  281.   end
  282.   r=r+1
  283.   z=z-1
  284.   if z > 0 then
  285.    if f < 1 then
  286.     turtle.turnRight()
  287.     forward()
  288.     turtle.turnRight()
  289.     f=1
  290.    elseif f > 0 then
  291.     turtle.turnLeft()
  292.     forward()
  293.     turtle.turnLeft()
  294.     f=0
  295.    end
  296.   end
  297.  end
  298.  turtle.turnRight()
  299.  while r > 0 do
  300.   if r > 1 then
  301.    forward()
  302.   end
  303.   r=r-1
  304.   z=z+1
  305.  end
  306.  drop()
  307.  turtle.turnRight()
  308.  f=0
  309.  for t=1,3000 do
  310.   term.setCursorPos(1,6)
  311.   print("                                 ")
  312.   term.setCursorPos(1,6)
  313.   count=3000-t
  314.   print("Sleeping for "..count.." Seconds.")
  315.   sleep(1)
  316.  end
  317. end
Add Comment
Please, Sign In to add comment