Advertisement
XSiggeManx

new core [gui]

May 15th, 2022 (edited)
601
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.12 KB | None | 0 0
  1. monitor = peripheral.find("monitor")
  2.  
  3. local modemCount = 0
  4. for i,v in pairs(redstone.getSides()) do
  5. if peripheral.getType(v) == "modem" then
  6. rednet.open(v)
  7. modemCount = modemCount + 1
  8. end
  9. end
  10.  
  11. if modemCount < 1 then
  12. print("You need a wireless/ender modem.")
  13. return
  14. end
  15. math.randomseed(os.time())
  16.  
  17. local temp
  18. local shield
  19. local sat
  20. local fuel
  21. local statusText
  22.  
  23. local info
  24. local chaos = false
  25.  
  26. mX,mY = monitor.getSize()
  27. local coreUpdateDelay = 30
  28. size = {9,13,15,17,17,19,19,19,17,17,15,13,9}
  29. coreShieldLayout = {}
  30.  
  31. function drawProgressBar(monitor, barColor, backgroundColor, progress, width)
  32. c = math.floor(progress*width)
  33. cR = width-c
  34. monitor.blit((" "):rep(c), (barColor):rep(c), (barColor):rep(c))
  35. monitor.blit((" "):rep(cR), (backgroundColor):rep(cR), (backgroundColor):rep(cR))
  36. end
  37.  
  38. function mainStuff()
  39. while not chaos do
  40. if info then
  41. temp = info.temperature
  42. shield = math.ceil(info.fieldStrength / info.maxFieldStrength * 10000) / 100
  43. sat = math.ceil(info.energySaturation / info.maxEnergySaturation * 10000) / 100
  44. fuel = math.ceil(info.fuelConversion / info.maxFuelConversion * 10000) / 100
  45. monitor.clear()
  46. monitor.setCursorPos(1, 1)
  47. monitor.setTextColor(colors.white)
  48. monitor.write("Core Temperature: " .. temp .. "°C")
  49. monitor.setCursorPos(1, 2)
  50. drawProgressBar(monitor, "1", "8", temp/10000, 49)
  51. monitor.setCursorPos(1, 3)
  52. monitor.write("Containment Field Strength: " .. shield .. "%")
  53. monitor.setCursorPos(1, 4)
  54. drawProgressBar(monitor, "b", "8", shield/100, 49)
  55. monitor.setCursorPos(1, 5)
  56. monitor.write("Energy Saturation: " .. sat .. "%")
  57. monitor.setCursorPos(1, 6)
  58. drawProgressBar(monitor, "5", "8", sat/100, 49)
  59. monitor.setCursorPos(1, 7)
  60. monitor.write("Fuel Conversion Level: " .. fuel .. "%")
  61. monitor.setCursorPos(1, 8)
  62. if info.status == "cold" then statusText = "Inactive" end
  63. if info.status == "warming_up" then statusText = "Charging" end
  64. if info.status == "running" then statusText = "Active" end
  65. if info.status == "stopping" then statusText = "Stopping" end
  66. if info.status == "cooling" then statusText = "Cooling" end
  67. if info.status == "beyond_hope" then
  68. statusText = "EXPLOSION IMMINENT!"
  69. chaos = true
  70. end
  71. monitor.write("Status: " .. statusText)
  72. monitor.setCursorPos(1, 9)
  73. monitor.write("Containment Field Drain Rate: " .. info.fieldDrainRate .. " RF/t")
  74. monitor.setCursorPos(1, 10)
  75. monitor.write("Fuel Conversion Rate: " .. info.fuelConversionRate .. " nb/t")
  76.  
  77. coreUpdateDelay = coreUpdateDelay + 1
  78. if coreUpdateDelay >= 30 then
  79. coreShieldLayout = {}
  80. for i = 1,#size do
  81. for j = 1,size[i] do
  82. table.insert(coreShieldLayout, math.random(1,70))
  83. end
  84. end
  85. coreUpdateDelay = 0
  86. end
  87.  
  88. drawCore()
  89. else
  90. monitor.clear()
  91. monitor.setCursorPos(1, 1)
  92. monitor.write("Reactor Computer is not connected!")
  93. end
  94. sleep(0.1)
  95. end
  96. end
  97.  
  98. function drawCore()
  99. local temperature = temp
  100. local fieldStrength = shield - 10
  101. local color1
  102. if temperature < 6000 then color1 = "e" end
  103. if temperature >= 6000 and temperature < 9000 then color1 = "1" end
  104. if temperature >= 9000 then color1 = "4" end
  105. local color2
  106. if fieldStrength < 85 then color2 = "b" else color2 = "9" end
  107. layoutIndex = 1
  108. for i = 1,#size do
  109. monitor.setCursorPos(math.floor(mX-10-size[i]/2),i+11)
  110. if fieldStrength > 50 then fieldStrength = 50 end
  111. for i2 = 1,size[i] do
  112. if coreShieldLayout[layoutIndex] <= fieldStrength then
  113. monitor.blit(" ",color2,color2)
  114. else
  115. monitor.blit(" ",color1,color1)
  116. end
  117. layoutIndex = layoutIndex + 1
  118. end
  119. end
  120. end
  121.  
  122. function redNetReceive()
  123. while true do
  124. id, msg = rednet.receive()
  125. info = msg
  126. sleep(0)
  127. end
  128. end
  129.  
  130. function chaosMessage()
  131. while true do
  132. if chaos then
  133. text1 = "WARNING!"
  134. text2 = "Explosion imminent!"
  135. text3 = "Initiating Emergency Shutdown!"
  136. monitor.setTextColor(colors.red)
  137. monitor.setTextScale(2)
  138. yPos = 5
  139. monitor.setCursorPos(math.ceil(mX/2 - text1:len()/2+1),yPos)
  140. monitor.write(text1)
  141. monitor.setCursorPos(math.ceil(mX/2 - text2:len()/2+1),yPos+2)
  142. monitor.write(text2)
  143. monitor.setCursorPos(math.ceil(mX/2 - text3:len()/2+1),yPos+3)
  144. monitor.write(text3)
  145. sleep(1)
  146. monitor.clear()
  147. sleep(0.75)
  148. end
  149. sleep(1)
  150. end
  151. end
  152.  
  153. parallel.waitForAll(mainStuff, redNetReceive, chaosMessage)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement