Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("left")
- recvID = 68
- local jars = peripheral.getNames()
- local essentia = {}
- local jarSize = 64 --Max number of essentia per jar(always <= 64)
- function fillTable()
- for i,j in pairs(jars) do
- if peripheral.getType(j) == "tt_aspectContainer" then
- asp = peripheral.call(j, "getAspects")
- countasp = peripheral.call(j, "getAspectCount", asp)
- if asp ~= nil then essentia[asp] = math.floor(countasp) end
- --print(countasp)
- --print(asp..":"..countasp)
- end
- end
- end
- function scanBeans()
- rednet.send(recvID, "scan")
- print("Scanning beans...")
- local message
- while message ~= "scanned" do
- id,message = rednet.receive()
- end
- print("Bean Scan complete.")
- end
- function scanJars()
- for i, j in pairs(essentia) do
- print(i .. ": " .. j)
- if j < jarSize and i~=nil then
- refillJar(i, (jarSize - j))
- end
- end
- end
- function refillJar(asp, amo) --aspect, amount
- t = {asp, amo}
- local msg = textutils.serialize(t)
- rednet.send(recvID, msg)
- print("Waiting to add " .. amo .. " to " .. asp .. ".")
- message = ""
- while message ~= "refilled" do
- id,message = rednet.receive()
- end
- print("Added " .. amo .. " to " .. asp .. ".")
- end
- fillTable()
- scanBeans()
- sleep(2)
- scanJars()
- rednet.close("left")
Advertisement
Add Comment
Please, Sign In to add comment