Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local essentia = {}
- local jars = peripheral.getNames()
- local m = peripheral.wrap("top")
- local monCoord = {}
- local currEssentia
- local fillAmt = 0
- local rowsActive = true
- local emptyjars = 0
- function sortEss(t)
- local keys = {}
- for k in pairs(t) do keys[#keys+1] = k end
- table.sort(keys)
- local i = 0
- return function()
- i = i+1
- if keys[i] then
- return keys[i], t[keys[i]]
- end
- end
- end
- function scanEssentia()
- for i,j in ipairs(jars) do
- if peripheral.getType(j) == "tilejar" then
- asp = peripheral.call(j, "getAspects")
- --print(asp[1])
- if asp[1] then
- countasp = asp[1]["quantity"]
- nameasp = asp[1]["name"]
- if countasp > 0 then
- if essentia[string.lower(nameasp)] then
- essentia[string.lower(nameasp)] = essentia[string.lower(nameasp)] + math.floor(countasp)
- else
- essentia[string.lower(nameasp)] = math.floor(countasp)
- end
- end
- -- print(countasp)
- print(nameasp..":"..countasp)
- else
- emptyjars= emptyjars+1
- end
- -- print(peripheral.getType(j))
- end
- end
- end
- function printEssentia()
- m.clear()
- m.setCursorPos(1,1)
- m.setTextColor(colors.white)
- local x = 1
- local y = 1
- monCoord[x] = {}
- for i,j in sortEss(essentia) do
- if j<=20 then m.setTextColor(colors.red) end
- if j<40 and j>20 then m.setTextColor(colors.yellow) end
- if j>=40 then m.setTextColor(colors.green) end
- m.setCursorPos(x,y)
- m.write(i)
- m.setCursorPos(x+13,y)
- m.write(tostring(j))
- -- print(j)
- monCoord[x][y] = i
- if y < 20 then
- y = y+1
- else
- y = 1
- x = x+17
- monCoord[x] = {}
- end
- end
- --emptyjars print
- if emptyjars<=5 then m.setTextColor(colors.red) end
- if emptyjars<10 and emptyjars>5 then m.setTextColor(colors.yellow) end
- if emptyjars>=10 then m.setTextColor(colors.green) end
- m.setCursorPos(18,23)
- m.write("Empty Warded Jars: "..emptyjars)
- m.setTextColor(colors.white)
- end
- while true do
- emptyjars=0
- local k = next(essentia)
- while k do
- essentia[k] = nil
- k = next(essentia)
- end
- scanEssentia()
- print("Scanning essentia complete")
- printEssentia()
- print("Printing essentia complete")
- sleep(1)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement