Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local p = peripheral.wrap("right")
- local itemRef = {
- "exnihilo:exnihilo.iron_broken",
- "exnihilo:exnihilo.copper_broken",
- "exnihilo:exnihilo.tin_broken",
- "exnihilo:exnihilo.aluminum_broken",
- "exnihilo:exnihilo.gold_broken",
- "exnihilo:exnihilo.silver_broken",
- "exnihilo:exnihilo.lead_broken",
- "exnihilo:exnihilo.nickel_broken",
- "exnihilo:exnihilo.platinum_broken",
- "exnihilo:exnihilo.iron_crushed",
- "exnihilo:exnihilo.copper_crushed",
- "exnihilo:exnihilo.tin_crushed",
- "exnihilo:exnihilo.aluminum_crushed",
- "exnihilo:exnihilo.gold_crushed",
- "exnihilo:exnihilo.silver_crushed",
- "exnihilo:exnihilo.lead_crushed",
- "exnihilo:exnihilo.nickel_crushed",
- "exnihilo:exnihilo.platinum_crushed",
- "exnihilo:exnihilo.iron_powdered",
- "exnihilo:exnihilo.copper_powdered",
- "exnihilo:exnihilo.tin_powdered",
- "exnihilo:exnihilo.aluminum_powdered",
- "exnihilo:exnihilo.gold_powdered",
- "exnihilo:exnihilo.silver_powdered",
- "exnihilo:exnihilo.lead_powdered",
- "exnihilo:exnihilo.nickel_powdered",
- "exnihilo:exnihilo.platinum_powdered"
- }
- local itemCount = {}
- function initializeItemCount()
- if fs.exists("_itemCount_") and pcall(getSavedCount) then
- else
- for i = 1, #itemRef do
- itemCount[#itemCount+1] = 0
- end
- saveItemCount()
- end
- end
- function getSavedCount()
- local rFile = fs.open("_itemCount_", "r")
- for i = 1, #itemRef do
- itemCount[#itemCount+1] = tonumber(rFile.readLine())
- end
- rFile.close()
- end
- function saveItemCount()
- local oFile = fs.open("_itemCount_", "w")
- for _, v in pairs(itemCount) do
- oFile.writeLine(v)
- end
- oFile.close()
- end
- function printItemCount()
- term.clear()
- term.setCursorPos(1, 1)
- write("Broken")
- term.setCursorPos(1, 2)
- for i = 1, 9 do
- write(itemRef[i]:sub(19, 19) .. " ")
- end
- term.setCursorPos(1, 3)
- for i = 1, 9 do
- write(itemCount[i] .. " ")
- end
- term.setCursorPos(1, 4)
- write("Crushed")
- term.setCursorPos(1, 5)
- for i = 10, 18 do
- write(itemRef[i]:sub(19, 19) .. " ")
- end
- term.setCursorPos(1, 6)
- for i = 10, 18 do
- write(itemCount[i] .. " ")
- end
- term.setCursorPos(1, 7)
- write("Powdered")
- term.setCursorPos(1, 8)
- for i = 19, 27 do
- write(itemRef[i]:sub(19, 19) .. " ")
- end
- term.setCursorPos(1, 9)
- for i = 19, 27 do
- write(itemCount[i] .. " ")
- end
- end
- function checkItem(i)
- for n = 1, #itemRef do
- if i.name == itemRef[n] then
- return true, n
- end
- end
- return false
- end
- initializeItemCount()
- while true do
- printItemCount()
- while not turtle.suck(1) do
- end
- turtle.select(1)
- info = turtle.getItemDetail()
- ok, num = checkItem(info)
- if ok then
- itemCount[num] = itemCount[num] + 1
- if itemCount[num] == 4 then
- itemCount[num] = 0
- p.pullItem("down", num)
- turtle.transferTo(2, 1)
- turtle.transferTo(5, 1)
- turtle.transferTo(6, 1)
- turtle.craft()
- turtle.dropUp()
- else
- p.pushItem("down", 1, 1, num)
- end
- saveItemCount()
- else
- turtle.dropUp()
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement