Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- rednet.open("back") -- Set Modem poition
- mon = peripheral.wrap("top") --set Monitor Position
- mon.setBackgroundColor(colors.black)
- temp = 1
- reactor = "Querying"
- maxHeat = 1
- output = "Querying"
- timeLeft = "Querying"
- tempPercent = "Querying"
- adjustTemp = 5000
- x,y = mon.getSize()
- rednet.broadcast("ping")
- reactorCom = 148 --enter reactor computer ID
- maxStorageL = "1"
- energyL = "1"
- nir = 147 -- enter Nuclear information reader ID
- function display()
- mon.setTextColor(colours.black)
- if reactor == "false" then
- mon.setBackgroundColor(colors.green)
- rectr = "OFF"
- elseif reactor == "true" then
- mon.setBackgroundColor(colors.lime)
- rectr = "ON"
- else
- rectr = "QRY"
- mon.setBackgroundColor(colors.gray)
- end
- p = 1
- for i = 1,3 do
- mon.setCursorPos(x-5, p)
- mon.write(" ")
- p = p + 1
- end
- p = 0
- mon.setCursorPos(x-4, 2)
- mon.write(rectr)
- mon.setBackgroundColor(colours.black)
- mon.setTextColor(colors.lime)
- mon.setCursorPos(x/3+1, y-2)
- mon.write("Reactor Temp: "..tempPercent.."%")
- mon.setCursorPos(1, y-1)
- mon.write("0%")
- mon.setCursorPos(x/2, y-1)
- mon.write("50%")
- mon.setCursorPos(x-3, y-1)
- mon.write("100%")
- if tempPercent == "Querying" --[[or tempPercent == 0 ]] then
- mon.setCursorPos(1, y)
- mon.write("Temprature Unknown... Querying")
- elseif tempPercent/2 < 1 then
- mon.setCursorPos(1, y)
- mon.setBackgroundColor(colors.lime)
- mon.write(" ")
- mon.setBackgroundColor(colors.black)
- else
- for i = 1, tempPercent, 2 do
- p = p + 1
- mon.setCursorPos(p,y)
- if p < x/4 then
- mon.setBackgroundColor(colors.lime)
- mon.write(" ")
- mon.setBackgroundColor(colors.black)
- elseif p < x/2 then
- mon.setBackgroundColor(colors.green)
- mon.write(" ")
- mon.setBackgroundColor(colors.black)
- elseif p < x/4*3 then
- mon.setBackgroundColor(colors.orange)
- mon.write(" ")
- mon.setBackgroundColor(colors.black)
- elseif p <= x then
- mon.setBackgroundColor(colors.red)
- mon.write(" ")
- mon.setBackgroundColor(colors.black)
- end
- end
- p = 0
- end
- end
- local result
- result = fs.exists("shutTemp")
- if result == true then
- file = io.open("shutTemp", "r")
- shutTemp = file:read()
- file:close()
- elseif result == false then
- shutTemp = 1000
- end
- local result
- result = fs.exists("rctrStatus")
- if result == true then
- file = io.open("rctrStatus", "r")
- reactor = file:read()
- file:close()
- if reactor == "true" then
- rednet.send(reactorCom, "on")
- elseif reactor == "false" then
- rednet.send(reactorCom, "off")
- end
- elseif result == false then
- rednet.send(reactorCom, "off")
- end
- while true do
- display()
- event, param1, param2, param3 = os.pullEvent()
- if event == "rednet_message" then
- if param2 == "heat" then
- rednet.send(nir, "ping")
- a,b = rednet.receive(.5)
- temp = b
- elseif param2 == "reactorPoweredB" then
- rednet.send(nir, "ping")
- a,b = rednet.receive(.5)
- reactor = tostring(b)
- file = fs.open("rctrStatus", "w")
- file.write(b)
- file:close()
- elseif param2 == "maxHeat" then
- rednet.send(nir, "ping")
- a,b = rednet.receive(.5)
- maxHeat = b
- elseif param2 == "output" then
- rednet.send(nir, "ping")
- a,b = rednet.receive(.5)
- output = b
- elseif param2 == "timeLeft" then
- rednet.send(nir, "ping")
- a,b = rednet.receive(.5)
- timeLeft = b --*0.00277778
- elseif param2 == "energyL" then
- rednet.send(nir, "ping")
- a,b = rednet.receive(.5)
- energyL = b
- energyL = tonumber(energyL)
- if energyL > 100000000 then
- energyL = 100000000
- end
- elseif param2 == "maxStorageL" then
- rednet.send(nir, "ping")
- a,b = rednet.receive(.5)
- maxStorageL = b
- elseif param2 == "isSteam" then
- rednet.send(nir, "ping")
- a,b = rednet.receive(.5)
- isSteam = b
- end
- mon.clear()
- mon.setCursorPos(1,1)
- mon.setTextColor(colors.lime)
- if reactor == "true" then
- mon.write("Reactor: ")
- mon.setTextColor(colors.lime)
- mon.write("ON")
- mon.setTextColor(colors.lime)
- elseif reactor == "false" then
- mon.write("Reactor: ")
- mon.setTextColor(colors.green)
- mon.write("OFF")
- mon.setTextColor(colors.lime)
- else
- mon.write("Reactor: "..reactor)
- end
- mon.setCursorPos(1,3)
- tempPercent = temp / maxHeat
- tempPercent = tempPercent*100
- tempPercent = math.floor(tempPercent)
- mon.write("Reactor Temp: "..temp.."c")
- mon.setCursorPos(1,5)
- mon.write("EU Output: "..output)
- mon.setCursorPos(1,7)
- mon.write("Fuel: "..timeLeft)
- mon.setCursorPos(1,9)
- mon.write("Shutdown Temp: "..shutTemp)
- mon.setCursorPos(21, 1)
- mfsuE = tonumber(energyL)
- mfsuEL = tonumber(maxStorageL)
- if mfsuE == mfsuEL then
- mon.write("AESU: 100%")
- else
- mfsuPercent = mfsuE / mfsuEL
- mfsuPercent = mfsuPercent*100
- mfsuPercent = math.floor(mfsuPercent)
- mon.write("AESU: "..mfsuPercent.."%")
- end
- mon.setCursorPos(21, 3)
- mon.write("EU: "..mfsuE)
- elseif event == "monitor_touch" then
- if param2 > x-6 and param3 < 4 then
- if reactor == "false" then
- rednet.send(reactorCom, "on")
- elseif reactor == "true" then
- rednet.send(reactorCom, "off")
- end
- j,k = rednet.receive()
- if j == reactorCom and k == "false" then
- for i = 1,4 do
- mon.setBackgroundColor(colors.red)
- mon.clear()
- mon.setTextScale(4)
- mon.setTextColor(colors.black)
- mon.setCursorPos(1, 2)
- mon.write("OVERHEATING!")
- os.sleep(.5)
- mon.clear()
- mon.setTextColor(colors.red)
- mon.setBackgroundColor(colors.black)
- mon.setCursorPos(1, 2)
- mon.write("OVERHEATING!")
- os.sleep(.5)
- end
- end
- mon.setTextScale(1)
- mon.setBackgroundColor(colors.black)
- mon.setTextColor(colors.lime)
- rednet.broadcast("ping")
- elseif param3 == y then --and param2 * 2 * 100 < 7500 then
- adjustTemp = param2 * 2 * 100
- mon.setCursorPos(param2, param3)
- mon.setBackgroundColor(1)
- mon.write(" ")
- mon.setBackgroundColor(colors.black)
- rednet.send(reactorCom, "maxTemp")
- id, message = rednet.receive()
- if id == reactorCom then
- adjustTemp = tostring(adjustTemp)
- rednet.send(reactorCom, adjustTemp)
- id, message = rednet.receive()
- if message == "true" and id == reactorCom then
- shutTemp = adjustTemp
- file = fs.open("shutTemp", "w")
- file.write(shutTemp)
- file:close()
- elseif message == "false" and id == reactorCom then
- mon.setCursorPos(1,y)
- for i = 1,x do
- mon.write(" ")
- end
- mon.setCursorPos(1,y)
- mon.write("Max Temp Failed To Update!")
- end
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement