Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- monitorSide = "top"
- redstoneSide = "left"
- outputSide = "back"
- inputSide = "Down" -- suckDown/Up
- mon = peripheral.wrap("top")
- f = io.open("items.txt", "w")
- function show()
- for s = 1, 16 do
- local item = turtle.getItemDetail(s)
- local line = ""
- for k,v in pairs(item) do
- if k == "count" then
- k = "x"
- v = string.format("%02d", v)
- end
- if k == "name" then
- line = line .. "\"".. v .."\", "
- else
- line = line .. "[".. k .."]=".. v ..", "
- end
- end
- print(line)
- f:write(line)
- f:write("\n")
- --term.setCursorPos(1, s)
- end
- f:flush()
- --term.setCursorPos(1,1)
- end
- function outputItems()
- repeat
- for i = 1, 16 do
- turtle.select(i)
- turtle.drop(64)
- end
- turtle.select(1)
- sleep(1)
- local hasItems = 0
- for s = 1, 16 do
- hasItems = hasItems + turtle.getItemCount(s)
- end
- sleep(1)
- until hasItems == 0
- redstone.setOutput(outputSide, false)
- end
- function inputItems()
- for i = 1, 16 do
- turtle["suck" .. inputSide](64)
- end
- end
- while true do
- if redstone.getInput(redstoneSide) then
- print("Redstone Signal Received!")
- show()
- sleep(1)
- --
- print("Waiting for repeated Redstone Input to output Items!")
- local wait = true
- while wait do
- if redstone.getInput(redstoneSide) then
- wait = false
- print("Outputting Items!")
- outputItems()
- end
- sleep(0.1)
- end
- sleep(1)
- print("Inputting items!")
- inputItems()
- print("Done!")
- sleep(1)
- else
- sleep(0.1)
- end
- if redstone.getInput("front") then
- f:close()
- print("Stop Signal received!")
- mon.write("Stop Signal received!")
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement