Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- os.loadAPI("button")
- m = peripheral.find("monitor")
- r = peripheral.find("BigReactors-Reactor")
- local width, height = m.getSize()
- local menuType = "Reactor"
- local targetSpeed = 1840
- local timerCode
- local mode = "Manual"
- local RFProduction = 0
- local coreTemp = 0
- local reactorOnline = false
- local rodLevel = 0
- local OptFuelRodLevel = 0
- function manualMenu()
- m.setTextScale(1)
- button.clearTable()
- button.setTable("Manual", manualMode, "", 9, 25, 6, 6)
- button.setTable("Online", online, "", 3, 13, 8, 8)
- button.setTable("Offline", offline, "", 15, 25, 8, 8)
- button.setTable("0", setRods, 0, 11,14, 10, 10)
- button.setTable("10", setRods, 10, 5,8, 12, 12)
- button.setTable("20", setRods, 20, 11,14, 12, 12)
- button.setTable("30", setRods, 30, 17,20, 12, 12)
- button.setTable("40", setRods, 40, 5,8, 14, 14)
- button.setTable("50", setRods, 50, 11,14, 14, 14)
- button.setTable("60", setRods, 60, 17,20, 14, 14)
- button.setTable("70", setRods, 70, 5,8, 16, 16)
- button.setTable("80", setRods, 80, 11,14, 16, 16)
- button.setTable("90", setRods, 90, 17,20, 16, 16)
- button.setTable("+", rodPlus, "", 23, 25, 12, 12)
- button.setTable("-", rodMinus, "", 23, 25, 16, 16)
- button.screen()
- checkMode()
- reactorOnOff()
- end
- function reactorMenu()
- menuType = "Reactor"
- displayScreen()
- end
- function online()
- r.setActive(true)
- --button.flash("Online")
- end
- function offline()
- r.setActive(false)
- --button.flash("Offline")
- end
- function reactorOnOff()
- button.setButton("Online", r.getActive())
- button.setButton("Offline", not r.getActive())
- end
- function setRods(setLevel)
- print("Setting Rod Level: "..setLevel)
- button.flash(tostring(setLevel))
- r.setAllControlRodLevels(setLevel)
- fuelRodLevel()
- end
- function rodPlus()
- button.flash("+")
- r.setAllControlRodLevels(rodLevel+1)
- fuelRodLevel()
- end
- function rodMinus()
- button.flash("-")
- r.setAllControlRodLevels(rodLevel-1)
- fuelRodLevel()
- end
- function checkMode()
- button.toggleButton(mode)
- end
- function comma_value(amount)
- local formatted = amount
- local swap = false
- if formatted < 0 then
- formatted = formatted*-1
- swap = true
- end
- while true do
- formatted, k = string.gsub(formatted, "^(%d+)(%d%d%d)", '%1,%2')
- if k == 0 then
- break
- end
- end
- if swap then
- formatted = "-"..formatted
- end
- return formatted
- end
- function displayEn()
- m.clear()
- m.setTextScale(2)
- m.setCursorPos(width-25,2)
- m.write("RF Gen: ")
- m.setTextColor(colors.green)
- m.write(comma_value(math.floor(RFProduction)).."RF/t")
- m.setTextColor(colors.white)
- m.setTextScale(1)
- end
- function checkEn()
- RFProduction = r.getEnergyProducedLastTick()
- reactorOnline = r.getActive()
- end
- function fuelRodLevel()
- rodLevel = r.getControlRodLevel(0)
- --print(rodLevel)
- m.setCursorPos(width-6,5)
- m.write(tostring(rodLevel).."%")
- m.setBackgroundColor(colors.white)
- m.setCursorPos(width-8,6)
- m.write(" ")
- for i = 1,20 do
- m.setCursorPos(width-8,i+6)
- m.setBackgroundColor(colors.white)
- m.write(" ")
- m.setBackgroundColor(colors.yellow)
- m.write(" ")
- if rodLevel/10 >= i then
- m.setBackgroundColor(colors.red)
- else
- m.setBackgroundColor(colors.yellow)
- end
- m.write(" ")
- m.setBackgroundColor(colors.yellow)
- m.write(" ")
- m.setBackgroundColor(colors.white)
- m.write(" ")
- end
- m.setCursorPos(width-8,27)
- m.write(" ")
- m.setBackgroundColor(colors.black)
- end
- function getClick()
- local event, side, x, y = os.pullEvent("monitor_touch")
- button.checkxy(x,y)
- end
- function displayScreen()
- -- repeat
- checkEn()
- displayEn()
- if menuType == "Reactor" then
- fuelRodLevel()
- if mode == "Manual" then
- manualMenu()
- end
- end
- timerCode = os.startTimer(1)
- local event, side, x, y
- repeat
- event, side, x, y = os.pullEvent()
- print(event)
- if event == "timer" then
- print(timerCode..":"..side)
- if timerCode ~= side then
- print("Wrong Code")
- else
- print("Right Code")
- end
- end
- until event~= "timer" or timerCode == side
- if event == "monitor_touch" then
- print(x..":"..y)
- button.checkxy(x,y)
- end
- -- until event ~= "timer"
- end
- while true do
- displayScreen()
- end
Advertisement
Add Comment
Please, Sign In to add comment