Hello, CraftOS
Prints to the screen, writes on a monitor and makes a sandboxed web request.
| 1 | -- Welcome to the ccbin.dev Workbench! |
| 2 | -- This is real CraftOS (CC: Tweaked) running in your browser. |
| 3 | -- Edit this program and press Run, or open another one from Examples below. |
| 4 | |
| 5 | term.setTextColour(colours.yellow) |
| 6 | print("Hello from ccbin.dev!") |
| 7 | term.setTextColour(colours.white) |
| 8 | print(os.version() .. " on " .. _HOST) |
| 9 | |
| 10 | local monitor = peripheral.find("monitor") |
| 11 | if monitor then |
| 12 | monitor.setTextScale(0.5) |
| 13 | monitor.setBackgroundColour(colours.blue) |
| 14 | monitor.clear() |
| 15 | local w, h = monitor.getSize() |
| 16 | local text = "ccbin.dev" |
| 17 | monitor.setCursorPos(math.floor((w - #text) / 2) + 1, math.floor(h / 2)) |
| 18 | monitor.setTextColour(colours.yellow) |
| 19 | monitor.write(text) |
| 20 | print(("Monitor attached: %dx%d characters"):format(w, h)) |
| 21 | end |
| 22 | |
| 23 | -- Networking is sandboxed: unless you turn on live network, nothing |
| 24 | -- leaves your browser. Mocks, ccbin's code-host resolver (Pastebin, GitHub, |
| 25 | -- ccbin) and placeholders answer instead. See the Network tab. |
| 26 | print("Trying http.get(\"https://example.com/hello.txt\") ...") |
| 27 | local response, err = http.get("https://example.com/hello.txt") |
| 28 | if response then |
| 29 | term.setTextColour(colours.lime) |
| 30 | print("Sandbox answered: " .. response.readAll()) |
| 31 | term.setTextColour(colours.white) |
| 32 | response.close() |
| 33 | else |
| 34 | term.setTextColour(colours.red) |
| 35 | print(err) |
| 36 | term.setTextColour(colours.white) |
| 37 | end |
Press Run to boot a computer.
- Network requests stay in your browser. The program's mocks answer them, Pastebin and GitHub downloads come through ccbin, and anything else gets a placeholder. The Network panel below lists each request.
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/BxDF2AdOwget https://ccbin.dev/raw/BxDF2AdO startup.luaPrints to the screen, writes on a monitor and makes a sandboxed web request.
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.