Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- otherComputerId = 15 -- Change this number to the other computers' ID. You can get the ID by typing "id" into the terminal.
- monitor = peripheral.find("monitor")
- local modemCount = 0
- for i,v in pairs(redstone.getSides()) do
- if peripheral.getType(v) == "modem" then
- rednet.open(v)
- modemCount = modemCount + 1
- end
- end
- if modemCount < 1 then
- print("You need a wireless/ender modem.")
- return
- end
- math.randomseed(os.time())
- local temp
- local shield
- local sat
- local fuel
- local statusText
- local info
- local chaos = false
- mX,mY = monitor.getSize()
- local coreUpdateDelay = 30
- size = {9,13,15,17,17,19,19,19,17,17,15,13,9}
- coreShieldLayout = {}
- function drawProgressBar(monitor, barColor, backgroundColor, progress, width)
- c = math.floor(progress*width)
- cR = width-c
- monitor.blit((" "):rep(c), (barColor):rep(c), (barColor):rep(c))
- monitor.blit((" "):rep(cR), (backgroundColor):rep(cR), (backgroundColor):rep(cR))
- end
- function mainStuff()
- while not chaos do
- if info then
- temp = info.temperature
- shield = math.ceil(info.fieldStrength / info.maxFieldStrength * 10000) / 100
- sat = math.ceil(info.energySaturation / info.maxEnergySaturation * 10000) / 100
- fuel = math.ceil(info.fuelConversion / info.maxFuelConversion * 10000) / 100
- monitor.clear()
- monitor.setCursorPos(1, 1)
- monitor.setTextColor(colors.white)
- monitor.write("Core Temperature: " .. temp .. "°C")
- monitor.setCursorPos(1, 2)
- drawProgressBar(monitor, "1", "8", temp/10000, 49)
- monitor.setCursorPos(1, 3)
- monitor.write("Containment Field Strength: " .. shield .. "%")
- monitor.setCursorPos(1, 4)
- drawProgressBar(monitor, "b", "8", shield/100, 49)
- monitor.setCursorPos(1, 5)
- monitor.write("Energy Saturation: " .. sat .. "%")
- monitor.setCursorPos(1, 6)
- drawProgressBar(monitor, "5", "8", sat/100, 49)
- monitor.setCursorPos(1, 7)
- monitor.write("Fuel Conversion Level: " .. fuel .. "%")
- monitor.setCursorPos(1, 8)
- if info.status == "cold" then statusText = "Inactive" end
- if info.status == "warming_up" then statusText = "Charging" end
- if info.status == "running" then statusText = "Active" end
- if info.status == "stopping" then statusText = "Stopping" end
- if info.status == "cooling" then statusText = "Cooling" end
- if info.status == "beyond_hope" then
- statusText = "EXPLOSION IMMINENT!"
- chaos = true
- end
- monitor.write("Status: " .. statusText)
- monitor.setCursorPos(1, 9)
- monitor.write("Containment Field Drain Rate: " .. info.fieldDrainRate .. " RF/t")
- monitor.setCursorPos(1, 10)
- monitor.write("Fuel Conversion Rate: " .. info.fuelConversionRate .. " nb/t")
- if info.maxFuelConversion ~= 10368 then
- monitor.setTextColor(colors.red)
- monitor.setCursorPos(1, 12)
- monitor.write("Please use 8 awakened")
- monitor.setCursorPos(1, 13)
- monitor.write("draconium blocks!")
- end
- if (info.status == "cold" or info.status == "cooling") and info.maxFuelConversion == 10368 then
- monitor.setCursorPos(2, 12)
- monitor.blit("Charge Reactor", "00000000000000", "77777777777777")
- end
- if (info.status == "warming_up" or info.status == "stopping") and info.temperature >= 2000 then
- monitor.setCursorPos(2, 12)
- monitor.blit("Activate Reactor", "0000000000000000", "7777777777777777")
- end
- if info.status == "warming_up" or info.status == "running" then
- monitor.setCursorPos(2, 14)
- monitor.blit("Stop Reactor", "000000000000", "777777777777")
- end
- coreUpdateDelay = coreUpdateDelay + 1
- if coreUpdateDelay >= 30 then
- coreShieldLayout = {}
- for i = 1,#size do
- for j = 1,size[i] do
- table.insert(coreShieldLayout, math.random(1,70))
- end
- end
- coreUpdateDelay = 0
- end
- drawCore()
- else
- monitor.clear()
- monitor.setCursorPos(1, 1)
- monitor.write("Reactor Computer is not connected!")
- end
- sleep(0.1)
- end
- end
- function drawCore()
- local temperature = temp
- local fieldStrength = shield - 10
- local color1
- if temperature < 6000 then color1 = "e" end
- if temperature >= 6000 and temperature < 9000 then color1 = "1" end
- if temperature >= 9000 then color1 = "4" end
- local color2
- if fieldStrength < 85 then color2 = "b" else color2 = "9" end
- layoutIndex = 1
- for i = 1,#size do
- monitor.setCursorPos(math.floor(mX-10-size[i]/2),i+11)
- if fieldStrength > 50 then fieldStrength = 50 end
- for i2 = 1,size[i] do
- if coreShieldLayout[layoutIndex] <= fieldStrength then
- monitor.blit(" ",color2,color2)
- else
- monitor.blit(" ",color1,color1)
- end
- layoutIndex = layoutIndex + 1
- end
- end
- end
- function redNetReceive()
- while true do
- id, msg = rednet.receive()
- if id == otherComputerId then
- info = msg
- end
- sleep(0)
- end
- end
- function buttons()
- while not chaos do
- event, side, x, y = os.pullEvent("monitor_touch")
- if x >= 2 and x < 16 and y == 12 and (info.status == "cold" or info.status == "cooling") then
- rednet.send(otherComputerId, "chargeReactor")
- end
- if x >= 2 and x < 18 and y == 12 and (info.status == "warming_up" or info.status == "stopping") and info.temperature >= 2000 then
- rednet.send(otherComputerId, "activateReactor")
- end
- if x >= 2 and x < 14 and y == 14 and (info.status == "warming_up" or info.status == "running") then
- rednet.send(otherComputerId, "stopReactor")
- end
- sleep(0)
- end
- end
- function chaosMessage()
- while true do
- if chaos then
- text1 = "WARNING!"
- text2 = "Explosion imminent!"
- text3 = "Evacuate now!"
- monitor.setTextColor(colors.red)
- monitor.setTextScale(2)
- yPos = 5
- monitor.setCursorPos(math.ceil(mX/2 - text1:len()/2+1),yPos)
- monitor.write(text1)
- monitor.setCursorPos(math.ceil(mX/2 - text2:len()/2+1),yPos+2)
- monitor.write(text2)
- monitor.setCursorPos(math.ceil(mX/2 - text3:len()/2+1),yPos+3)
- monitor.write(text3)
- sleep(1)
- monitor.clear()
- sleep(0.75)
- end
- sleep(1)
- end
- end
- parallel.waitForAll(mainStuff, redNetReceive, buttons, chaosMessage)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement