Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- time waiting after each check
- local timeout = 30
- local terminalside = "back"
- -- name of item, itemid, itemmetavalue (0 for items without metadata), qty to keep in system
- local observerlist = {
- { name = "Pulverized Obsidian", id = 20264, metadata = 3, maxqty = 360},
- { name = "Glass", id = 20, metadata = 0, maxqty = 128},
- { name = "Invar Ingot", id = 20264, metadata = 71, maxqty = 32},
- { name = "Graphite Bar", id = 18006, metadata = 2, maxqty = 64}
- }
- -- Iterates through items in observerlist and checks if the current quantity
- -- in the ae is lower than the quantity you wish to have, if this is the case
- -- the computer crafts the difference of items.
- function checkItems()
- for k,item in pairs(observerlist) do
- currentqty = peripheral.call(terminalside, "countOfItemType", item.id, item.metadata)
- if currentqty < item.maxqty then
- print("need to craft " .. (item.maxqty - currentqty) .. " " .. item.name .. "(" .. item.id ..":"..item.metadata..")")
- craftItem(item.id, item.metadata, item.maxqty - currentqty)
- end
- end
- end
- -- Crafts Items
- function craftItem(itemid, itemmeta, itemqty)
- item = {id = itemid, dmg = itemmeta, qty = itemqty}
- peripheral.call(terminalside, "requestCrafting", item)
- end
- while true do
- checkItems()
- os.sleep(timeout)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement