local bf = require("bigfont") function switch(value) -- Handing `cases` to the returned function allows the `switch()` function to be used with a syntax closer to c code (see the example below). -- This is because lua allows the parentheses around a table type argument to be omitted if it is the only argument. return function(cases) -- The default case is achieved through the metatable mechanism of lua tables (the `__index` operation). setmetatable(cases, cases) local f = cases[value] if f then f() end end end -- Make screen components function Box(x, y, w, h, bg, outline) -- Draw the background term.setBackgroundColor(bg) term.setTextColor(bg) for i = 1, h do term.setCursorPos(x, y + i) term.write(string.rep(" ", w)) end -- Draw the outline if outline then term.setBackgroundColor(outline) term.setTextColor(outline) term.setCursorPos(x, y) term.write(string.rep(" ", w)) term.setCursorPos(x, y + h) term.write(string.rep(" ", w)) for i = 1, h do term.setCursorPos(x, y + i) term.write(" ") term.setCursorPos(x + w, y + i) term.write(" ") end end end function Text(x, y, text, size, bg, fg) term.setBackgroundColor(bg) term.setTextColor(fg) term.setCursorPos(x + 2, y + 1) switch(size) { ["small"] = function() term.write(text) end, ["medium"] = function() bf.bigWrite(text) end, ["large"] = function() bf.hugeWrite(text) end } end