Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Datei: gui.lua
- -- Ausgabe auf Monitor, Debug-Ausgabe optional im Terminal (CC: Tweaked), modularisiert
- local gui = {}
- local config = require("config")
- local monitor = peripheral.find and peripheral.find("monitor") or nil
- -- Hilfsfunktionen fĂźr Terminal
- local function termClear()
- term.clear()
- end
- local function termWriteAt(x, y, text)
- term.setCursorPos(x, y)
- print(text)
- end
- -- Hilfsfunktionen fĂźr Monitor
- local function monitorClear()
- if monitor then monitor.clear() end
- end
- local function monitorWriteAt(x, y, text)
- if monitor then
- monitor.setCursorPos(x, y)
- monitor.write(text)
- end
- end
- function gui.clear()
- if config.debug == 1 then termClear() end
- monitorClear()
- end
- function gui.drawCenteredText(y, text)
- if config.debug == 1 then
- local w, _ = term.getSize()
- local x = math.floor((w - #text) / 2)
- termWriteAt(x, y, text)
- end
- if monitor then
- local w, _ = monitor.getSize()
- local x = math.floor((w - #text) / 2)
- monitorWriteAt(x, y, text)
- end
- end
- function gui.updateMonitor(turbines)
- local turbine = require("turbine")
- gui.clear()
- gui.drawCenteredText(1, "Turbinenstatus")
- local y = 3
- for i, t in ipairs(turbines) do
- local info = turbine.getTurbineInfo(t)
- local lines = {
- string.format("Turbine %d:", i),
- string.format(" Aktiv: %s", tostring(info.active)),
- string.format(" Energie: %d / %d RF", info.energyStored, info.energyCapacity),
- string.format(" Flowrate: %d / %d mB/t", info.fluidFlowRate, info.fluidFlowRateMax),
- string.format(" Rotor: %d RPM", info.rotorSpeed),
- string.format(" RF/t: %.1f", info.energyProducedLastTick)
- }
- for j, line in ipairs(lines) do
- if config.debug == 1 then termWriteAt(1, y + j - 1, line) end
- monitorWriteAt(1, y + j - 1, line)
- end
- y = y + #lines + 1
- end
- end
- return gui
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement