Advertisement
manaphoenix

Essentia Tracker

Jul 11th, 2018
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.26 KB | None | 0 0
  1. local monitor = peripheral.find("monitor")
  2. local essentia = peripheral.wrap("back")
  3.  
  4. local aspects = {
  5.     Aer = 0,
  6.     Aqua = 0,
  7.     Ignis = 0,
  8.     Ordo = 0,
  9.     Perditio = 0,
  10.     Terra = 0,
  11.     Gelum = 0,
  12.     Lux = 0,
  13.     Motus = 0,
  14.     Permutatio = 0,
  15.     Potentia = 0,
  16.     Tempestas = 0,
  17.     Vacuos = 0,
  18.     Venenum = 0,
  19.     Victus = 0,
  20.     Vitreus = 0,
  21.     Bestia = 0,
  22.     Fames = 0,
  23.     Herba = 0,
  24.     Iter = 0,
  25.     Limus = 0,
  26.     Metallum = 0,
  27.     Mortuus = 0,
  28.     Praecantatio = 0,
  29.     Sano = 0,
  30.     Tenebrae = 0,
  31.     Vinculum = 0,
  32.     Volatus = 0,
  33.     Alienis = 0,
  34.     Arbor = 0,
  35.     Auram = 0,
  36.     Corpus = 0,
  37.     Exanimis = 0,
  38.     Spiritus = 0,
  39.     Vitium = 0,
  40.     Cognitio = 0,
  41.     Sensus = 0,
  42.     Humanus = 0,
  43.     Instrumentum = 0,
  44.     Lucrum = 0,
  45.     Messis = 0,
  46.     Perfodio = 0,
  47.     Fabrico = 0,
  48.     Machina = 0,
  49.     Meto = 0,
  50.     Pannus = 0,
  51.     Telum = 0,
  52.     Tutamen = 0,
  53.     Infernus = 0,
  54.     Luxuria = 0,
  55.     Gula = 0,
  56.     Desidia = 0,
  57.     Ira = 0,
  58.     Invidia = 0,
  59.     Superbia = 0,
  60.     Tempus = 0
  61. }
  62. local threshHold = 1000
  63.  
  64. -- sorting
  65. do
  66. local s = {}
  67. for i,v in pairs(aspects) do
  68.     table.insert(s,i)
  69. end
  70. table.sort(s)
  71. aspects = {}
  72. for i,v in ipairs(s) do
  73.     aspects[i] = {v,0}
  74. end
  75. end
  76.  
  77. local function aspectScan()
  78.     local etable = {essentia.getAspects()}
  79.     local sorted = {}
  80.     local calling = {}
  81.    
  82.     for i = 1, #etable, 2 do
  83.         if i % 2 == 1 then
  84.             table.insert(sorted,etable[i])
  85.         end
  86.         calling[etable[i]] = etable[i+1]
  87.     end
  88.    
  89.     table.sort(sorted)
  90.    
  91.     local result = {}
  92.    
  93.     for i,v in ipairs(sorted) do
  94.         result[v] = calling[v]
  95.     end
  96.    
  97.     for i,v in ipairs(aspects) do
  98.         if result[v[1]] then
  99.             v[2] = result[v[1]]
  100.         else
  101.             v[2] = 0
  102.         end
  103.     end
  104. end
  105.  
  106. local function outputToMonitor(tab)
  107.     monitor.clear()
  108.     monitor.setCursorPos(1,1)
  109.     local posx,posy = 1,1
  110.  
  111.     for i,v in ipairs(tab) do
  112.         if v[2] < threshHold then
  113.             monitor.setTextColor(colors.red)
  114.         elseif v[2] > 2001 then
  115.             monitor.setTextColor(colors.green)
  116.         else
  117.             monitor.setTextColor(colors.yellow)
  118.         end
  119.         monitor.setCursorPos(posx,posy)
  120.         monitor.write(v[1] .. ":")
  121.         local offset = (posx + 19) - string.len(v[2])
  122.         monitor.setCursorPos(offset,posy)
  123.         monitor.write(v[2])
  124.         if posy < 19 then
  125.             posy = posy + 1
  126.         else
  127.             posy = 1
  128.             posx = posx + 25
  129.         end
  130.     end
  131. end
  132.  
  133. aspectScan()
  134. outputToMonitor(aspects)
  135.  
  136. while true do
  137.     os.sleep(30)
  138.     aspectScan()
  139.     outputToMonitor(aspects)
  140. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement