Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --CONFIG
- local Items = {
- ["ME_Basic_Processor"] = {
- ["id"] = 4362,
- ["dmg"] = 18,
- ["name"] = "ME Basic Processor"
- },
- ["ME_Advanced_Processor"] = {
- ["id"] = 4362,
- ["dmg"] = 19,
- ["name"] = "ME Advanced Processor"
- },
- ["Silicon"] = {
- ["id"] = 4362,
- ["dmg"] = 13,
- ["name"] = "Silicon"
- }
- }
- local keep = {
- {
- ["Item"] = Items["ME_Basic_Processor"],
- ["Minimum"] = 10000
- },
- {
- ["Item"] = Items["ME_Advanced_Processor"],
- ["Minimum"] = 10000
- },
- {
- ["Item"] = Items["Silicon"],
- ["Minimum"] = 10000
- }
- }
- local side = "back"
- --END CONFIG
- local per = peripheral.wrap(side)
- local function stack(item, qty)
- return {
- ["id"] = item.id,
- ["dmg"] = item.dmg,
- ["qty"] = qty
- }
- end
- local function hasEnough(keep)
- local count = per.countOfItemType(keep.Item.id, keep.Item.dmg)
- return count >= keep.Minimum
- end
- local function requestEnough(keep)
- local count = per.countOfItemType(keep.Item.id, keep.Item.dmg)
- local request = keep.Minimum - count + 64
- print("Requesting " .. tostring(request) .. " " .. keep.Item.name)
- per.requestCrafting(stack(keep.Item, request))
- keep.Waiting = true
- end
- local timer = 0
- while true do
- for i = 1, #keep do
- local k = keep[i]
- if not k.Waiting then
- if not hasEnough(k) then
- requestEnough(k)
- end
- else
- if hasEnough(k) then
- k.Waiting = false
- end
- end
- end
- sleep(10)
- timer = timer + 1
- if timer == 30 then
- os.reboot() -- reset the system every 5 minutes. lazy fix to a shitty problem...
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement