Advertisement
RandomShovel

[1.5] [CC][IC2][AE][TE] Monitor GUI

Oct 6th, 2013
451
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.54 KB | None | 0 0
  1. -------------
  2. -- Config  --
  3. -------------
  4.  
  5. terminalSide = "right"
  6. wiredModemSide = "back"
  7.  
  8. refreshTime = 1
  9. -- Time in seconds until the screen GUI refreshes
  10.  
  11. AppliedEnergistics = false
  12. -- Gets the used | max storage in your AE system
  13. -- Currently doesn't have a bar
  14.  
  15. ThermalExpansion = false
  16. -- Gets the capacity | max amount of MJ stored in your energy cells
  17.  
  18. IndustrialCraft = false
  19. -- Gets the capacity | remaining amount of EU stored in your "Batboxes"
  20.  
  21.  
  22. --------------
  23. --  Tables  --
  24. --------------
  25.  
  26. EnergyUnits = {}
  27. MinecraftJoules = {}
  28. AppliedStorage = {}
  29. -- All units must be in ""s and separated by a ,
  30.  
  31. ---------------
  32. -- Variables --
  33. ---------------
  34.  
  35. bridge = peripheral.wrap(tostring(terminalSide))
  36. net = peripheral.wrap(tostring(wiredModemSide))
  37.  
  38. currentEU = 0
  39. currentMJ = 0
  40. currentStorage = 0
  41.  
  42. maxEU = 0
  43. maxMJ = 0
  44. maxStorage = 0
  45.  
  46.  
  47. -----------------
  48. --  Functions  --
  49. -----------------
  50.  
  51. function displayText()
  52.  bridge.clear()
  53.    
  54.  if IndustrialCraft == true then
  55.   cEU = bridge.addText(3, 16, "0", 0xFFFFFF)
  56.   mEU = bridge.addText(3, 16, "0", 0xFFFFFF)
  57.   divEU = bridge.addText(3, 16, "|", 0xFFFFFF)
  58.   cEU.setZIndex(1)
  59.   mEU.setZIndex(1)
  60.   divEU.setZIndex(1)
  61.  end
  62.  
  63.  if ThermalExpansion == true then
  64.   cMJ = bridge.addText(4, 40, "0", 0xFFFFFF)
  65.   mMJ = bridge.addText(4, 40, "0", 0xFFFFFF)
  66.   divMJ = bridge.addText(4, 40, "|", 0xFFFFFF)
  67.   cMJ.setZIndex(1)
  68.   mMJ.setZIndex(1)
  69.   divMJ.setZIndex(1)
  70.  end
  71.    
  72.  if AppliedEnergistics == true then
  73.   cAE = bridge.addText(4, 64, "0", 0xFFFFFF)
  74.   mAE = bridge.addText(4, 64, "0", 0xFFFFFF)
  75.   divAE = bridge.addText(4, 64, "|", 0xFFFFFF)
  76.   cAE.setZIndex(1)
  77.   mAE.setZIndex(1)
  78.   divAE.setZIndex(1)
  79.  end
  80. end
  81.  
  82.  
  83. function grabData()
  84.  if IndustrialCraft == true then
  85.   for i = 1, #EnergyUnits do
  86.    currentEU = currentEU + net.callRemote(EnergyUnits[i], "getStored")
  87.    maxEU = maxEU + net.callRemote(EnergyUnits[i], "getCapacity")
  88.   end
  89.   cEU.setText(""..currentEU)
  90.   divEU.setX(string.len(currentEU)*6 + 8)
  91.   mEU.setX(string.len(currentEU)*6 + 14)
  92.   mEU.setText(""..maxEU.." EU")
  93.  end
  94.    
  95.  if ThermalExpansion == true then
  96.   for i = 1, #MinecraftJoules do
  97.    currentMJ = currentMJ + net.callRemote(MinecraftJoules[i], "getEnergyStored")
  98.    maxMJ = maxMJ + net.callRemote(MinecraftJoules[i], "getMaxEnergyStored")
  99.   end
  100.   cMJ.setText(""..currentMJ)
  101.   divMJ.setX(string.len(currentMJ)*6 + 8)
  102.   mMJ.setX(string.len(currentMJ)*6 + 14)
  103.   mMJ.setText(""..maxMJ.." MJ")
  104.  end
  105.    
  106.  if AppliedEnergistics == true then
  107.   for i = 1, #AppliedStorage do
  108.    currentStorage = currentStorage + net.callRemote(AppliedStorage[i], "getStoredItemCount")
  109.    maxStorage = maxStorage + net.callRemote(AppliedStorage[i], "getRemainingItemCount")
  110.   end
  111.   cAE.setText(""..currentStorage)
  112.   divAE.setX(string.len(currentStorage)*6 + 8)
  113.   mAE.setX(string.len(currentStorage)*6 + 14)
  114.   mAE.setText(""..maxStorage.." Stored")
  115.  end
  116. end
  117.  
  118. function displayBars()
  119.  if IndustrialCraft == true then
  120.   EUBar = bridge.addGradientBox(4, 3, 0, 10, 0x0000FF, 0.5, 0x999999, 0.7, 1)
  121.   EUBack = bridge.addGradientBox(3, 2, 102, 12, 0x666666, 0.5, 0x999999, 0.5, 1)
  122.   EUBack.setZIndex(0)
  123.   EUBar.setZIndex(1)
  124.   EURatio = currentEU / maxEU
  125.   EUWidth = 100 * EURatio
  126.   EUBar.setWidth(EUWidth)
  127.  end
  128.  
  129.  if ThermalExpansion == true then
  130.   MJBar = bridge.addGradientBox(4, 27, 0, 10, 0x0000FF, 0.5, 0x999999, 0.7, 1)
  131.   MJBack = bridge.addGradientBox(3, 26, 102, 12, 0x666666, 0.5, 0x999999, 0.5, 1)
  132.   MJBack.setZIndex(0)  
  133.   MJBar.setZIndex(1)
  134.   MJRatio = currentMJ / maxMJ
  135.   MJWidth = 100 * MJRatio
  136.   MJBar.setWidth(MJWidth)
  137.  end
  138. end
  139.  
  140. function resetValues()
  141.  -- I could've merged this with grabData(), but this is somewhat better in my opinion
  142.  currentEU = 0
  143.  currentMJ = 0
  144.  currentStorage = 0
  145.    
  146.  maxEU = 0
  147.  maxMJ = 0
  148.  maxStorage = 0
  149. end
  150.  
  151.  
  152.  
  153. ------------
  154. --  Main  --
  155. ------------
  156.  
  157. term.clear()
  158. term.setCursorPos(1, 1)
  159. print("By default, the glasses bridge must be on the right")
  160. print("By default, the wired modem must be on the back")
  161. print("Do you want to edit that?")
  162. write("> ")
  163. response = read()
  164.  
  165. if response == "Yes" or response == "yes" then
  166.  term.clear()
  167.  term.setCursorPos(1, 1)
  168.  print("Opening config...")
  169.  sleep(2)
  170.  shell.run("edit", shell.getRunningProgram())
  171. else
  172.  term.clear()
  173.  term.setCursorPos(1, 1)
  174.  print("Activating GUI")
  175.  sleep(2)
  176.  term.clear()
  177.  term.setCursorPos(1, 1)
  178.  print("GUI Activated")
  179.  while true do
  180.   displayText()
  181.   grabData()
  182.   displayBars()
  183.  
  184.   bridge.addText(6, 90, "Made by RandomShovel", 0xFF0000)
  185.  
  186.   sleep(refreshTime)
  187.   resetValues()
  188.  end
  189. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement