Advertisement
rhn

BotaniaOverflowHandler

rhn
Apr 24th, 2020
322
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.55 KB | None | 0 0
  1. if (fs.exists("choices") == false) then --Check if this is first time run, no saved choices on file
  2.     while true do
  3.         print("How many crates for turtle to empty from?(1-16):")
  4.         local answer = read()
  5.         if tonumber(answer)==nill then
  6.             print("-Wrong answer, input not a number-")
  7.         else
  8.             local answerv = tonumber(string.format("%." .. 0 .. "f", answer))
  9.             if (0 < answerv and answerv <= 16) then
  10.                 crates=answerv
  11.                 break
  12.             else
  13.                 print("-Wrong answer, input does not match range of choices-")
  14.             end
  15.         end
  16.     end
  17.  
  18.     --Write choices to file
  19.     local file = fs.open("choices","w")
  20.     file.writeLine("crates="..tostring(crates))
  21.  
  22.     file.close()
  23. end
  24.  
  25.  
  26. os.loadAPI("choices") -- Reads choices from file
  27. local crates= choices.crates
  28.  
  29.  
  30.  
  31. local function load()
  32.     for i=1,crates do
  33.         if i>1 then
  34.             turtle.back()
  35.         end
  36.         provider=peripheral.wrap("top")
  37.         turtle.select(i)
  38.         provider.pushItems("down",1,64,i)
  39.     end
  40.     for i=1,crates-1 do
  41.         turtle.forward()
  42.     end
  43. end
  44.  
  45. local function unload()
  46.     chest=peripheral.wrap("bottom")
  47.     for i=1,crates do
  48.         turtle.select(i)
  49.         chest.pullItems("up",i,64,i)
  50.     end
  51. end
  52.  
  53. local function cake()
  54.     chest=peripheral.wrap("bottom")
  55.     provider=peripheral.wrap("top")
  56.     provider.pushItems("down",1,64,1)
  57.     chest.pullItems("up",1,64,1)
  58. end
  59.  
  60. --return to home in case of restart
  61. while turtle.forward() do end
  62.  
  63.  
  64. while true do
  65.     load()
  66.     unload()
  67.     for i=1,50 do
  68.         cake()
  69.         sleep(3)
  70.     end
  71. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement