Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local tArgs = {...}
- local p = peripheral.wrap("bottom")
- local product = p.getStackInSlot(1)
- local recipe = {product = product.display_name, schematic = {}, ingredient = {}}
- for i=2, 82 do
- local slot = p.getStackInSlot(i)
- local name = slot.display_name
- if slot then
- recipe.schematic[i] = name
- if recipe.ingredient[name] then
- recipe.ingredient[name] = recipe.ingredient[name] + slot.qty
- else
- recipe.ingredient[name] = slot.qty
- end
- end
- end
- local c = peripheral.wrap("top")
- local chestSize = c.getInventorySize()
- local chest = {quantity={}}
- for i=1, chestSize do
- local slot = c.getStackInSlot(i)
- if slot then
- local name = slot.display_name
- chest[i] = name
- if chest.quantity[name] then
- chest.quantity[name] = chest.quantity[name] + slot.qty
- else
- chest.quantity[name] = slot.qty
- end
- end
- end
- for k,v in pairs(recipe.ingredient) do
- local name = k
- local required = v
- local available = chest.quantity[k]
- if available >= required then
- term.setTextColor(colors.green)
- print(k.." | "..available.."/"..v)
- else
- term.setTextColor(colors.red)
- print(k.." : "..available.."/"..v)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment