Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- DebiTurbineDisplay - (c) monster010
- ----------------------------------
- ----- DONT CHANGE UNDER THIS -----
- ----------------------------------
- os.loadAPI("/debiturbinedisplay/api/config")
- os.loadAPI("/debiturbinedisplay/api/monster010")
- os.loadAPI("/debiturbinedisplay/api/bars")
- os.loadAPI("/debiturbinedisplay/api/lbl")
- local software = "DebiTurbineDisplay"
- local monitor
- local cfg = {}
- local tbs = {}
- local labels = {
- tb1 = {text = "TB 1", x = 2, y = 25},
- tb2 = {text = "TB 2", x = 8, y = 25},
- tb3 = {text = "TB 3", x = 14, y = 25},
- tb4 = {text = "TB 4", x = 20, y = 25},
- tb5 = {text = "TB 5", x = 26, y = 25},
- tb6 = {text = "TB 6", x = 32, y = 25},
- tb7 = {text = "TB 7", x = 38, y = 25},
- tb8 = {text = "TB 8", x = 44, y = 25},
- tb9 = {text = "TB 9", x = 50, y = 25},
- tb10 = {text = "TB 10", x = 56, y = 25}
- }
- local bar = {
- tb1sp = {tb = "tb1", what = "speed", typ = "ver", maxVal = 2000, curVal = 2000, x = 3, y = 3, w = 0, h = 21, clfill = colors.gray, clempty = colors.lime},
- tb2sp = {tb = "tb2", what = "speed", typ = "ver", maxVal = 2000, curVal = 2000, x = 9, y = 3, w = 0, h = 21, clfill = colors.gray, clempty = colors.lime},
- tb3sp = {tb = "tb3", what = "speed", typ = "ver", maxVal = 2000, curVal = 2000, x = 15, y = 3, w = 0, h = 21, clfill = colors.gray, clempty = colors.lime},
- tb4sp = {tb = "tb4", what = "speed", typ = "ver", maxVal = 2000, curVal = 2000, x = 21, y = 3, w = 0, h = 21, clfill = colors.gray, clempty = colors.lime},
- tb5sp = {tb = "tb5", what = "speed", typ = "ver", maxVal = 2000, curVal = 2000, x = 27, y = 3, w = 0, h = 21, clfill = colors.gray, clempty = colors.lime},
- tb6sp = {tb = "tb6", what = "speed", typ = "ver", maxVal = 2000, curVal = 2000, x = 33, y = 3, w = 0, h = 21, clfill = colors.gray, clempty = colors.lime},
- tb7sp = {tb = "tb7", what = "speed", typ = "ver", maxVal = 2000, curVal = 2000, x = 39, y = 3, w = 0, h = 21, clfill = colors.gray, clempty = colors.lime},
- tb8sp = {tb = "tb8", what = "speed", typ = "ver", maxVal = 2000, curVal = 2000, x = 45, y = 3, w = 0, h = 21, clfill = colors.gray, clempty = colors.lime},
- tb9sp = {tb = "tb9", what = "speed", typ = "ver", maxVal = 2000, curVal = 2000, x = 51, y = 3, w = 0, h = 21, clfill = colors.gray, clempty = colors.lime},
- tb10sp = {tb = "tb10", what = "speed", typ = "ver", maxVal = 2000, curVal = 2000, x = 57, y = 3, w = 0, h = 21, clfill = colors.gray, clempty = colors.lime},
- tb1en = {tb = "tb1", what = "energy", typ = "ver", maxVal = 25000, curVal = 25000, x = 5, y = 3, w = 0, h = 21, clfill = colors.gray, clempty = colors.yellow},
- tb2en = {tb = "tb2", what = "energy", typ = "ver", maxVal = 25000, curVal = 25000, x = 11, y = 3, w = 0, h = 21, clfill = colors.gray, clempty = colors.yellow},
- tb3en = {tb = "tb3", what = "energy", typ = "ver", maxVal = 25000, curVal = 25000, x = 17, y = 3, w = 0, h = 21, clfill = colors.gray, clempty = colors.yellow},
- tb4en = {tb = "tb4", what = "energy", typ = "ver", maxVal = 25000, curVal = 25000, x = 23, y = 3, w = 0, h = 21, clfill = colors.gray, clempty = colors.yellow},
- tb5en = {tb = "tb5", what = "energy", typ = "ver", maxVal = 25000, curVal = 25000, x = 29, y = 3, w = 0, h = 21, clfill = colors.gray, clempty = colors.yellow},
- tb6en = {tb = "tb6", what = "energy", typ = "ver", maxVal = 25000, curVal = 25000, x = 35, y = 3, w = 0, h = 21, clfill = colors.gray, clempty = colors.yellow},
- tb7en = {tb = "tb7", what = "energy", typ = "ver", maxVal = 25000, curVal = 25000, x = 41, y = 3, w = 0, h = 21, clfill = colors.gray, clempty = colors.yellow},
- tb8en = {tb = "tb8", what = "energy", typ = "ver", maxVal = 25000, curVal = 25000, x = 47, y = 3, w = 0, h = 21, clfill = colors.gray, clempty = colors.yellow},
- tb9en = {tb = "tb9", what = "energy", typ = "ver", maxVal = 25000, curVal = 25000, x = 53, y = 3, w = 0, h = 21, clfill = colors.gray, clempty = colors.yellow},
- tb10en = {tb = "tb10", what = "energy", typ = "ver", maxVal = 25000, curVal = 25000, x = 59, y = 3, w = 0, h = 21, clfill = colors.gray, clempty = colors.yellow},
- }
- function connect_tb()
- for name, data in pairs(tbs) do
- data["tb"] = peripheral.wrap(data["name"])
- end
- end
- function addBars()
- for name, data in pairs(bar) 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
- lbl.screen()
- end
- function updateTurbineState()
- for name, data in pairs(bar) do
- if tbs[data["tb"]]["tb"].getActive() then
- if data["what"] == "speed" then
- bars.set(name, "clfill", colors.gray)
- bars.set(name, "clempty", colors.lime)
- elseif data["what"] == "energy" then
- bars.set(name, "clfill", colors.gray)
- bars.set(name, "clempty", colors.yellow)
- end
- else
- bars.set(name, "clfill", colors.red)
- bars.set(name, "clempty", colors.red)
- end
- end
- end
- function updateSpeedBars()
- 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(bar) do
- if data["what"] == "speed" then
- bars.set(name, "cur", monster010.round(2000 - tbs[data["tb"]]["tb"].getRotorSpeed()))
- end
- end
- bars.screen()
- break
- end
- end
- end
- function updateEnergyBars()
- for name, data in pairs(bar) do
- if data["what"] == "energy" then
- bars.set(name, "cur", monster010.round(25000 - tbs[data["tb"]]["tb"].getEnergyProducedLastTick()))
- end
- end
- bars.screen()
- end
- function loadCFG()
- tbs = config.get("tbs")
- for name, data in pairs(tbs) do
- data["tb"] = {}
- end
- end
- config.load("/debiturbinedisplay/cfg")
- cfg = config.getConfig()
- monster010.construct(cfg["monSide"], software)
- monster010.startUp()
- monster010.heading(software)
- monitor = monster010.getMonitor()
- bars.construct(monitor)
- lbl.construct(monitor)
- loadCFG()
- connect_tb()
- addBars()
- addLabels()
- monster010.startUpDone()
- while true do
- updateTurbineState()
- updateSpeedBars()
- updateEnergyBars()
- end
Advertisement
Add Comment
Please, Sign In to add comment