Advertisement
rhn

AutoCompactor

rhn
Apr 18th, 2020
304
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.57 KB | None | 0 0
  1. craftoption=        {"1x1", "2x2",      "3x3",                  "2 vertical",   "2 horizontal", "3 horizontal", "3 shapeless"}
  2. craftoptionslots={  {1},    {1,2,5,6},  {1,2,3,5,6,7,9,10,11},  {1,5},          {1,2},          {1,2,3},        {1,2,3}}
  3.  
  4. if (fs.exists("choices") == false) then --Check if this is first time run, no saved choices on file
  5.     while true do --Asks for type of crops
  6.             print("Please pick crafting pattern:")
  7.             for i=1, #craftoption do
  8.                 print(i..". "..craftoption[i])
  9.             end
  10.             local answer = read()
  11.             if tonumber(answer)==nill then
  12.                 print("-Wrong answer, input not a number-")
  13.             else
  14.                 local answerv = tonumber(string.format("%." .. 0 .. "f", answer))
  15.                 if (0 < answerv and answerv <= #craftoption) then
  16.                     craftchoice=answerv
  17.                     print("Crafting method chosen: "..craftoption[answerv])
  18.                     break
  19.                 else
  20.                     print("-Wrong answer, input does not match range of choices-")
  21.                 end
  22.             end
  23.     end
  24.     --Write choices to file
  25.     local file = fs.open("choices","w")
  26.     file.writeLine("craftchoice="..tostring(craftchoice))
  27.     file.close()
  28. end
  29.  
  30. os.loadAPI("choices") -- Reads choices from file
  31. local craftchoice = choices.craftchoice
  32.  
  33. --Empty inventory from items from before restart
  34. for i=1,16 do
  35.     turtle.select(i)
  36.     turtle.dropDown()
  37. end
  38.  
  39.  
  40. while true do
  41.     for _,i in pairs(craftoptionslots[craftchoice]) do
  42.         turtle.select(i)
  43.         while not turtle.suckUp(1) do
  44.             sleep(5)
  45.         end
  46.     end
  47.     turtle.select(4)
  48.     turtle.craft()
  49.     if turtle.getItemCount(4)>0 then
  50.         while not turtle.dropDown() do
  51.             sleep(1)
  52.         end
  53.     end
  54. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement