SchindlerShadow

Thaumcraft-Essence-Monitor

Aug 27th, 2014
714
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.06 KB | None | 0 0
  1. start = 10
  2. mon = peripheral.wrap("front")
  3. peripherals = peripheral.getNames()
  4. x, y = mon.getSize()
  5. aspects = {"Aer", "Aqua", "Ignis", "Ordo", "Perditio", "Terra", "Gelum", "Lux", "Motus", "Potentia", "Saxum", "Vacuos", "Victus", "Bestia", "Fames", "Granum", "Iter", "Limus", "Metallum", "Mortuus", "Permutatio", "Praecantatio", "Sano", "Tempestas", "Tenebrae", "Vinculum", "Vitreus", "Volatus", "Tempus", "Alienis", "Auram", "Corpus", "Exanimis", "Herba", "Spiritus", "Venenum", "Arbor", "Cognitio", "Sensus", "Humanus", "Instrumentum", "Lucrum", "Messis", "Perfodio", "Fabrico", "Machina", "Meto", "Pannus", "Tutamen"}
  6. essence = {}
  7. labels = {}
  8. --jars = {}
  9. print("Screen size: X:"..x.." Y:"..y.." AREA:"..x*y)
  10.  
  11. if (x < 18) or x * (y-1) < 1000 then
  12.   print("ERROR: screen is too small")
  13. end
  14.  
  15. function getSize()
  16.   x, y = mon.getSize()
  17. end
  18.  
  19. function pos(xPos,yPos)
  20.   mon.setCursorPos(xPos,yPos)
  21. end
  22.  
  23. function get(thing,jars)
  24. result = 0
  25.   for i=1,#jars do
  26.     result = result + peripheral.call(jars[i], "getAspectCount", thing)
  27.   end
  28.  
  29. return result
  30.  
  31. end
  32.  
  33. function allJars()
  34.   list = {}
  35.  
  36.   for _, name in pairs(peripheral.getNames()) do
  37.     if peripheral.getType(name) == "tilejar" or peripheral.getType(name) == "tilejarvoid" then
  38.       table.insert(list, name)
  39.     end
  40.   end
  41.     return list
  42.  
  43. end
  44.  
  45.  
  46. function write(txt)
  47.   mon.write(txt)
  48. end
  49.  
  50. function draw(jars)
  51.   mon.setBackgroundColor(colors.gray)
  52.   getSize()
  53.   col = x / 18
  54.   row = 50
  55.   count = 1
  56.  
  57.   for i=1,#aspects do
  58.     essence[i] = get(string.lower(aspects[i]),jars)
  59.   end
  60.  
  61.   mon.clear()
  62.   pos((x/2)-2,1)
  63.   write("Aspects")
  64.  
  65.   for i=1,col do
  66.     for z=2,y do
  67.       if 5+(start+((i-1)*18)+13) < x and count < row then
  68.         pos(start+((i-1)*18),z)
  69.         write(aspects[count])
  70.         pos(start+((i-1)*18)+13,z)
  71.         write(string.format("%i",essence[count]))
  72.         if count <= row then
  73.           count = count+1
  74.         end
  75.        
  76.         --sleep(0.01)
  77.       end
  78.     end
  79.   end  
  80. end
  81.  
  82. while true do
  83.  
  84.   jars = allJars()
  85.   draw(jars)
  86.   sleep(3)
  87.  
  88. end
Advertisement
Add Comment
Please, Sign In to add comment