Advertisement
Guest User

EssentiaMonitor

a guest
Jun 24th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.22 KB | None | 0 0
  1. print("EssentiaMonitor is running")
  2.  
  3. mon = peripheral.wrap("monitor_0")
  4. mon.clear()
  5.  
  6.  
  7. -- Alle Essentia Namen
  8. Essentia = {"Aer", "Terra", "Ignis", "Aqua", "Ordo", "Perditio", "Vacuos", "Lux", "Tempestas", "Motus", "Gelum", "Vitreus", "Victus", "Venenum", "Potentia", "Permutatio", "Metallum", "Mortuus", "Volatus", "Tenebrae", "Spiritus", "Sano", "Iter", "Alienis", "Praecantatio", "Auram", "Vitium", "Limus", "Herba", "Arbor", "Bestia", "Corpus", "Exanimis", "Cognitio", "Sensus", "Humanus", "Messis", "Perfodio", "Instrumentum", "Meto", "Telum", "Tutamen", "Fames", "Lucrum", "Fabrico", "Pannus", "Machina", "Vinculum", "Luxuria", "Infernus", "Superbia", "Gula", "Invidia", "Desidia", "Ira", "Tempus"}
  9. Ess_status = {}
  10.  
  11. -- Liest die Essentia Werte vom me aus
  12.  
  13. function lText(txt)--gibt die textlaenge aus--
  14.   zUp=0
  15.   txt=tostring(txt)
  16.   for i=1, #txt do
  17.     txt:gsub(i,i)
  18.     zUp=zUp+1
  19.   end
  20.   return zUp
  21. end
  22.  
  23. function expandtext(txt, fzahl)
  24.     --print(txt)
  25.     stingzeichen=lText(txt)
  26.  
  27.    
  28.     hinzu = fzahl -stingzeichen
  29.     --print(hinzu)
  30.     while hinzu > 0 do
  31.         txt=txt.." "
  32.         hinzu=hinzu-1
  33.        
  34.     end
  35.  
  36.         --txt=txt.." "
  37.         --stringzeichen=stringzeichen+1
  38.        
  39.        
  40.     --end
  41.    
  42.     return txt
  43. end
  44.  
  45. function readessentiaValues(essentianame)
  46.     essentia= peripheral.wrap("EssentiaProvider_2")
  47.     return essentia.getAmount((essentianame))
  48. end
  49.  
  50.  
  51.  
  52.  
  53. function monitorrun()
  54.  
  55.     Ess_status["red"]={}
  56.     Ess_status["green"]={}
  57.     Ess_status["yellow"]={}
  58.     Ess_status["greengold"]={}
  59.     mindestwert= 64
  60.    
  61.     optimalwert= 500
  62.     goldwert= 9999
  63.     greengoldentry=1
  64.     greenentry=1
  65.     yellowentry=1
  66.     redentry=1
  67.  
  68.     for i=1,#Essentia do
  69.    
  70.    
  71.        
  72.  
  73.  
  74.         value = readessentiaValues(Essentia[i])
  75.  
  76.         if value < mindestwert then
  77.             Ess_status["red"][redentry]= " "..expandtext(tostring(Essentia[i]), 12).." ["..expandtext(tostring(value), 6).."] "
  78.             redentry=redentry+1
  79.            
  80.         else
  81.  
  82.             if value > optimalwert then
  83.                 if value > goldwert then
  84.                     Ess_status["greengold"][greengoldentry]= " "..expandtext(tostring(Essentia[i]), 12).." ["..expandtext(tostring(value), 6).."] "            
  85.                     greengoldentry=greengoldentry+1
  86.                
  87.                 else
  88.                     Ess_status["green"][greenentry]= " "..expandtext(tostring(Essentia[i]), 12).." ["..expandtext(tostring(value), 6).."] "            
  89.                     greenentry=greenentry+1
  90.                 end
  91.             else
  92.                 Ess_status["yellow"][yellowentry]= " "..expandtext(tostring(Essentia[i]), 12).." ["..expandtext(tostring(value), 6).."] "
  93.                 yellowentry=yellowentry+1
  94.             end
  95.  
  96.  
  97.         end
  98.  
  99.  
  100.  
  101.  
  102.     end
  103.  
  104.  
  105.     mon.setTextScale(1)
  106.     spalten={1,25,49}
  107.     akt_spalte=1
  108.     zeile=1
  109.    
  110.    
  111.     for i=1,#Ess_status["greengold"] do
  112.        
  113.         if zeile==20 then
  114.             akt_spalte=akt_spalte+1
  115.             zeile=1
  116.            
  117.         end
  118.        
  119.         mon.setCursorPos(spalten[akt_spalte], zeile)
  120.         mon.setBackgroundColor(colors.lime)
  121.         mon.setTextColor(colors.orange)
  122.         mon.write(Ess_status["greengold"][i])
  123.         mon.setTextColor(colors.white)
  124.         mon.setBackgroundColor(colors.black)
  125.         zeile=zeile+1
  126.    
  127.        
  128.        
  129.    
  130.     end
  131.        
  132.     for i=1,#Ess_status["green"] do
  133.        
  134.         if zeile==20 then
  135.             akt_spalte=akt_spalte+1
  136.             zeile=1
  137.            
  138.         end
  139.        
  140.         mon.setCursorPos(spalten[akt_spalte], zeile)
  141.         mon.setBackgroundColor(colors.lime)
  142.         mon.setTextColor(colors.black)
  143.         mon.write(Ess_status["green"][i])
  144.         mon.setTextColor(colors.white)
  145.         mon.setBackgroundColor(colors.black)
  146.         zeile=zeile+1
  147.    
  148.        
  149.        
  150.    
  151.     end
  152.    
  153.     for i=1,#Ess_status["yellow"] do
  154.        
  155.         if zeile==20 then
  156.             akt_spalte=akt_spalte+1
  157.             zeile=1
  158.            
  159.         end
  160.        
  161.         mon.setCursorPos(spalten[akt_spalte], zeile)
  162.         mon.setBackgroundColor(colors.yellow)
  163.         mon.setTextColor(colors.black)
  164.         mon.write(Ess_status["yellow"][i])
  165.         mon.setTextColor(colors.white)
  166.         mon.setBackgroundColor(colors.black)
  167.         zeile=zeile+1
  168.    
  169.        
  170.        
  171.    
  172.     end
  173.    
  174.     for i=1,#Ess_status["red"] do
  175.        
  176.         if zeile==20 then
  177.             akt_spalte=akt_spalte+1
  178.             zeile=1
  179.            
  180.         end
  181.        
  182.         mon.setCursorPos(spalten[akt_spalte], zeile)
  183.         mon.setBackgroundColor(colors.red)
  184.         mon.setTextColor(colors.black)
  185.         mon.write(Ess_status["red"][i])
  186.         mon.setTextColor(colors.white)
  187.         mon.setBackgroundColor(colors.black)
  188.         zeile=zeile+1
  189.    
  190.        
  191.        
  192.    
  193.     end
  194.    
  195.         mon.setCursorPos(spalten[akt_spalte], zeile)
  196.         mon.setBackgroundColor(colors.magenta)
  197.         mon.setTextColor(colors.purple)
  198.         mon.write(" Essentia Monitor V1.0 ")
  199.         mon.setTextColor(colors.white)
  200.         mon.setBackgroundColor(colors.black)  
  201.    
  202.    
  203.    
  204. end
  205.    
  206.    
  207.  
  208.  
  209.  
  210. while true do
  211. monitorrun()
  212. os.sleep(3)
  213. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement