Monitor clock
Shows the in-game time in big letters on a monitor, updated every second.
| 1 | -- A clock on a monitor. The time is Minecraft's: a day lasts 20 minutes. |
| 2 | |
| 3 | local monitor = peripheral.find("monitor") |
| 4 | if not monitor then |
| 5 | error("Attach a monitor to the computer", 0) |
| 6 | end |
| 7 | |
| 8 | monitor.setTextScale(2) |
| 9 | |
| 10 | local function centre(y, text, colour) |
| 11 | local w = monitor.getSize() |
| 12 | monitor.setCursorPos(math.floor((w - #text) / 2) + 1, y) |
| 13 | monitor.setTextColour(colour) |
| 14 | monitor.write(text) |
| 15 | end |
| 16 | |
| 17 | print("Showing the time on the monitor. Hold Ctrl+T to stop.") |
| 18 | while true do |
| 19 | local time = os.time() |
| 20 | local night = time < 6 or time >= 19 |
| 21 | monitor.setBackgroundColour(night and colours.blue or colours.lightBlue) |
| 22 | monitor.clear() |
| 23 | local _, h = monitor.getSize() |
| 24 | centre(math.floor(h / 2), textutils.formatTime(time, true), colours.white) |
| 25 | centre(math.floor(h / 2) + 1, "Day " .. os.day(), night and colours.lightGrey or colours.blue) |
| 26 | sleep(1) |
| 27 | end |
Press Run to boot a computer.
Network
Every request the program makes, and how the sandbox answered it. The program's own mocks answer first. Pastebin, GitHub and ccbin downloads go through ccbin. Anything else gets a placeholder, or an error if the scene says so. Nothing else leaves your browser unless you turn on live network.
Install in your world
wget run https://ccbin.dev/i/ujtgACwswget https://ccbin.dev/raw/ujtgACws startup.luaShows the in-game time in big letters on a monitor, updated every second.
This is one of the examples in the Workbench. Run it here, or open it in the Workbench to change it.
Comments
No comments yet.
Sign in to comment.