Advertisement
AnonymusHochgenuss

craftify

Apr 24th, 2024 (edited)
725
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.58 KB | None | 0 0
  1. local tArgs = { ... }
  2.  
  3. function suckdropDirection()
  4.  if input == "top" then
  5.   turtle.dropUp()
  6.  elseif input == "bottom" then
  7.   turtle.dropDown()
  8.  else
  9.   turtle.drop()
  10.  end
  11. end
  12.  
  13. function suckDirection()
  14.  if input == "top" then
  15.   turtle.suckUp()
  16.  elseif input == "bottom" then
  17.   turtle.suckDown()
  18.  else
  19.   turtle.suck()
  20.  end
  21. end
  22.  
  23. function dropDirection()
  24.  if output == "top" then
  25.   turtle.dropUp()
  26.  elseif output == "bottom" then
  27.   turtle.dropDown()
  28.  else
  29.   turtle.drop()
  30.  end
  31. end
  32.  
  33. function drop()
  34.  for i=5,12 do
  35.   if turtle.getItemCount(i) > 0 then
  36.    turtle.select(i)
  37.    for e=2,4 do
  38.     if turtle.compareTo(e) then
  39.      turtle.select(e)
  40.      suckdropDirection()
  41.      turtle.select(i)
  42.     end
  43.    end
  44.    suckdropDirection()
  45.   end
  46.  end
  47.  for i=2,4 do
  48.   if turtle.getItemCount(i) > 0 then
  49.    turtle.select(i)
  50.    dropDirection()
  51.   end
  52.  end
  53. end
  54.  
  55. function dropNotSelected()
  56.  if input == "top" then
  57.   if output == "bottom" then
  58.    turtle.drop()
  59.   elseif output == "front" then
  60.    turtle.dropDown()
  61.   else
  62.    turtle.dropUp()
  63.   end
  64.  elseif input == "bottom" then
  65.   if output == "top" then
  66.    turtle.drop()
  67.   elseif output == "front" then
  68.    turtle.dropUp()
  69.   else
  70.    turtle.dropDown()
  71.   end
  72.  elseif input == "front" then
  73.   if output == "top" then
  74.    turtle.dropDown()
  75.   elseif output == "bottom" then
  76.    turtle.dropUp()
  77.   else
  78.    turtle.drop()
  79.   end
  80.  end
  81. end
  82.  
  83. function pattern()
  84.  if tArgs[2] == "4" then
  85.   while turtle.getItemCount(2) < 64 do
  86.    turtle.select(2)
  87.    suckDirection()
  88.   end
  89.   while turtle.getItemCount(5) < 64 do
  90.    turtle.select(5)
  91.    suckDirection()
  92.   end
  93.   while turtle.getItemCount(6) < 64 do
  94.    turtle.select(6)
  95.    suckDirection()
  96.   end
  97.   while turtle.getItemCount(9) < 64 do
  98.    turtle.select(9)
  99.    suckDirection()
  100.   end
  101.   for k1=3,4 do
  102.    if turtle.getItemCount(k1) > 0 then
  103.     turtle.select(k1)
  104.     dropNotSelected()
  105.    end
  106.   end
  107.   for k2=7,8 do
  108.    if turtle.getItemCount(k2) > 0 then
  109.     turtle.select(k2)
  110.     dropNotSelected()
  111.    end
  112.   end
  113.   for k3=10,12 do
  114.    if turtle.getItemCount(k3) > 0 then
  115.     turtle.select(k3)
  116.     dropNotSelected()
  117.    end
  118.   end
  119.   for k4=13,16 do
  120.    if turtle.getItemCount(k4) > 0 then
  121.     turtle.select(k4)
  122.     dropNotSelected()
  123.    end
  124.   end
  125.  elseif tArgs[2] == "8" then
  126.   while turtle.getItemCount(2) < 64 do
  127.    turtle.select(2)
  128.    suckDirection()
  129.   end
  130.   while turtle.getItemCount(3) < 64 do
  131.    turtle.select(3)
  132.    suckDirection()
  133.   end
  134.   while turtle.getItemCount(5) < 64 do
  135.    turtle.select(5)
  136.    suckDirection()
  137.   end
  138.   while turtle.getItemCount(6) < 64 do
  139.    turtle.select(6)
  140.    suckDirection()
  141.   end
  142.   while turtle.getItemCount(7) < 64 do
  143.    turtle.select(7)
  144.    suckDirection()
  145.   end
  146.   while turtle.getItemCount(9) < 64 do
  147.    turtle.select(9)
  148.    suckDirection()
  149.   end
  150.   while turtle.getItemCount(10) < 64 do
  151.    turtle.select(10)
  152.    suckDirection()
  153.   end
  154.   while turtle.getItemCount(11) < 64 do
  155.    turtle.select(11)
  156.    suckDirection()
  157.   end
  158.   if turtle.getItemCount(4) > 0 then
  159.    turtle.select(4)
  160.    dropNotSelected()
  161.   end
  162.   if turtle.getItemCount(8) > 0 then
  163.    turtle.select(8)
  164.    dropNotSelected()
  165.   end
  166.   if turtle.getItemCount(12) > 0 then
  167.    turtle.select(12)
  168.    dropNotSelected()
  169.   end
  170.   for k4=13,16 do
  171.    if turtle.getItemCount(k4) > 0 then
  172.     turtle.select(k4)
  173.     dropNotSelected()
  174.    end
  175.   end
  176.  end
  177. end
  178.  
  179. if tArgs[1] == "ee3" then
  180.  if not fs.exists("ee3") then
  181.   shell.run("clear")
  182.   print("You ran this Program the first")
  183.   print("Time on this Turtle. By default")
  184.   print("this Turtle will Suck the Materials")
  185.   print("from the Top and Drop it down.")
  186.   print("")
  187.   write("Press ENTER to Continue")
  188.   read()
  189.   print("")
  190.   print("You can Change this after first")
  191.   print("start by editing the ee3 file.")
  192.   print("The first Line defines where it")
  193.   print("comes from and the second Line")
  194.   print("decides where it goes.")
  195.   print("")
  196.   print("Attention: the only accepted")
  197.   print("Directions are top, front & bottom")
  198.   print("Every other Entry will reset the File!")
  199.   print("")
  200.   write("Press ENTER to Accept and Start")
  201.   read()
  202.   file=fs.open("ee3","w")
  203.   file.writeLine("top")
  204.   file.writeLine("bottom")
  205.   file.close()
  206.   input="top"
  207.   ouput="bottom"
  208.  else
  209.   file=fs.open("ee3","r")
  210.   input=file.readLine()
  211.   output=file.readLine()
  212.   file.close()
  213.   if not input then
  214.    fs.delete("ee3")
  215.    shell.run("craftify ee3 "..tArgs[2])
  216.   end
  217.   if not output then
  218.    fs.delete("ee3")
  219.    shell.run("craftify ee3 "..tArgs[2])
  220.   end
  221.   if not input == "top" then
  222.    if not input == "bottom" then
  223.     if not input == "front" then
  224.      fs.delete("ee3")
  225.      shell.run("craftify ee3 "..tArgs[2])
  226.     end
  227.    end
  228.   end
  229.   if not output == "top" then
  230.    if not output == "bottom" then
  231.     if not output == "front" then
  232.      fs.delete("ee3")
  233.      shell.run("craftify ee3 "..tArgs[2])
  234.     end
  235.    end
  236.   end
  237.  end
  238.  shell.run("clear")
  239.  print("crafting with "..tArgs[2].." Items.")
  240.  print("input:  "..input)
  241.  print("output: "..output)
  242.  drop()
  243.  pattern()
  244.  if tArgs[2] == "4" then
  245.   q1="2"
  246.   q2="6"
  247.   q3="9"
  248.  else
  249.   q1="3"
  250.   q2="7"
  251.   q3="11"
  252.  end
  253.  for f=1,64 do
  254.   turtle.select(4)
  255.   turtle.craft()
  256.   dropDirection()
  257.   if f < 64 then
  258.    for q = 2,q1 do
  259.     while turtle.getItemCount(q) < 1 do
  260.      drop()
  261.      pattern()
  262.     end
  263.    end
  264.    for q = 5,q2 do
  265.     while turtle.getItemCount(q) < 1 do
  266.      drop()
  267.      pattern()
  268.     end
  269.    end
  270.    for q = 9,q3 do
  271.     while turtle.getItemCount(q) < 1 do
  272.      drop()
  273.      pattern()
  274.     end
  275.    end
  276.   end
  277.  end
  278.  drop()
  279.  shell.run("craftify ee3 "..tArgs[2])
  280. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement