Advertisement
AnonymusHochgenuss

baum

Feb 15th, 2020 (edited)
1,074
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.72 KB | None | 0 0
  1. function desc()
  2.  shell.run("clear")
  3.  print("The Turtle detects what Block Type is below. It compares the Block with all in his Inv. If the compare is success and the Turtle found the same Block Type of the Block under it in his Inventory than it does the Action for that Block Type was specified.")
  4.  print("")
  5.  print("Notice: The Turtle Slot-Numbers are place like reading a book. From Left to right and top to bottom")
  6.  print("")
  7.  write("Press Enter to Continue")
  8.  x=read()
  9.  shell.run("clear")
  10. end
  11. k=0
  12. if turtle.getItemCount(1) < 1 then
  13.  if k < 1 then
  14.   desc()
  15.  end
  16.  print("Slot 1 Block Type to go forward")
  17.  k=1
  18. end
  19. if turtle.getItemCount(2) < 1 then
  20.  if k < 1 then
  21.   desc()
  22.  end
  23.  print("Slot 2 Block Type to go right")
  24.  k=1
  25. end
  26. if turtle.getItemCount(3) < 1 then
  27.  if k < 1 then
  28.   desc()
  29.  end
  30.  print("Slot 3 Block Type to go Left")
  31.  print("       (or detect Chest Left)")
  32.  k=1
  33. end
  34. if turtle.getItemCount(4) < 1 then
  35.  if k < 1 then
  36.   desc()
  37.  end
  38.  print("Slot 4 Block type to detect tree")
  39.  print("                       (in front)")
  40.  k=1
  41. end
  42. if turtle.getItemCount(5) < 1 then
  43.  if k < 1 then
  44.   desc()
  45.  end
  46.  print("Slot 5 Wood Block of the Tree Type")
  47.  print("Slot 6 Seeds of the Tree Type")
  48.  k=1
  49. end
  50. if turtle.getItemCount(7) < 1 then
  51.  if k < 1 then
  52.   desc()
  53.  end
  54.  print("Slot 7 Dirt")
  55.  k=1
  56. end
  57. if turtle.getItemCount(8) < 1 then
  58.  print("Slot 8 Leaves of the Tree Type")
  59.  if k < 1 then
  60.   desc()
  61.  end
  62.  k=1
  63. end
  64. if k > 0 then
  65.  print("")
  66.  write("Press ENTER when ready")
  67.  read()
  68.  os.reboot()
  69. elseif k < 1 then
  70.  print("")
  71.  print("")
  72.  print("")
  73.  print("       Hold Strg + T for 3 sec.")
  74.  print("      to terminate the Programm ")
  75. end
  76. function up()
  77.  while not turtle.up() do
  78.   sleep(1)
  79.  end
  80. end
  81. function forward()
  82.  while not turtle.forward() do
  83.   sleep(1)
  84.  end
  85. end
  86. function down()
  87.  while not turtle.down() do
  88.   sleep(1)
  89.  end
  90. end
  91. function back()
  92.  while not turtle.back() do
  93.   sleep(1)
  94.  end
  95. end
  96. function suck()
  97.  turtle.select(6)
  98.  for i=1,4 do
  99.   turtle.suck()
  100.   turtle.turnRight()
  101.  end
  102. end
  103. function tree()
  104.  turtle.select(9)
  105.  turtle.dig()
  106.  forward()
  107.  h=0
  108.  turtle.digUp()
  109.  up()
  110.  turtle.select(5)
  111.  while turtle.compareUp() do
  112.   if h == 1 then
  113.    turtle.select(6)
  114.    turtle.placeDown()
  115.   end
  116.   turtle.select(5)
  117.   if turtle.compareUp() then
  118.    turtle.select(9)
  119.   else
  120.    turtle.select(6)
  121.   end
  122.   turtle.digUp()
  123.   for i=1,4 do
  124.    turtle.select(6)
  125.    turtle.dig()
  126.    turtle.turnRight()
  127.   end
  128.   up()
  129.   h=h+1
  130.   turtle.select(5)
  131.  end
  132.  while not turtle.detectDown() do
  133.   down()
  134.  end
  135.  back()
  136.  if not turtle.detectDown() then
  137.   down()
  138.  end
  139. end
  140. function drop()
  141.  for i=9,16 do
  142.   turtle.select(i)
  143.   while turtle.getItemCount(i) > 0 do
  144.    turtle.drop()
  145.   end
  146.  end
  147.  if turtle.getItemCount(5) > 1 then
  148.   turtle.select(5)
  149.   xlog=turtle.getItemCount(5)
  150.   xlog=xlog-1
  151.   turtle.transferTo(9,xlog)
  152.   drop()
  153.  end
  154. end
  155. function detect()
  156.  turtle.select(1)
  157.  if turtle.compareDown() then
  158.   turtle.select(8)
  159.   if turtle.compare() then
  160.    turtle.dig()
  161.   end
  162.   if turtle.detect() then
  163.    up()
  164.    sleep(1)
  165.    down()
  166.   end
  167.   forward()
  168.  end
  169.  turtle.select(2)
  170.  if turtle.compareDown() then
  171.   turtle.turnRight()
  172.   turtle.select(8)
  173.   if turtle.compare() then
  174.    turtle.dig()
  175.   end
  176.   forward()
  177.  end
  178.  turtle.select(3)
  179.  if turtle.compareDown() then
  180.   turtle.turnLeft()
  181.   if turtle.detect() then
  182.    drop()
  183.    turtle.select(6)
  184.    turtle.suckUp()
  185.    turtle.turnRight()
  186.   end
  187.   forward()
  188.  end
  189.  turtle.select(4)
  190.  if turtle.compareDown() then
  191.   turtle.select(5)
  192.   if turtle.compare() then
  193.    tree()
  194.   end
  195.   if not turtle.detect() then
  196.    if turtle.getItemCount(6) > 1 then
  197.     turtle.select(6)
  198.     turtle.place()
  199.    end
  200.   end
  201.   turtle.turnLeft()
  202.   turtle.turnLeft()
  203.   forward()
  204.  end
  205. end
  206. function relocate()
  207.  turtle.select(1)
  208.  if turtle.compareDown() then
  209.  else
  210.   turtle.select(2)
  211.   if turtle.compareDown() then
  212.    turtle.select(8)
  213.    if turtle.compare() then
  214.     turtle.dig()
  215.    end
  216.    if turtle.detect() then
  217.     turtle.turnRight()
  218.    end
  219.    forward()
  220.    if not turtle.detectDown() then
  221.     back()
  222.     turtle.turnRight()
  223.     forward()
  224.    end
  225.    turtle.select(1)
  226.    if turtle.compareDown() then
  227.    else
  228.     turtle.select(3)
  229.     if turtle.compareDown() then
  230.      turtle.forward()
  231.     else
  232.      back()
  233.      turtle.turnRight()
  234.      forward()
  235.     end
  236.    end
  237.   else
  238.    turtle.select(3)
  239.    if turtle.compareDown() then
  240.     if turtle.detect() then
  241.      drop()
  242.      turtle.turnRight()
  243.      forward()
  244.     else
  245.      forward()
  246.     end
  247.    else
  248.     turtle.select(4)
  249.     if turtle.compareDown() then
  250.      if turtle.detect() then
  251.       turtle.select(5)
  252.       if turtle.compare() then
  253.       else
  254.        turtle.select(6)
  255.        if turtle.compare() then
  256.        else
  257.         turtle.select(8)
  258.         if turtle.compare() then
  259.          turtle.dig()
  260.         else
  261.          up()
  262.          sleep(1)
  263.          down()
  264.         end
  265.        end
  266.       end
  267.      else
  268.       forward()
  269.       if not turtle.detectDown() then
  270.        back()
  271.        turtle.turnLeft()
  272.        if not turtle.forward() then
  273.         if turtle.detect() then
  274.          os.reboot()
  275.         end
  276.        else
  277.         if turtle.detect() then
  278.          os.reboot()
  279.         end
  280.        end
  281.       end
  282.       turtle.select(1)
  283.       if turtle.compareDown() then
  284.       else
  285.        turtle.select(7)
  286.        if turtle.compareDown() then
  287.         back()
  288.         back()
  289.         turtle.turnLeft()
  290.         turtle.turnLeft()
  291.        end
  292.       end
  293.      end
  294.     end
  295.     turtle.select(6)
  296.     if turtle.compareDown() then
  297.      up()
  298.     end
  299.     if not turtle.detectDown() then
  300.      if turtle.detectUp() then
  301.       while turtle.detectUp() do
  302.        turtle.select(9)
  303.        turtle.digUp()
  304.        up()
  305.       end
  306.      else
  307.       turtle.up()
  308.       while turtle.detectUp() do
  309.        turtle.select(9)
  310.        turtle.digUp()
  311.        up()
  312.       end
  313.      end
  314.      while not turtle.detectDown() do
  315.       down()
  316.      end
  317.      turtle.select(6)
  318.      if turtle.compareDown() then
  319.       turtle.digDown()
  320.       down()
  321.      end
  322.     elseif turtle.detectUp() then
  323.      while turtle.detectUp() do
  324.       turtle.select(9)
  325.       turtle.digUp()
  326.       up()
  327.      end
  328.      while not turtle.detectDown() do
  329.       down()
  330.      end
  331.      turtle.select(6)
  332.      if turtle.compareDown() then
  333.       turtle.digDown()
  334.       down()
  335.      end
  336.     end
  337.     turtle.select(7)
  338.     if turtle.compareDown() then
  339.      turtle.select(4)
  340.      while not turtle.compareDown() do
  341.       back()
  342.       if turtle.compareDown() then
  343.        turtle.turnLeft()
  344.        turtle.turnLeft()
  345.       else
  346.        forward()
  347.        turtle.turnRight()
  348.       end
  349.      end
  350.      forward()
  351.     end
  352.    end
  353.   end
  354.  end
  355. end
  356.  
  357. relocate()
  358. while true do
  359.  detect()
  360. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement