Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- lp = peripheral.wrap("left")
- local jars = {}
- local beans = {}
- local beancounts = {}
- pnames = peripheral.getNames()
- for k,v in ipairs(pnames) do
- if peripheral.getType(v) == "tilejar" then
- aspects = peripheral.call(v, "getAspects")
- if aspects then
- aspect = string.lower(aspects[1]["name"])
- print("got aspect jar: ", aspect)
- jars[aspect] = aspects[1]["quantity"]
- end
- end
- end
- local data = lp.getAvailableItems()
- for k,v in pairs(data) do
- item = v.getValue1()
- if item.getName() == "Mana Bean" then
- tag = item.getTagCompound()
- aspect = tag["value"]["Aspects"]["value"][1]["value"]["key"]["value"]
- beans[aspect] = item
- beancounts[aspect] = v.getValue2()
- print("system has ", beancounts[aspect], " ", aspect)
- end
- end
- local n = 0
- for k,v in pairs(jars) do
- print(k, v)
- if beans[k] then
- if v < 64 then
- count = 64 - v
- if count > beancounts[k] then
- count = beancounts[k]
- end
- print("requesting ", count, " of ", k, ": ",beans[k])
- result = lp.makeRequest(beans[k], count)
- if result == "DONE" then
- -- print(result)
- n = n + 1
- end
- end
- end
- if n == 5 then
- break
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement