Advertisement
Guest User

Untitled

a guest
Nov 27th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. local essentia = {}
  2. local jars = peripheral.getNames()
  3. local m = peripheral.wrap("monitor_0")
  4. local monCoord = {}
  5.  
  6.  
  7. function shortName(str)
  8. --print(string.len(str))
  9. if string.len(str) > 8 then
  10. str = string.sub(str, 1, 8)..".."
  11. end
  12. return str
  13. end
  14.  
  15. function sortEss(t)
  16. local keys = {}
  17. for k in pairs(t) do keys[#keys+1] = k end
  18. table.sort(keys)
  19. local i = 0
  20. return function()
  21. i = i+1
  22. if keys[i] then
  23. return keys[i], t[keys[i]]
  24. end
  25. end
  26. end
  27.  
  28. function scanEssentia()
  29. for i,j in ipairs(jars) do
  30. if peripheral.getType(j) == "tt_aspectContainer" then
  31. asp2 = peripheral.call(j, "getAspects")
  32. for k, l in pairs(asp2) do
  33. asp = l
  34. end
  35. countasp = peripheral.call(j, "getAspectCount", asp)
  36. essentia[asp] = countasp
  37. end
  38. end
  39. end
  40.  
  41. function printEssentia()
  42. local x = 1
  43. local y = 1
  44. monCoord[x] = {}
  45. m.setTextScale(2)
  46. m.setTextColor(colors.white)
  47. for i,j in sortEss(essentia) do
  48. if j<=20 then m.setTextColor(colors.red) end
  49. if j<64 and j>20 then m.setTextColor(colors.yellow) end
  50. if j==64 then m.setTextColor(colors.green) end
  51. m.setCursorPos(x,y)
  52. m.write(shortName(i))
  53. m.setCursorPos(x+11,y)
  54. m.write(tostring(j))
  55. monCoord[x][y] = i
  56. if y < 16 then
  57. y = y+1
  58. else
  59. y = 1
  60. x = x+14
  61. monCoord[x] = {}
  62. end
  63. end
  64. end
  65.  
  66. function refresh()
  67. m.clear()
  68. scanEssentia()
  69. printEssentia()
  70. end
  71.  
  72. while true do
  73. refresh()
  74. sleep(15)
  75. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement