-- startup.lua : Bay Sign Renderer (single monitor) -- Reads config from "bay.cfg" local mon = peripheral.find("monitor") if not mon then error("No monitor attached") end -- ---- settings ---- local TEXT_SCALE = 0.5 -- change to 1.0 if you want bigger text -- ------------------ local function readCfg(path) if not fs.exists(path) then error("Missing config file: " .. path) end local h = fs.open(path, "r") local data = h.readAll() h.close() local ok, cfg = pcall(textutils.unserialize, data) if not ok or type(cfg) ~= "table" then error("Invalid bay.cfg (must be a serialized table)") end return cfg end local cfg = readCfg("bay.cfg") mon.setTextScale(TEXT_SCALE) mon.setBackgroundColor(colors.black) mon.clear() local w, h = mon.getSize() local function center(y, text, color) if y < 1 or y > h then return end if #text > w - 2 then text = string.sub(text, 1, w - 5) .. "..." end mon.setCursorPos(math.floor((w - #text) / 2) + 1, y) mon.setTextColor(color or colors.white) mon.write(text) end local function frame() mon.setTextColor(colors.gray) for x = 1, w do mon.setCursorPos(x, 1) mon.write("═") mon.setCursorPos(x, h) mon.write("═") end for y = 1, h do mon.setCursorPos(1, y) mon.write("║