Advertisement
Noobular

Factory Overview

Jul 18th, 2015
311
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.19 KB | None | 0 0
  1. term.clear()
  2. term.setCursorPos(1,1)
  3. ------------------------------------------------------------------------------------
  4. local m = peripheral.find("monitor")
  5. local r = {peripheral.find("BigReactors-Reactor")}
  6. local h = {peripheral.find("harvester")}
  7. local g = {peripheral.find("grinder")}
  8. local ra = {peripheral.find("rancher")}
  9. ------------------------------------------------------------------------------------
  10. local r2 = peripheral.find("BigReactors-Reactor")
  11. local h2 = peripheral.find("harvester")
  12. local g2 = peripheral.find("grinder")
  13. local ra2 = peripheral.find("rancher")
  14. ------------------------------------------------------------------------------------
  15. Long = " "
  16. ------------------------------------------------------------------------------------
  17. function MachineBuilder(Name,BlockName,Letter,Letter2,Mod)
  18. local Letter = {peripheral.find(BlockName)}
  19. local Letter2 = peripheral.find(BlockName)
  20. ListMachine(Name,Letter,Mod)
  21. end
  22.  
  23. function Header()
  24. m.setTextScale(1)
  25. m.setCursorPos(1,1)
  26. m.setBackgroundColor(colors.gray)
  27. m.write("[Factory Overview]")
  28. m.setCursorPos(1,2)
  29. m.write("-------------------")
  30. end
  31.  
  32. function Running()
  33. m.setBackgroundColor(colors.blue)
  34. m.setCursorPos(1,YPos)
  35. m.write(Long)
  36. m.setCursorPos(15,YPos)
  37. m.write("[ON]")
  38. end
  39.  
  40. function NotRunning()
  41. m.setBackgroundColor(colors.red)
  42. m.setCursorPos(1,YPos)
  43. m.write(Long)
  44. m.setCursorPos(14,YPos)
  45. m.write("[OFF]")
  46. end
  47.  
  48. function NotSureRunning()
  49. m.setBackgroundColor(colors.orange)
  50. m.setCursorPos(1,YPos)
  51. m.write(Long)
  52. m.setCursorPos(14,YPos)
  53. m.write("[IDK]")
  54. end
  55.  
  56. function ListMachine(Name,Peripherals,comparison)
  57. for i = 1, #Peripherals do
  58. m.setBackgroundColor(colors.orange)
  59.  
  60. if comparison == nil then
  61. NotSureRunning()
  62. elseif comparison == "Reactor" then --- Big Reactors Reactor
  63. if Peripherals[i].getActive() then
  64. Running()
  65. else
  66. NotRunning()
  67. end
  68.  
  69. elseif comparison == "MineFactory" then --- Minefactory Reloaded Machines
  70. if Peripherals[i].getEnergyStored() == nil then
  71. elseif Peripherals[i].getEnergyStored() > 0 then
  72. Running()
  73. else
  74. NotRunning()
  75. end
  76. --- space for new type of machine
  77.  
  78. end
  79.  
  80. m.setCursorPos(1,YPos)
  81. m.write(Name.." #"..i)
  82. YPos = YPos + 1
  83. end
  84. end
  85.  
  86. function Connected(name,letter)
  87. if letter then
  88. term.setTextColor(colors.lime)
  89. print(name.."[s] Connected!")
  90. print()
  91. else
  92. term.setTextColor(colors.red)
  93. print("No "..name.. "[s] Connected!")
  94. print()
  95. end
  96. end
  97.  
  98. function Connected2()
  99. Connected("Monitor",m)
  100. Connected("Reactor",r2)
  101. Connected("Harvester",h2)
  102. Connected("Grinder",g2)
  103. Connected("Rancher",ra2)
  104. m.setBackgroundColor(colors.black)
  105. end
  106.  
  107. function FindPeripherals()
  108. m = peripheral.find("monitor")
  109. r = {peripheral.find("BigReactors-Reactor")}
  110. h = {peripheral.find("harvester")}
  111. g = {peripheral.find("grinder")}
  112. r = {peripheral.find("rancher")}
  113. end
  114.  
  115.  
  116. function RunThrough()
  117. Header()
  118. YPos = 3
  119. ListMachine("Reactor",r,"Reactor")
  120. ListMachine("Harvester",h,"MineFactory")
  121. ListMachine("Grinder",g,"MineFactory")
  122. ListMachine("Rancher",ra,"MineFactory")
  123. end
  124.  
  125. CONNECTED2 = 1
  126. --------- LOOP -----------
  127. local OSTimer = os.startTimer(0)
  128.  
  129. m.clear()
  130. while true do
  131. m.setBackgroundColor(colors.black)
  132. local Event, EventType = os.pullEvent()
  133. if Event == "peripheral_detach" then
  134. term.setTextColor(colors.orange)
  135. print(EventType.." has been detached.")
  136. print("Screen has been reset")
  137. FindPeripherals()
  138. m.clear()
  139. elseif Event == "peripheral" then
  140. term.setTextColor(colors.blue)
  141. print(EventType.." has been attached.")
  142. print("Screen has been reset")
  143. FindPeripherals()
  144. m.clear()
  145. elseif Event == "timer" then
  146. OSTimer = os.startTimer(1)
  147. end
  148.  
  149. if CONNECTED2 == 1 then
  150. Connected2()
  151. CONNECTED2 = 0
  152. end
  153. RunThrough()
  154. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement