Advertisement
Scarjit

Untitled

Mar 19th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. function math.round(num, idp)
  2. assert(type(num) == "number", "math.round: wrong argument types (<number> expected for num)")
  3. assert(type(idp) == "number" or idp == nil, "math.round: wrong argument types (<integer> expected for idp)")
  4. local mult = 10 ^ (idp or 0)
  5. if num >= 0 then return math.floor(num * mult + 0.5) / mult
  6. else return math.ceil(num * mult - 0.5) / mult
  7. end
  8. end
  9.  
  10. local reaktor = peripheral.wrap("back")
  11. local chest = peripheral.wrap('chest_1')
  12. local cell = peripheral.wrap('tile_thermalexpansion_cell_resonant_name_0')
  13. local g = peripheral.wrap("right")
  14.  
  15. function addBg()
  16. g.addBox(1,1,200,80,0xFFFFFF,0.2)
  17. end
  18.  
  19. function write()
  20. local energyMax = cell.getMaxEnergyStored()
  21. local energyStored = cell.getEnergyStored()
  22.  
  23. g.addText(3,2,"Generated Rf/t: "..tostring(reaktor.getEnergyProducedLastTick()),0x000000)
  24. g.addText(3,12,"Control Rod Level: "..tostring(reaktor.getControlRodLevel(1)),0x000000)
  25. g.addText(3,22,"Reactor Status: ", 0x000000)
  26. if reaktor.getActive() then
  27. g.addText(85,22,"Online",0x00FF00)
  28. else
  29. g.addText(85,22,"Offline",0xFF0000)
  30. end
  31. g.addText(3,32,"Energy Stored: "..((energyStored/energyMax)*100).."%",0x000000)
  32. g.addText(3,42,"Fuel left: "..tostring(reaktor.getFuelAmount()+GetItemsInChest()*1000).."mB",0x000000)
  33. g.addText(3,52,"mB/t: "..tostring(reaktor.getFuelConsumedLastTick()),0x000000)
  34.  
  35. local fuelticksleft = ((reaktor.getFuelAmount()+GetItemsInChest()*100)/reaktor.getFuelConsumedLastTick())
  36. local secleft = fuelticksleft/20
  37. local minleft = secleft/60
  38. local hourleft = minleft/60
  39. local daysleft = hourleft/24
  40.  
  41. if daysleft > 1 then
  42. g.addText(3,62,"Time left: "..tostring(math.round(daysleft,2)).." Days",0x000000)
  43. elseif hourleft > 1 then
  44. g.addText(3,62,"Time left: "..tostring(math.round(hourleft,2)).." Hours",0x000000)
  45. elseif minleft > 1 then
  46. g.addText(3,62,"Time left: "..tostring(math.round(minleft,2)).." Minutes",0xFF00FF)
  47. elseif secleft > 1 then
  48. g.addText(3,62,"Time left: "..tostring(math.round(secleft,2)).." Seconds",0xFF00FF)
  49. elseif fuelticksleft > 1 then
  50. g.addText(3,62,"Time left: "..tostring(fuelticksleft).." Ticks",0xFF00FF)
  51. else
  52. g.addText(3,62," -- FUEL DEPLETED -- ",0xFF0000)
  53. end
  54. end
  55.  
  56. function GetItemsInChest()
  57. local yellorium = 0
  58. for i = 1, chest.getInventorySize() do
  59. local s = chest.getStackInSlot(i)
  60. if s then
  61. if s.display_name == "Yellorium Block" then
  62. yellorium = yellorium + s.qty*9
  63. elseif s.display_name == "Yellorium Ingot" or s.display_name == "Blutonium Ingot" then
  64. yellorium = yellorium + s.qty
  65. end
  66. end
  67. end
  68. return yellorium
  69. end
  70.  
  71. function start()
  72. while true do
  73. g.clear()
  74. addBg()
  75. write()
  76. g.sync()
  77. sleep(1)
  78. end
  79. end
  80. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement