Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (fs.exists("choices") == false) then --Check if this is first time run, no saved choices on file
- while true do
- print("How many crates for turtle to empty from?(1-16):")
- local answer = read()
- if tonumber(answer)==nill then
- print("-Wrong answer, input not a number-")
- else
- local answerv = tonumber(string.format("%." .. 0 .. "f", answer))
- if (0 < answerv and answerv <= 16) then
- crates=answerv
- break
- else
- print("-Wrong answer, input does not match range of choices-")
- end
- end
- end
- --Write choices to file
- local file = fs.open("choices","w")
- file.writeLine("crates="..tostring(crates))
- file.close()
- end
- os.loadAPI("choices") -- Reads choices from file
- local crates= choices.crates
- local function load()
- for i=1,crates do
- if i>1 then
- turtle.back()
- end
- provider=peripheral.wrap("top")
- turtle.select(i)
- provider.pushItems("down",1,64,i)
- end
- for i=1,crates-1 do
- turtle.forward()
- end
- end
- local function unload()
- chest=peripheral.wrap("bottom")
- for i=1,crates do
- turtle.select(i)
- chest.pullItems("up",i,64,i)
- end
- end
- local function cake()
- chest=peripheral.wrap("bottom")
- provider=peripheral.wrap("top")
- provider.pushItems("down",1,64,1)
- chest.pullItems("up",1,64,1)
- end
- --return to home in case of restart
- while turtle.forward() do end
- while true do
- load()
- unload()
- for i=1,50 do
- cake()
- sleep(3)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement