Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- DebiReactorDisplay - (c) monster010
- ----------------------------------
- ----- DONT CHANGE UNDER THIS -----
- ----------------------------------
- os.loadAPI("/debireactordisplay/api/config")
- os.loadAPI("/debireactordisplay/api/monster010")
- os.loadAPI("/debireactordisplay/api/bars")
- os.loadAPI("/debireactordisplay/api/lbl")
- local software = "DebiReactorDisplay"
- local monitor
- local reactor
- local cfg = {}
- local labels = {
- lbl1 = {text = "Rodstatus", x = 16, y = 3},
- lbl2 = {text = "Casing", x = 2, y = 25},
- lbl3 = {text = "Core", x = 10, y = 25},
- }
- local rlabels = {
- rod1 = {id = 0, text = "Rod 1: ", x = 27, y = 6, stxt = 0},
- rod2 = {id = 1, text = "Rod 2: ", x = 27, y = 8, stxt = 0},
- rod3 = {id = 2, text = "Rod 3: ", x = 27, y = 10, stxt = 0},
- rod4 = {id = 3, text = "Rod 4: ", x = 27, y = 12, stxt = 0},
- rod5 = {id = 4, text = "Rod 5: ", x = 27, y = 14, stxt = 0},
- }
- local barTemp = {
- temp1 = {what = "temp", typ = "ver", maxVal = 3000, curVal = 3000, x = 4, y = 3, w = 0, h = 21, clfill = colors.gray, clempty = colors.lightBlue},
- temp2 = {what = "temp", typ = "ver", maxVal = 3000, curVal = 3000, x = 11, y = 3, w = 0, h = 21, clfill = colors.gray, clempty = colors.lightBlue},
- }
- local barRods = {
- rod1 = {id = 0, what = "rod", typ = "ver", maxVal = 100, curVal = 100, x = 16, y = 5, w = 0, h = 10, clfill = colors.gray, clempty = colors.yellow},
- rod2 = {id = 1, what = "rod", typ = "ver", maxVal = 100, curVal = 100, x = 18, y = 5, w = 0, h = 10, clfill = colors.gray, clempty = colors.yellow},
- rod3 = {id = 2, what = "rod", typ = "ver", maxVal = 100, curVal = 100, x = 20, y = 5, w = 0, h = 10, clfill = colors.gray, clempty = colors.yellow},
- rod4 = {id = 3, what = "rod", typ = "ver", maxVal = 100, curVal = 100, x = 22, y = 5, w = 0, h = 10, clfill = colors.gray, clempty = colors.yellow},
- rod5 = {id = 4, what = "rod", typ = "ver", maxVal = 100, curVal = 100, x = 24, y = 5, w = 0, h = 10, clfill = colors.gray, clempty = colors.yellow},
- }
- function connect_rc()
- reactor = peripheral.wrap("BigReactors-Reactor_0")
- end
- function addBars()
- for name, data in pairs(barTemp) do
- bars.add(name, data["typ"], data["maxVal"], data["curVal"], data["x"], data["y"], data["w"], data["h"], data["clfill"], data["clempty"])
- end
- for name, data in pairs(barRods) do
- bars.add(name, data["typ"], data["maxVal"], data["curVal"], data["x"], data["y"], data["w"], data["h"], data["clfill"], data["clempty"])
- end
- bars.screen()
- end
- function addLabels()
- for name, data in pairs(labels) do
- lbl.add(name, data["text"], data["x"], data["y"])
- end
- for name, data in pairs(rlabels) do
- lbl.add(name, data["text"], data["x"], data["y"], data["stxt"])
- end
- lbl.screen()
- end
- function updateRodLabels()
- local mytimer = os.startTimer(1)
- while true do
- local event, args = os.pullEvent()
- if event == "timer" and args == mytimer then
- for name, data in pairs(rlabels) do
- local num = monster010.round(100 - reactor.getControlRodLevel(data["id"]))
- if string.len(num) == 3 then
- num = num
- elseif string.len(num) == 2 then
- num = " "..num
- elseif string.len(num) == 1 then
- num = " "..num
- end
- lbl.set(name, "stxt", num.."%")
- end
- end
- lbl.screen()
- break
- end
- end
- function updateReactorState()
- local mytimer = os.startTimer(1)
- while true do
- local event, args = os.pullEvent()
- if event == "timer" and args == mytimer then
- for name, data in pairs(barTemp) do
- if reactor.getActive() then
- bars.set(name, "clfill", colors.gray)
- bars.set(name, "clempty", colors.lightBlue)
- else
- bars.set(name, "clfill", colors.red)
- bars.set(name, "clempty", colors.red)
- end
- end
- for name, data in pairs(barRods) do
- if reactor.getActive() then
- bars.set(name, "clfill", colors.gray)
- bars.set(name, "clempty", colors.yellow)
- else
- bars.set(name, "clfill", colors.red)
- bars.set(name, "clempty", colors.red)
- end
- end
- bars.screen()
- break
- end
- end
- end
- function updateTempBars()
- local mytimer = os.startTimer(1)
- while true do
- local event, args = os.pullEvent()
- if event == "timer" and args == mytimer then
- bars.set("temp1", "cur", monster010.round(3000 - reactor.getCasingTemperature()))
- bars.set("temp2", "cur", monster010.round(3000 - reactor.getFuelTemperature()))
- bars.screen()
- break
- end
- end
- end
- function updateRodBars()
- local mytimer = os.startTimer(1)
- while true do
- local event, args = os.pullEvent()
- if event == "timer" and args == mytimer then
- for name, data in pairs(barRods) do
- if data["what"] == "rod" then
- bars.set(name, "cur", reactor.getControlRodLevel(data["id"]) + 1)
- end
- end
- bars.screen()
- break
- end
- end
- end
- config.load("/debireactordisplay/cfg")
- cfg = config.getConfig()
- monster010.construct(cfg["monSide"], software)
- monster010.startUp()
- monster010.heading(software)
- monitor = monster010.getMonitor()
- bars.construct(monitor)
- lbl.construct(monitor)
- connect_rc()
- addBars()
- addLabels()
- monster010.startUpDone()
- while true do
- updateReactorState()
- updateTempBars()
- updateRodBars()
- updateRodLabels()
- end
Advertisement
Add Comment
Please, Sign In to add comment