Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local essentia = {}
- local jars = peripheral.getNames()
- local m = peripheral.wrap("monitor_0")
- local monCoord = {}
- function shortName(str)
- --print(string.len(str))
- if string.len(str) > 8 then
- str = string.sub(str, 1, 8)..".."
- end
- return str
- end
- 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) == "tt_aspectContainer" then
- asp2 = peripheral.call(j, "getAspects")
- for k, l in pairs(asp2) do
- asp = l
- end
- countasp = peripheral.call(j, "getAspectCount", asp)
- essentia[asp] = countasp
- end
- end
- end
- function printEssentia()
- local x = 1
- local y = 1
- monCoord[x] = {}
- m.setTextScale(2)
- m.setTextColor(colors.white)
- for i,j in sortEss(essentia) do
- if j<=20 then m.setTextColor(colors.red) end
- if j<64 and j>20 then m.setTextColor(colors.yellow) end
- if j==64 then m.setTextColor(colors.green) end
- m.setCursorPos(x,y)
- m.write(shortName(i))
- m.setCursorPos(x+11,y)
- m.write(tostring(j))
- monCoord[x][y] = i
- if y < 16 then
- y = y+1
- else
- y = 1
- x = x+14
- monCoord[x] = {}
- end
- end
- end
- function refresh()
- m.clear()
- scanEssentia()
- printEssentia()
- end
- while true do
- refresh()
- sleep(15)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement