Guest User

t

a guest
Jun 9th, 2013
1,835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.38 KB | None | 0 0
  1. local bridge = peripheral.wrap("left")
  2. local net = peripheral.wrap("back")
  3.  
  4. local width = 50
  5. local machines = {
  6.     {
  7.     ["id"] = "nuclear_reactor_0",
  8.     ["name"] = "Matter Fab"
  9.     }
  10. }
  11.  
  12. local storages = {
  13.     {
  14.     ["id"] = "mfsu_0",
  15.     ["name"] = "MFSU"
  16.     }
  17. }
  18.  
  19. function round(num, idp)
  20.   local mult = 10^(idp or 0)
  21.   return math.floor(num * mult + 0.5) / mult
  22. end
  23.  
  24. bridge.clear()
  25.    
  26.  
  27. for key,value in pairs(machines) do
  28.     value["label"] = bridge.addText(5,5,"Nuclear Reactor:",0xC5360F)
  29.     value["heatTitle"] = bridge.addText(5,15,"H",0x000000)
  30.     value["heatTitle"].setScale(0.7)
  31.     value["progressbar"] = bridge.addBox(10,15,50,5,0xff0000,0.9)
  32.     value["progressbar"].setZIndex(10)
  33.     value["progressbar"].setGradient(2)
  34.     value["progressbar"].setColor2(0x33ff00)
  35.     value["progressbar"].setAlpha(0.5)
  36.     value["progressbarmarker"] = bridge.addBox(10,15,1,5,0x000000,1)
  37.     value["progressbarmarker"].setZIndex(11)
  38. end
  39.  
  40. local offset = 17
  41. for key,value in pairs(storages) do
  42.     value["label"] = bridge.addText(5,5+offset,"MFSU:",0xC5360F)
  43.     value["heatTitle"] = bridge.addText(5,15+offset,"E",0x000000)
  44.     value["heatTitle"].setScale(0.7)
  45.     value["progressbar"] = bridge.addBox(10,15+offset,50,5,0x0033ff,0.9)
  46.     value["progressbar"].setZIndex(10)
  47.     value["progressbar"].setGradient(2)
  48.     value["progressbar"].setColor2(0x66ccff)
  49.     value["progressbar"].setAlpha(0.5)
  50.     value["progressbarmarker"] = bridge.addBox(10,15+offset,1,5,0x000000,1)
  51.     value["progressbarmarker"].setZIndex(11)
  52. end
  53.  
  54. local heat, maxheat, curHeat
  55.  
  56. while true do
  57.     for i=#machines,1,-1 do
  58.             machine = machines[i]
  59.         if (net.isPresentRemote(machine["id"])) then
  60.             heat = net.callRemote(machine["id"],"getHeat")
  61.             maxHeat = net.callRemote(machine["id"],"getMaxHeat")
  62.             curHeat = width / maxHeat * heat
  63.  
  64.             machine["progressbarmarker"].setX(10 + curHeat)
  65.         end
  66.     end
  67.  
  68.     for i=#storages,1,-1 do
  69.             storage = storages[i]
  70.         if (net.isPresentRemote(storage["id"])) then
  71.             stored = net.callRemote(storage["id"],"getStored")
  72.             capacity = net.callRemote(storage["id"],"getCapacity")
  73.             curStored = width / capacity * stored
  74.  
  75.             storage["progressbarmarker"].setX(10 + curStored)
  76.         end
  77.     end
  78.  
  79.  
  80.     os.sleep(0.5)
  81. end
  82.  
  83.  
  84.  
  85. -- arguments: x, y, width, width, color, opacity
  86. -- mybox = bridge.addBox(0,0,80,40,0x0099FF,0.7)
  87.  
  88. -- arguments: x, y, text, color
  89. -- mytext = bridge.addText(10, 10, "hello!", 0xCC0000)
Advertisement
Add Comment
Please, Sign In to add comment