Guest User

test2

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