Advertisement
Jackson_Pike

ME Status

Jun 17th, 2016
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.29 KB | None | 0 0
  1.  
  2.  
  3. ----ME Status Program---Jackson_Pike----Connect wired modem to computer, ME controller, and Monitor
  4. -- I also reccommend a 5x4 monitor. (4 tall)
  5. ---Changes------
  6. --12/3/2016--Added automatic peripheral wrapping
  7. function getControl()
  8.  local names = peripheral.getNames()
  9.  local i, name
  10.  for i, name in pairs(names) do
  11.   if peripheral.getType(name) == "appeng_me_tilecontroller" then
  12.    return peripheral.wrap(name)
  13.   else
  14.  
  15.   end
  16.  end
  17. end
  18. function getMonitor()
  19.  local names = peripheral.getNames()
  20.  local i, name
  21.  for i, name in pairs(names) do
  22.   if peripheral.getType(name) == "monitor" then
  23.    return peripheral.wrap(name)
  24.   else
  25.  
  26.   end
  27.  end
  28. end
  29. -------Wrapping Peripherals--------------------------
  30. control = getControl()
  31. mon = getMonitor()
  32. mon.setBackgroundColor(colors.black)
  33. mon.clear()
  34.     function Draw_Line(xPos, yPos, length)
  35.         mon.setCursorPos(xPos, yPos)
  36.         mon.setBackgroundColor(colors.purple)---Change to Desired Color
  37.         mon.write(string.rep(" ", length))
  38.     end
  39. while true do
  40. monX, monY = mon.getSize() ---- Getting Size of Monitor
  41. -----------------------------------------------------
  42. mon.setBackgroundColor(colors.black)
  43. -------------------------Defining Variables----------------
  44. BUsed = control.getUnusedBytes()-----Methods Error, actually returns Used Bytes
  45. BFree = control.getFreeBytes()
  46. BTotal = control.getTotalBytes()
  47. EnergyStored = control.getEnergyStored("appeng_me_tilecontroller_0")-----Change based on your number
  48. EnergyFinal = EnergyStored / 2
  49. --pollCraft = control.getJobList()--I hope to add later. Get's items crafting in MAC
  50. BUsedDecimal = BUsed / BTotal
  51. BFreeDecimal = BFree / BTotal
  52. BUsedPercent = BUsedDecimal * 100
  53. BFreePercent = BFreeDecimal * 100
  54. UsedOutput = math.floor(BUsedPercent)----Rounds
  55. --------------------End Variables---------------------------------
  56. mon.setBackgroundColor(colors.white)
  57. mon.clear()
  58. Draw_Line(1, 1, monX)
  59. Draw_Line(1, monY, monX)
  60. mon.setTextColor(colors.black)
  61. mon.setCursorPos(monX/2-4.5, 1)
  62. mon.write("ME Status")
  63. mon.setBackgroundColor(colors.white)
  64. mon.setCursorPos(1,3)
  65. mon.write("Storage Used: "..BUsed.."/"..BTotal.."("..UsedOutput.."%)")
  66. mon.setCursorPos(1,4)
  67. mon.write("Energy Stored: "..EnergyFinal.." AE")
  68. sleep(1)
  69. end
  70. -------Please report bugs, and feel free to suggest things.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement