Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Prints Essentia, and ammounts
- --Miner8149
- local essentia = {}
- local connected = peripheral.getNames()
- local m = peripheral.wrap("top")
- m.setTextScale(0.5)
- local xMax, yMax = m.getSize()
- local xMon, yMon
- local monCoord = {}
- local currEssentia
- local redLevel = 5000
- local grnLevel = 100000
- local colLength = 28
- --***********************
- 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 getScreenSize()
- xMax, yMax = m.getSize()
- if(xMax == 15) then xMon = 1 end
- if(xMax == 36) then xMon = 2 end
- if(xMax == 57) then xMon = 3 end
- if(xMax == 79) then xMon = 4 end
- if(yMax == 10) then yMon = 1 end
- if(yMax == 24) then yMon = 2 end
- if(yMax == 38) then yMon = 3 end
- if(yMax == 52) then yMon = 4 end
- print(string.format("Screen Size %dx%d", xMon, yMon))
- end
- --***********************
- function scanEssentia()
- essentia = {}
- for i,j in ipairs(connected) do
- if peripheral.getType(j) == "EssentiaProvider" then
- aspectList = {peripheral.call(j, "getAspects")} --# Take all results, stick them in a table.
- --if #aspectList == 1 then --# This may be needed for regular jars?
- -- countasp = peripheral.call(j, "getAmount", aspectList[1])
- -- if countasp > 0 then
- -- essentia[aspectList[1]] = math.floor(countasp)
- -- end
- --else --# As for your provider block thingy:
- for k = 0, #aspectList / 2 - 1 do
- essentia[aspectList[k*2+1]] = aspectList[k*2+2]
- end
- --end
- end
- end
- end
- --***********************
- function printEssentia()
- m.setTextColor(colors.white)
- local x = 1
- local y = 1
- for i,j in sortEss(essentia) do
- if j<=redLevel then m.setTextColor(colors.red) end
- if j<grnLevel and j>redLevel then m.setTextColor(colors.yellow) end
- if j>=grnLevel then m.setTextColor(colors.green) end
- m.setCursorPos(x,y)
- m.write(i)
- m.setCursorPos(x+13,y)
- printNum(j)
- if y < colLength then
- y = y+1
- else
- y = 1
- x = x+19
- end
- end
- m.setTextColor(colors.white)
- end
- --***********************
- function printNum(number)
- local newNum = 0
- if number < 9999 then
- m.write(tostring(number))
- elseif number >= 9999 and number < 1000000 then
- newNum = number/1000
- m.write(string.format("%dK", newNum))
- elseif number >= 1000000 and number < 1000000000 then
- newNum = number/1000000
- m.write(string.format("%dM", newNum))
- else
- m.write("LOTS")
- end
- end
- --***********************
- function refresh()
- m.clear()
- getScreenSize()
- scanEssentia()
- printEssentia()
- print("Refreshed")
- sleep(5)
- end
- refresh()
- while (true) do refresh() end
Add Comment
Please, Sign In to add comment