Advertisement
Guest User

Untitled

a guest
Jan 21st, 2020
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.44 KB | None | 0 0
  1. local meControllerSide = 'top'
  2. local meInterfaceSide = 'back'
  3.  
  4.  
  5. -- Install the F library if not present.
  6. if fs.exists('lib/f') == false then
  7. fs.makeDir("lib") lib = http.get("https://raw.githubusercontent.com/acidjazz/drmon/master/lib/f.lua") libFile = lib.readAll() local file1 = fs.open("lib/f", "w") file1.write(libFile) file1.close()
  8. end
  9.  
  10. os.loadAPI("lib/f")
  11.  
  12. --monitor
  13. local mon, monitor, monX, monY
  14. --peripherals
  15. local meController = peripheral.wrap(meControllerSide)
  16. local meInterface = peripheral.wrap(meInterfaceSide)
  17.  
  18. --vars
  19. params = {meController = meController, meInterface = meInterface}
  20.  
  21.  
  22. if meInterface == null then
  23. error("No valid ME Interface was found on " .. meControllerSide .. " of computer.")
  24. end
  25.  
  26. if meController == null then
  27. error("No valid ME Controller was found on ".. meInterfaceSide .." of computer. ")
  28. end
  29.  
  30. if monitor == null then
  31. error("No valid monitor was found")
  32. end
  33.  
  34. monitor.setTextScale(0.99)
  35.  
  36. monX, monY = monitor.getSize()
  37. mon = {}
  38. mon.monitor,mon.X, mon.Y = monitor, monX, monY
  39.  
  40.  
  41. function showTabMenu(mon, currentTab)
  42. local y = 0
  43. local tabs = {Monitor=1,Details=11,Edit=21}
  44. for k,v in pairs(tabs) do
  45. if k == currentTab then
  46. f.draw_text(mon, v, y, '[' .. k .. ']', colors.white, colors.purple)
  47. else
  48. f.draw_text(mon, v, y, '[' .. k .. ']', colors.white, colors.gray)
  49. end
  50. end
  51. end
  52.  
  53. function switchToTab(mon, tab, params)
  54. --erase screen, go to the main tab.
  55. f.clear(mon)
  56. showTabMenu(mon, tab);
  57.  
  58.  
  59. end
  60.  
  61. function monitorTab(mon, params)
  62. print('Monitor general status')
  63. print ('Busy CPUs: ' .. getBusyCPUs(params.meController);)
  64. print ('Total CPUs: ' .. #params.meController.getCraftingCPUs())
  65. --[[
  66.  
  67. [Monitor] [Details] [Edit]
  68. Monitor general crafting.
  69.  
  70.  
  71. Num total crafting jobs: 7
  72. Num computer jobs: 6
  73.  
  74. Crafting requested:
  75. 64k ME storage
  76. Energetic Alloy
  77. and 4 others.
  78.  
  79.  
  80. ]]--
  81.  
  82. end
  83.  
  84. function getBusyCPUs(meController)
  85. local cpus = meController.getCraftingCPUs()
  86. local busy = 0;
  87. for cpu in ipairs(cpus) do
  88. if cpu.busy == true then
  89. busy++
  90. end
  91. end
  92. return busy
  93. end
  94.  
  95. function drawButtons(y)
  96.  
  97. -- 2-4 = -1000, 6-9 = -10000, 10-12,8 = -100000
  98. -- 17-19 = +1000, 21-23 = +10000, 25-27 = +100000
  99.  
  100. f.draw_text(mon, 2, y, " < ", colors.white, colors.gray)
  101. f.draw_text(mon, 6, y, " <<", colors.white, colors.gray)
  102. f.draw_text(mon, 10, y, "<<<", colors.white, colors.gray)
  103.  
  104. f.draw_text(mon, 17, y, ">>>", colors.white, colors.gray)
  105. f.draw_text(mon, 21, y, ">> ", colors.white, colors.gray)
  106. f.draw_text(mon, 25, y, " > ", colors.white, colors.gray)
  107. end
  108.  
  109.  
  110.  
  111.  
  112.  
  113. --Program actually starts here.
  114.  
  115. switchToTab(mon, 'Monitor', {})
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123. --[[
  124. [Monitor] [Details] [Edit]
  125. Monitor general crafting.
  126.  
  127.  
  128. Num total crafting jobs: 7
  129. Num computer jobs: 6
  130.  
  131. Crafting requested:
  132. 64k ME storage
  133. Energetic Alloy
  134. and 4 others.
  135.  
  136.  
  137. --============================
  138.  
  139. [Monitor] [Details] [Edit]
  140. Detailed Crafting breakdown
  141.  
  142. Crafting Requested (Have / Want):
  143. 64k ME storage 5 / 64
  144. Energetic Alloy 64 / 256
  145. Steel Ingot 60 / 64
  146. ...
  147. ...
  148.  
  149. --============================
  150. [Monitor] [Details] [Edit]
  151. Edit preferred stock levels.
  152.  
  153.  
  154. Recipe:
  155. 64k ME Storage
  156. Have: 5
  157. Want: 0
  158. Less - More
  159. <<< << < > >> >>>
  160. [Prev] [Next]
  161.  
  162. ]]--
  163.  
  164.  
  165. -- What if there are no crafting CPUs free?
  166. -- What if there are not enough materials?
  167. -- What if the job is already running?
  168. -- What if the ME system runs out of power?
  169. -- What if
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement