Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getItemsCount(target)
- -- if no target specified break
- if not target then
- print("No target specified")
- print("use top, bottom, front, back, left, right")
- print("or use 'minecraft:hopper', 'minecraft:dropper', 'minecraft:chest' etc.")
- print("example getItemCount(\"minecraft:dropper\")")
- break
- end
- -- determin as side has been given or a container to search for
- if (target == "top") or (target == "bottom") or (target == "front") or (target == "back") or (target == "left") or (target == "right") then
- local container = peripheral.wrap(target)
- else
- local container = peripheral.find(target)
- end
- totalItems = 0
- local slots = container.size()
- for slot=1, slots do
- item = container.getItemDetail(slot)
- if item ~= nil then
- -- getting count
- amount = item.count
- totalItems = totalItems + amount
- end
- -- result
- return totalItems
- end
- function getItemsMaxCount(target)
- -- if no target specified break
- if not target then
- print("No target specified")
- print("use top, bottom, front, back, left, right")
- print("or use 'minecraft:hopper', 'minecraft:dropper', 'minecraft:chest' etc.")
- print("example getItemsMaxCount(\"minecraft:dropper\")")
- break
- end
- -- determin as side has been given or a container to search for
- if (target == "top") or (target == "bottom") or (target == "front") or (target == "back") or (target == "left") or (target == "right") then
- local container = peripheral.wrap(target)
- else
- local container = peripheral.find(target)
- end
- totalMaxItems = 0
- local slots = container.size()
- for slot=1, slots do
- item = container.getItemDetail(slot)
- -- totalMaxItems
- if item ~= nil then
- -- getting maxCount
- totalMaxItems = totalMaxItems + item.maxCount
- else
- -- assuming stackable to 64
- totalMaxItems = totalMaxItems + 64
- end
- -- result
- return totalMaxItems
- end
- -- loop
- while true do
- turtle.dig()
- term.clear()
- term.setCursorPos(1, 1)
- print("container: "..getItemsInHopper().."/"..getMaxItemsInHopper())
- os.sleep(0.2)
- -- wait if hopper is full and inventory has atleast 16 items
- if (getItemsCount() == getItemsMaxCount() and turtle.getItemCount() >= 16) then
- term.clear()
- term.setCursorPos(1, 1)
- print("container: "..getItemsInHopper().."/"..getMaxItemsInHopper().." -> +16 -> stopped minning")
- -- while getItemsInHopper() == getMaxItemsInHopper() do
- while turtle.getItemCount() >= 16 do
- os.sleep(1)
- end
- end
- end
Add Comment
Please, Sign In to add comment