Advertisement
Gabby008

test

Aug 22nd, 2014
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.14 KB | None | 0 0
  1. --pastebin code: G47j7rDW
  2.  
  3. local bridge = peripheral.wrap("right")
  4. local net = peripheral.wrap("back")
  5.  
  6. bridge.clear()
  7.  
  8. local width = 100
  9.  
  10. local storageUnits = {
  11. {
  12. ["id"] = "cofh_thermalexpansion_energycell_3",
  13. ["name"] = "Resonant"
  14. },
  15. {
  16. ["id"] = "cofh_thermalexpansion_energycell_4",
  17. ["name"] = "Resonant"
  18. },
  19. {
  20. ["id"] = "cofh_thermalexpansion_energycell_5",
  21. ["name"] = "Resonant"
  22. },
  23. {
  24. ["id"] = "cofh_thermalexpansion_energycell_6",
  25. ["name"] = "Resonant"
  26. },
  27. {
  28. ["id"] = "cofh_thermalexpansion_energycell_7",
  29. ["name"] = "Resonant"
  30. },
  31. {
  32. ["id"] = "cofh_thermalexpansion_energycell_8",
  33. ["name"] = "Resonant"
  34. },
  35. {
  36. ["id"] = "cofh_thermalexpansion_energycell_9",
  37. ["name"] = "Resonant"
  38. },
  39. {
  40. ["id"] = "cofh_thermalexpansion_energycell_10",
  41. ["name"] = "Resonant"
  42. },
  43. {
  44. ["id"] = "cofh_thermalexpansion_energycell_11",
  45. ["name"] = "Resonant"
  46. },
  47.  
  48.  
  49.  
  50. {
  51. ["id"] = "harvester_0",
  52. ["name"] = "Tree Farm"
  53. },
  54. {
  55. ["id"] = "planter_0",
  56. ["name"] = "Planter"
  57.  
  58. }
  59. }
  60.  
  61. local offset = 0
  62. for key, storageUnit in pairs(storageUnits) do
  63. if net.getTypeRemote(storageUnit["id"]) == "cofh_thermalexpansion_energycell" then
  64. pxOffset = offset * 10
  65. --storageUnit["label"] = bridge.addText(4, 4 + pxOffset, storageUnit["name"], 0xffffff)
  66. storageUnit["bar"] = bridge.addBox(4, 14 + pxOffset, 0, 5, 0xCC0000, 0.9)
  67. storageUnit["bar"].setZ(2)
  68. storageUnit["bg"] = bridge.addBox(4, 14 + pxOffset, width, 5, 0x000000, 0.5)
  69. storageUnit["num"] = bridge.addText(4, 24 + pxOffset, "0/0", 0xffffff)
  70. --storageUnit["percent"] = bridge.addText(0 + bridge.getStringWidth(storageUnit["name"]), 4 + pxOffset, "##%", 0xffffff)
  71. offset = offset + 2
  72. elseif net.getTypeRemote(storageUnit["id"]) == "harvester" then
  73. pxOffset = offset * 10
  74. storageUnit["label"] = bridge.addText(4, 34 + pxOffset, storageUnit["name"].." :", 0xffffff)
  75. storageUnit["run"] = bridge.addText(0 + bridge.getStringWidth(storageUnit["name"]), 34 + pxOffset, "", 0xffffff)
  76. offset = offset + 1
  77. elseif net.getTypeRemote(storageUnit["id"]) == "planter" then
  78. pxOffset = offset * 10
  79. storageUnit["label"] = bridge.addText(4, 44 + pxOffset, storageUnit["name"].." :", 0xffffff)
  80. storageUnit["run"] = bridge.addText(0 + bridge.getStringWidth(storageUnit["name"]), 44 + pxOffset, "", 0xffffff)
  81. offset = offset + 1
  82. end
  83. end
  84.  
  85. while true do
  86. for i=#storageUnits,1,-1 do
  87. storageUnit = storageUnits[i]
  88. if net.isPresentRemote(storageUnit["id"]) then
  89. if net.getTypeRemote(storageUnit["id"]) == "cofh_thermalexpansion_energycell" then
  90. t = peripheral.wrap(storageUnit["id"])
  91. capacity = capacity + t.getMaxEnergyStored("")
  92.  
  93. amount = amount + t.getEnergyStored("")
  94. storageUnit["bar"].setWidth(width / capacity * amount)
  95. perc = math.floor(amount/capacity * 100)
  96. tCap = tostring(capacity)
  97. tAmt = tostring(amount)
  98. tPerc = tostring(perc)
  99. storageUnit["num"].setText(tAmt.."/"..tCap)
  100. --storageUnit["percent"].setText(tPerc.."%")
  101. end
  102. end
  103. end
  104. sleep(0.5
  105. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement